forked from polserver/polserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
171 lines (140 loc) · 4.79 KB
/
CMakeLists.txt
File metadata and controls
171 lines (140 loc) · 4.79 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
cmake_minimum_required(VERSION 3.2)
# protect the user for himself
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
Remove CMakeCache.txt and CMakeFiles folder and
Switch to bin-build.")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "!BuildTargets")
#fix default compiler flags for MSVC (/Md vs /MT)
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake)
project(polserver CXX C)
set(POL_VERSION_STR "100")
set(POL_VERSION 100)
set(POL_VERSION_NAME "Never Gonna Give You Up")
option(NO_PCH "Disable pre-compiled headers" OFF)
option(USE_CCACHE "Use ccache if found" OFF)
option(ENABLE_BENCHMARK "Enable benchmark support" OFF)
option(ENABLE_FLYWEIGHT_REPORT "Enables flyweight memory report in memoryusage.log" OFF)
option(BUILD_ALL "Build everything" ON)
option(ONLY_ECOMPILE "Build only ecompile" OFF)
option(ONLY_RUNECL "Build only runecl" OFF)
option(ONLY_POL "Build only pol" OFF)
option(ONLY_POLTOOL "Build only poltool" OFF)
option(ONLY_UOCONVERT "Build only uoconvert" OFF)
option(ONLY_UOTOOL "Build only uotool" OFF)
option(ENABLE_ASAN "Enables Address sanitizer" OFF)
option(ENABLE_USAN "Enables Undefined sanitizer" OFF)
option(ENABLE_MSAN "Enables Memory sanitizer" OFF)
option(ENABLE_TSAN "Enables Thread sanitizer" OFF)
option(ENABLE_TIDY "Enables clang tidy check" OFF)
# e.g "-fix;-checks=modernize-use-nullptr")
set(TIDY_ARGS "" CACHE STRING "clang tidy arguments")
if(${ONLY_ECOMPILE} OR ${ONLY_RUNECL} OR ${ONLY_POL} OR ${ONLY_POLTOOL} OR ${ONLY_UOCONVERT} OR ${ONLY_UOTOOL})
set(BUILD_ALL OFF)
endif()
if(${ENABLE_TIDY})
set(NO_PCH ON)
endif()
include(cmake/init.cmake)
set(output_bin_dir "${CMAKE_SOURCE_DIR}/bin")
message("####################################")
message("# ${PROJECT_NAME} - ${POL_VERSION_STR} #")
message("# - ${POL_VERSION_NAME} - #")
message("####################################")
message("## CMake Version ${CMAKE_VERSION}")
message("## Generator ${CMAKE_GENERATOR} ${CMAKE_EXTRA_GENERATOR}")
message("## Output Dir: ${output_bin_dir}")
if (NO_PCH)
message("## No precompiled header")
endif()
if (ENABLE_TIDY)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(ERROR "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "clang-tidy args: ${TIDY_ARGS}")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "${TIDY_ARGS}")
endif()
endif()
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message("## building with ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
endif()
message("")
include(CheckIncludeFiles)
include(ExternalProject)
include(cmake/compile_defs.cmake)
include(cmake/release.cmake)
include(cmake/cotire.cmake)
#hide the cotire settings
hide_cotire()
fix_compiler_flags()
detect_compiler()
detect_arch()
detect_platform()
git_revision_target()
if (${linux})
option(STRIP_BINARIES "Strip binaries directly, instead of only in package target" OFF)
endif()
prepare_build()
cmake_fake_target()
include(cmake/Boost.cmake)
include(cmake/Benchmark.cmake)
include(cmake/Format.cmake)
include(cmake/Kaitai.cmake)
if (${windows})
include(cmake/ZLib.cmake)
include(cmake/StackWalker.cmake)
endif()
if (BUILD_ALL OR ONLY_POL)
include(cmake/Curl.cmake)
endif()
include(cmake/TinyXML.cmake)
add_subdirectory(docs)
add_subdirectory(pol-core)
#cmake package target for creating archive
release()
if (BUILD_ALL OR ONLY_POL)
if (${CMAKE_VERSION} VERSION_GREATER "3.6.0")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT pol)
endif()
endif()
add_polrelease_target()
#ctest integration
#splitted into each escript testfolder to allow parallel execution
if (BUILD_ALL OR (ONLY_ECOMPILE AND ONLY_RUNECL))
message("activating test target")
enable_testing()
set(testdir ${CMAKE_CURRENT_SOURCE_DIR}/testsuite/escript)
file(GLOB children RELATIVE ${testdir} ${testdir}/*)
foreach(child ${children})
if(IS_DIRECTORY ${testdir}/${child})
string(FIND "${child}" "_" out)
if(${out} EQUAL 0)
continue()
endif()
add_test(NAME escript_${child}
COMMAND ${CMAKE_COMMAND}
-Dtestdir=${testdir}
-Dsubtest=${child}
-Decompile=${output_bin_dir}/ecompile
-Drunecl=${output_bin_dir}/runecl
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/escripttest.cmake
WORKING_DIRECTORY ${testdir}
)
endif()
endforeach()
endif()