-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (101 loc) · 4.27 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_FLAGS "-Wall -pedantic -Werror -g3 ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(common_tools_lib C CXX)
if (DEFINED PIL_ALL)
option(PIL_SHARED "Build shared library" ON)
option(PIL_STATIC "Build static library" ON)
option(PIL_CXX "Enable C++ support" ON)
option(PIL_EXCEPTION_HANDLING "Enable exception handling in C++ version" ON)
option(PIL_COMMUNICATION "Enable UART and socket communication" ON)
option(PIL_THREADING "Enable multithreading support" ON)
option(PIL_FILE_HANDLING "Enable file handling support" ON)
option(PIL_LOGGING "Enable logging support" ON)
option(PIL_TIMING "Enable exception handling in C++ version" ON)
option(PIL_CSV "Enable CSV file support" ON)
option(PIL_BUILD_DOCUMENTATION "Build doxygen code documentation" OFF)
if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
option(PIL_UNIT_TESTING "Enable Unit testing" ON)
endif()
endif () # PIL_ALL
if(PIL_CXX)
add_definitions(-DPIL_CXX=1)
endif() # PIL_CXX
if(PIL_EXCEPTION_HANDLING)
add_definitions(-DPIL_EXCEPTION_HANDLING=1)
endif()
if (PIL_COMMUNICATION)
include(Communication/SourceFiles.cmake)
endif () # DEFINED COMMUNICATION
if (PIL_TIMING)
include(Timing/SourceFiles.cmake)
endif()
if (PIL_FILE_HANDLING)
include(FileHandling/SourceFiles.cmake)
endif() # DEFINED FILE_HANDLING
if (PIL_LOGGING)
include(Logging/SourceFiles.cmake)
endif () # DEFINED LOGGING
if(PIL_THREADING)
include("Threading/SourceFiles.cmake")
endif() # THREADING
if(PIL_STRING)
set(string "${CMAKE_CURRENT_SOURCE_DIR}/String/src/String.cpp"
"String/include/ctlib/String.h")
endif() # STRING
if(PIL_CSV)
set(csv "${CMAKE_CURRENT_SOURCE_DIR}/Protocols/src/CSVHandler.c"
"Protocols/include/ctlib/CSVHandler.h")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Protocols/include")
endif()
include("ErrorHandling/SourceFiles.cmake")
set(additional_headers "Additional/ctlib/DataTypeDefines.h")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/Additional")
set(source_files ${logging} ${communication} ${file_handling} ${errorHandling} ${additional_headers} ${unitTestFiles} ${threading} ${string} ${csv} ${timing_cxx})
if (DEFINED PIL_SHARED)
add_library(common_tools_lib SHARED ${source_files})
if(PIL_STATIC_LIBGCC)
target_link_options(common_tools_lib PUBLIC -static -static-libgcc -static-libstdc++)
endif()
if(WIN32)
target_link_libraries(common_tools_lib PRIVATE ws2_32 wsock32)
else()
target_link_libraries(common_tools_lib PRIVATE pthread)
endif()
set_target_properties(common_tools_lib PROPERTIES PUBLIC_HEADER
"${errorHandling_headers};${communication_headers};${file_handling_headers};${logging_headers};${threading_headers};${additional_headers};${timing_cxx_headers}")
endif () # DEFINED SHARED
if (DEFINED PIL_STATIC)
add_library(common_tools_lib_static STATIC ${source_files})
if(PIL_STATIC_LIBGCC)
target_link_options(common_tools_lib_static PUBLIC -static -static-libgcc -static-libstdc++)
endif()
if(WIN32)
target_link_libraries(common_tools_lib_static PRIVATE ws2_32 wsock32)
else()
target_link_libraries(common_tools_lib_static PRIVATE pthread)
endif()
endif () # DEFINED STATIC
if (PIL_UNIT_TESTING)
add_subdirectory(googletest)
enable_testing()
include(GoogleTest)
include(UnitTesting/build_unittest.cmake)
endif () # PIL_UNIT_TESTING
if(PIL_BUILD_DOCUMENTATION)
include(cmake/build_documentation.cmake)
pil_build_documentation()
endif() # DEFINED BUILD_DOCUMENTATION
if(PIL_BUILD_DEB)
include(cmake/installers/deb_installer.cmake)
build_deb()
endif() # PIL_BUILD_DEB
if(PIL_BUILD_BUNDLE)
include(cmake/installers/mac_bundle_installer.cmake)
build_mac_bundle()
endif() # PIL_BUILD_BUNDLE
if(PIL_NSIS_BUILD)
include(cmake/installers/windows_nsis_installer.cmake)
build_nsis_installer()
endif() # PIL_NSIS_BUILD