-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
107 lines (80 loc) · 3.41 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cmake_minimum_required(VERSION 2.8.12)
###### override builtin gcc CFLAGS
# because we don't want NDEBUG
set (CMAKE_USER_MAKE_RULES_OVERRIDE_C "${CMAKE_CURRENT_SOURCE_DIR}/cmake/override_c.cmake")
# don't go polluting c:\program files ; this has to go before project()
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Default install prefix")
set (TEMP_INSTPREFIX ${CMAKE_INSTALL_PREFIX})
message("Using install prefix : ${CMAKE_INSTALL_PREFIX}")
project(nisprog)
#check if install prefix was clobbered
if ( NOT(${CMAKE_INSTALL_PREFIX} STREQUAL ${TEMP_INSTPREFIX}))
message(WARNING "Default install prefix has been corrupted ! please report this.")
#note : if this happens, the alternative is something like
#if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# set(installprefix .etc... FORCE)
#endif()
#placed after project().
endif ()
include (CheckLibraryExists)
include (CheckFunctionExists)
include (CheckTypeSize)
include (ExternalProject)
set (PKGVERSIONMAJOR "1")
set (PKGVERSIONMINOR "05")
set (PKGVERSION "${PKGVERSIONMAJOR}.${PKGVERSIONMINOR}")
set (NP_PROGNAME "nisprog")
#that sets the command-line tool prompt.
###### fill metadata file
configure_file (np_conf.h.in np_conf.h)
###### Compiler flags & build types
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
message(STATUS "No build type selected, defaulting to Debug")
message(STATUS "Available build types : Debug, Release, RelWithDebInfo")
set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif ()
###### add some CFLAGS
if (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -pedantic -std=gnu99 -Wstrict-prototypes -Wsign-compare -Wredundant-decls" )
#else ()
#not sure what we should use on other compilers.
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif ()
message(STATUS "Generating make/project files for: ${CMAKE_GENERATOR}")
###### Type checks
check_type_size (char CHARSIZE)
check_type_size (uint8_t UINT8SIZE)
check_type_size (uint16_t UINT16SIZE)
check_type_size (uint32_t UINT32SIZE)
if (NOT (${CHARSIZE} EQUAL 1))
message(FATAL_ERROR "Error, sizeof(char) must be 1 !")
endif()
set(L0LIST "dumb" "dumbtest" "sim")
set(L2LIST "iso9141" "iso14230" "raw")
add_subdirectory(freediag external EXCLUDE_FROM_ALL)
unset(CMAKE_C_CPPCHECK CACHE)
# Add a custom command that produces version.c, plus
# a dummy output that's not actually produced, in order
# to force version.cmake to always be re-run before the build
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.c
${CMAKE_CURRENT_BINARY_DIR}/_version.c
COMMAND ${CMAKE_COMMAND}
-D SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake
)
set (NISPROG_SRCS nisprog.c np_cli.c nis_backend.c npk_backend.c ssm_backend.c
scantool_bits.c
nissutils/cli_utils/nislib.c nissutils/cli_utils/ecuid_list.c
${CMAKE_CURRENT_BINARY_DIR}/version.c
)
add_executable(nisprog ${NISPROG_SRCS})
target_include_directories(nisprog PUBLIC freediag/scantool)
target_include_directories(nisprog PUBLIC ${PROJECT_BINARY_DIR})
target_include_directories(nisprog PUBLIC ${PROJECT_BINARY_DIR}/external)
target_link_libraries(nisprog diag freediagcli)
#add_dependencies(nisprog freediag)