-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
135 lines (107 loc) · 5.71 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
133
134
cmake_minimum_required (VERSION 3.10)
project ("commsdsl")
option (COMMSDSL_WARN_AS_ERR "Treat warning as error" ON)
option (COMMSDSL_USE_CCACHE "Use ccache on UNIX systems if it's available" OFF)
option (COMMSDSL_INSTALL_LIBRARY "Install commdsl library" OFF )
option (COMMSDSL_INSTALL_LIBRARY_HEADERS "Install commdsl library headers" ${COMMSDSL_INSTALL_LIBRARY})
option (COMMSDSL_BUILD_COMMSDSL2COMMS "Build commsdsl2comms" ON)
option (COMMSDSL_BUILD_COMMSDSL2TEST "Build commsdsl2test" OFF)
option (COMMSDSL_BUILD_COMMSDSL2TOOLS_QT "Build commsdsl2tools_qt" OFF)
option (COMMSDSL_BUILD_COMMSDSL2SWIG "Build commsdsl2swig" OFF)
option (COMMSDSL_BUILD_COMMSDSL2EMSCRIPTEN "Build commsdsl2emscripten" OFF)
option (COMMSDSL_BUILD_WITH_SANITIZERS "Build with sanitizers enables" OFF)
option (COMMSDSL_INSTALL_APPS "Install applications" ON)
option (COMMSDSL_BUILD_UNIT_TESTS "Build unittests." OFF)
option (COMMSDSL_BUILD_COMMSDSL2COMMS_TESTS "Build commsdsl2comms unittests." ${COMMSDSL_BUILD_UNIT_TESTS})
option (COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS "Build commsdsl2tools_qt unittests." ${COMMSDSL_BUILD_UNIT_TESTS})
option (COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS_CHUNK1 "Build chunk1 commsdsl2tools_qt unittests." ${COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS})
option (COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS_CHUNK2 "Build chunk2 commsdsl2tools_qt unittests." ${COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS})
option (COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS_CHUNK3 "Build chunk3 commsdsl2tools_qt unittests." ${COMMSDSL_BUILD_COMMSDSL2TOOLS_QT_TESTS})
option (COMMSDSL_BUILD_COMMSDSL2TEST_TESTS "Build commsdsl2test unittests." ${COMMSDSL_BUILD_UNIT_TESTS})
option (COMMSDSL_VALGRIND_TESTS "Enable testing with valgrind (applicable when COMMSDSL_BUILD_UNIT_TESTS is on)" OFF)
option (COMMSDSL_TEST_USE_SANITIZERS "Build unittiests with sanitizers (applicable when COMMSDSL_BUILD_UNIT_TESTS is on)" ON)
option (COMMSDSL_TEST_BUILD_DOC "Build documentation target in generated projects (applicable when COMMSDSL_BUILD_UNIT_TESTS is on)" OFF)
option (COMMSDSL_FORCE_INTERNAL_LIBXML_BUILD "Force internal build of libxml2 when external one is not found" OFF)
# Additional variables to be used if needed
# ---------------------------
# COMMSDSL_TESTS_CXX_STANDARD - The C++ standard to use in tests, defaults to 11
# COMMSDSL_TESTS_C_COMPILER - C compiler to build unittests
# COMMSDSL_TESTS_CXX_COMPILER - C++ compiler to build unittests
# COMMSDSL_EXTERNALS_DIR - Directory to contain sources for external projects, defaults to ${PROJECT_SOURCE_DIR}/externals.
# COMMSDSL_TESTS_QT_VERSION - The major Qt version for tests, defaults to 5
# COMMSDSL_CCACHE_EXECUTABLE - Path to ccache executable
# Other used CMake variables
# CMAKE_CXX_STANDARD - The C++ standard to use during the compilation, defaults to 17 (min)
# Deprecated options for backward compatibility, use the ones above for new builds.
# ---------------------------
# option (COMMSDSL_NO_WARN_AS_ERR "Do NOT treat warning as error" OFF)
# option (COMMSDSL_NO_CCACHE "Disable use of ccache on UNIX system" OFF)
# option (COMMSDSL_NO_TESTS "Disable unittesting" OFF)
# option (COMMSDSL_WIN_ALLOW_LIBXML_BUILD "Allow internal build of libxml2 on Windows platforms" ON)
################################################
set (CMAKE_SCIPTS_DIR "${PROJECT_SOURCE_DIR}/cmake")
include (${CMAKE_SCIPTS_DIR}/CommsdslFuncs.cmake)
include (${CMAKE_SCIPTS_DIR}/CommsdslCompile.cmake)
################################################
# Check usage of deprecated options and ovewrite the default values of proper ones
commsdsl_negate_option(COMMSDSL_NO_WARN_AS_ERR COMMSDSL_WARN_AS_ERR)
commsdsl_negate_option(COMMSDSL_NO_CCACHE COMMSDSL_USE_CCACHE)
commsdsl_negate_option(COMMSDSL_NO_TESTS COMMSDSL_BUILD_UNIT_TESTS)
if (WIN32 AND COMMSDSL_WIN_ALLOW_LIBXML_BUILD)
set (COMMSDSL_FORCE_INTERNAL_LIBXML_BUILD ON)
endif ()
################################################
if ("${COMMSDSL_TESTS_QT_VERSION}" STREQUAL "")
set (COMMSDSL_TESTS_QT_VERSION 5)
endif ()
if ("${CMAKE_CXX_STANDARD}" STREQUAL "")
set (CMAKE_CXX_STANDARD 17)
endif ()
if ("${CMAKE_CXX_STANDARD}" VERSION_LESS "17")
message (FATAL_ERROR "Use C++17 or later to compile this project.")
endif()
if ("${COMMSDSL_TESTS_CXX_STANDARD}" STREQUAL "")
set (COMMSDSL_TESTS_CXX_STANDARD ${CMAKE_CXX_STANDARD})
endif ()
if (NOT COMMSDSL_TESTS_C_COMPILER)
set (COMMSDSL_TESTS_C_COMPILER ${CMAKE_C_COMPILER})
endif ()
if (NOT COMMSDSL_TESTS_CXX_COMPILER)
set (COMMSDSL_TESTS_CXX_COMPILER ${CMAKE_CXX_COMPILER})
endif ()
if (NOT COMMSDSL_EXTERNALS_DIR)
set (COMMSDSL_EXTERNALS_DIR "${PROJECT_SOURCE_DIR}/externals")
endif ()
# Compiler options
set (extra_opts)
if (COMMSDSL_WARN_AS_ERR)
list (APPEND extra_opts WARN_AS_ERR)
endif ()
if (COMMSDSL_USE_CCACHE)
list (APPEND extra_opts USE_CCACHE)
if (NOT "${COMMSDSL_CCACHE_EXECUTABLE}" STREQUAL "")
list (APPEND extra_opts CCACHE_EXECUTABLE "${COMMSDSL_CCACHE_EXECUTABLE}")
endif ()
endif ()
if (COMMSDSL_BUILD_WITH_SANITIZERS)
list (APPEND extra_opts DEFAULT_SANITIZERS)
endif ()
commsdsl_compile(${extra_opts})
commsdsl_msvc_force_warn_opt("/W4")
set (COMMSDSL_FOUND_COMMS_INTERNAL OFF CACHE INTERNAL "Mark COMMS library found" FORCE)
function (commsdsl_mark_comms_found)
set (COMMSDSL_FOUND_COMMS_INTERNAL ON CACHE INTERNAL "Mark COMMS library found" FORCE)
endfunction ()
################################################
if (COMMSDSL_BUILD_UNIT_TESTS)
find_package(LibComms REQUIRED)
include (${LibComms_DIR}/CC_CxxtestFuncs.cmake)
cc_get_cxxtest(INSTALL_PREFIX ${COMMSDSL_EXTERNALS_DIR})
if (COMMSDSL_VALGRIND_TESTS)
find_program(VALGRIND_EXECUTABLE NAMES "valgrind")
endif ()
enable_testing()
endif ()
include(GNUInstallDirs)
add_subdirectory(lib)
add_subdirectory(app)