This repository was archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildsys.cmake
530 lines (460 loc) · 17.3 KB
/
buildsys.cmake
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# sanity check: no in-tree build
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "In-source build is disabled. Remove the already"
"generated files [CMakeCache.txt CMakFiles/] and start again"
"from dedicated build directory.")
endif()
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
# buildsystem as a dependency: fake dependency (e.g. BuildSystem>=1.0)
set(BuildSystem_VERSION 1.15)
set(BuildSystem_FOUND TRUE)
set(BuildSystem_LIBRARIES)
set(BuildSystem_DEFINITION)
set(BuildSystem_TARGETS)
# remember buildsystem root
set(BUILDSYS_ROOT ${CMAKE_CURRENT_LIST_DIR})
# remember buildsystem binary root
set(BUILDSYS_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR})
## set(SUPPORTED_PLATFORMS "Linux;Darwin;"
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_SUFFIX)
set(_PLATFORM_FILE "${BUILDSYS_ROOT}/macros/buildsys.${SYSTEM_SUFFIX}.cmake")
if(EXISTS ${_PLATFORM_FILE})
include(${_PLATFORM_FILE})
else()
message(FATAL_ERROR "Unsupported platform <${CMAKE_SYSTEM_NAME}> (missing file <${_PLATFORM_FILE}>).")
endif()
if(WIN32 AND MSVC)
# get rid of bin/Release, bin/Debug, etc. subdirectories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
macro(cpp_msvc_overrides)
# enable intrinsic functions, favor faster code (instead of smaller code)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/arch:AVX>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Oi>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Ot>)
# disable security checks (stack buffer overrun prevention)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release>>:/GS->)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release>>:/O2>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RelWithDebInfo>>:/GS->)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RelWithDebInfo>>:/O2>)
# # disable warning: class 'type' needs to have dll-interface
# # to be used by clients of class 'type2'
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4251>)
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4275>)
# # disable warning: conversion from 'type' to 'type2', possible loss of data
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4305>)
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4244>)
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4305>)
# # disable warning: unary minus operator applied
# # to unsigned type, result still unsigned
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4146>)
# disable warning: deprecated declaration
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4996>)
# not enough arguments for function-like macro invocation
# should be fixed in newer VC https://developercommunity.visualstudio.com/t/
# standard-conforming-preprocessor-invalid-warning-c/364698
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4003>)
# strict warnings, all errors
# TODO: allow W4 or Wall
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W3>)
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>)
# disable external warnings
# https://devblogs.microsoft.com/cppblog/broken-warnings-theory/
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/external:anglebrackets>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/external:W0>)
# TODO(?): allow external warnings stemming from internal template init.
# add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/external:templates->)
# enable multi process compilation
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/MP>)
# stricter conformance with c++ standard
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/permissive->)
# avoid fatal error: number of sections exceeded object file format limit
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/bigobj>)
# disable linker warning: PDB (debug symbols) not found
add_link_options(/ignore:4099)
if(BUILDSYS_RELEASE_NDEBUG)
# eliminate unreferenced functions
add_link_options(/OPT:REF)
# not possible with /OPT:REF
add_link_options(/INCREMENTAL:NO)
endif()
# avoid some especially obtrusive macro definitions in windows.h
add_definitions(/DWIN32_LEAN_AND_MEAN)
add_definitions(/DNOMINMAX)
add_definitions(/D_USE_MATH_DEFINES)
add_definitions(/D_ENABLE_EXTENDED_ALIGNED_STORAGE)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endmacro()
macro(cpp_gcc_overrides)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wall>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wextra>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-pedantic-errors>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-date-time>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-misleading-indentation>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-function>)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
endmacro()
macro(cpp_appleclang_overrides)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wall>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wextra>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-stdlib=libc++>)
endmacro()
# enable C11
macro(enable_c11)
set(CMAKE_C_STANDARD 11)
if (CMAKE_C_COMPILER_ID MATCHES GNU)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wall>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wextra>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Werror>)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-pedantic-errors>)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
# compiler newer than 4.x
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-date-time>)
endif()
elseif (CMAKE_C_COMPILER_ID MATCHES Clang)
# add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=c1x>)
elseif (CMAKE_C_COMPILER_ID MATCHES MSVC)
cpp_msvc_overrides()
else()
message(FATAL_ERROR "Unknown C compiler: ${CMAKE_C_COMPILER_ID}.")
endif()
message(STATUS "Enabled C11 for C (${CMAKE_C_COMPILER_ID})")
endmacro()
# enable C++11
macro(enable_cpp11)
set(CMAKE_CXX_STANDARD 11)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic-errors")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
# old compilers, use C++0x
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-unused-function")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
# compiler newer than 4.x
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-date-time")
else()
# 4.x or older
set(BUILDSYS_LIMITED_CPP11 TRUE)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
# compiler newer than 5.x
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation")
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
# compiler newer than 8.x; needed by Eigen3
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wno-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
cpp_msvc_overrides()
else()
message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}.")
endif()
message(STATUS "Enabled C++11 for C++ (${CMAKE_CXX_COMPILER_ID})")
endmacro()
# enable C++14
macro(enable_cpp14)
set(CMAKE_CXX_STANDARD 14)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
cpp_gcc_overrides()
elseif(CMAKE_CXX_COMPILER_ID MATCHES AppleClang)
cpp_appleclang_overrides()
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang AND NOT CMAKE_CXX_COMPILER_ID MATCHES AppleClang)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-conversion>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-braces>)
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
cpp_msvc_overrides()
else()
message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}.")
endif()
message(STATUS "Enabled C++14 for C++ (${CMAKE_CXX_COMPILER_ID})")
endmacro()
# enable C++17
macro(enable_cpp17)
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
cpp_gcc_overrides()
elseif(CMAKE_CXX_COMPILER_ID MATCHES AppleClang)
cpp_appleclang_overrides()
elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang AND NOT CMAKE_CXX_COMPILER_ID MATCHES AppleClang)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-conversion>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-braces>)
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
cpp_msvc_overrides()
else()
message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}.")
endif()
message(STATUS "Enabled C++17 for C++ (${CMAKE_CXX_COMPILER_ID})")
endmacro()
# enable visibility=hidden
macro(enable_hidden_visibility)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
endmacro()
macro(set_visibility TARGET VISIBILITY)
if (${VISIBILITY} STREQUAL hidden)
set(inline_hidden ON)
else()
set(inline_hidden OFF)
endif()
set_target_properties(${TARGET} PROPERTIES
C_VISIBILITY_PRESET ${VISIBILITY}
CXX_VISIBILITY_PRESET ${VISIBILITY}
VISIBILITY_INLINES_HIDDEN ${inline_hidden})
endmacro()
macro(unset_visibility TARGET)
# unseall all visibility-related flags
set_property(TARGET ${TARGET} PROPERTY C_VISIBILITY_PRESET)
set_property(TARGET ${TARGET} PROPERTY CXX_VISIBILITY_PRESET)
set_property(TARGET ${TARGET} PROPERTY VISIBILITY_INLINES_HIDDEN)
endmacro()
macro(enable_threads)
find_package(Threads REQUIRED)
set(THREADS_LIBRARIES Threads::Threads)
endmacro()
macro(setup_project NAME VERSION)
# obsoleted
message(FATAL_ERROR "Use project(${NAME}) before including buildsys/cmake/buildsys.cmake")
endmacro()
macro(append_parent_directory_list_property PROPERTY)
get_directory_property(PARENT_DIRECTORY
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
PARENT_DIRECTORY)
set_property(DIRECTORY ${PARENT_DIRECTORY} APPEND
PROPERTY ${PROPERTY} ${ARGN})
endmacro()
macro(append_parent_directory_property PROPERTY)
get_directory_property(PARENT_DIRECTORY
DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
PARENT_DIRECTORY)
set_property(DIRECTORY ${PARENT_DIRECTORY} APPEND_STRING
PROPERTY ${PROPERTY} ${ARGN})
endmacro()
# Set target version to ${VERSION} or ${VERSION}-${CMAKE_BUILD_TYPE}
macro(set_target_version TARGET VERSION)
if (0)
if (CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
set_target_properties(${TARGET} PROPERTIES VERSION
${VERSION}-${BUILD_TYPE})
else()
set_target_properties(${TARGET} PROPERTIES VERSION
${VERSION})
endif()
endif()
set_property(TARGET ${TARGET} APPEND
PROPERTY COMPILE_DEFINITIONS
BUILD_TARGET_VERSION=\"${VERSION}\"
BUILD_TARGET_NAME=\"${TARGET}\")
endmacro()
macro(setup_build_system_overrides)
# enable profiler if forced to
if(BUILDSYS_FORCE_PROFILER)
message(STATUS "Forcing GNU profiler.")
set(INTERNAL_BUILDSYS_DISABLE_OPENMP TRUE)
enable_profiler()
else()
set(INTERNAL_BUILDSYS_DISABLE_OPENMP FALSE)
endif()
endmacro()
macro(setup_customer)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BT)
if (BUILDSYS_CUSTOMER_BUILD_${BT})
set(BUILDSYS_CUSTOMER_BUILD TRUE)
add_definitions("-DBUILDSYS_CUSTOMER_BUILD=1")
if (NOT BUILDSYS_CUSTOMER)
message(FATAL_ERROR "Custom build requested but no customer is set. "
"Please, set BUILDSYS_CUSTOMER variable.")
endif()
add_definitions("-DBUILDSYS_CUSTOMER=\"${BUILDSYS_CUSTOMER}\"")
message(STATUS "Custom build for '${BUILDSYS_CUSTOMER}'.")
# create shell variable
string(TOUPPER ${BUILDSYS_CUSTOMER} BUILDSYS_CUSTOMER_SHELL)
string(REPLACE "-" "_" BUILDSYS_CUSTOMER_SHELL ${BUILDSYS_CUSTOMER_SHELL})
string(REPLACE "." "_" BUILDSYS_CUSTOMER_SHELL ${BUILDSYS_CUSTOMER_SHELL})
else()
set(BUILDSYS_CUSTOMER_SHELL "")
endif()
endmacro()
# setup common build system options
macro(setup_build_system)
if (${PROJECT_NAME} STREQUAL Project)
message(FATAL_ERROR "Use project(projecname) before including buildsys/cmake/buildsys.cmake")
endif()
# set default buildsys version
if (NOT BUILDSYS_PACKAGE_VERSION)
set(BUILDSYS_PACKAGE_VERSION "test")
endif()
message(STATUS "Setting up project <${PROJECT_NAME}>, version <${BUILDSYS_PACKAGE_VERSION}>.")
set(${PROJECT_NAME}_VERSION ${BUILDSYS_PACKAGE_VERSION})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
message(STATUS "*** Defaulting to ${CMAKE_BUILD_TYPE} build type.")
else()
message(STATUS "Build type: <${CMAKE_BUILD_TYPE}>.")
endif()
# pass build type to compiler
string(TOUPPER "${CMAKE_BUILD_TYPE}" BT)
add_definitions("-DCMAKE_BUILD_TYPE_${BT}=1")
# add install prefix
buildsys_compile_with_install_prefix()
# add this directory to the modules path
if(BUILDSYS_CONAN)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules.Conan)
endif()
if(WIN32)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules.Win32)
else()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
if (CMAKE_VERSION VERSION_LESS 3.7)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules.xenial)
endif()
endif()
if(NOT BUILDSYS_CPP_STANDARD)
# fallback to cpp/c 11
set(BUILDSYS_CPP_STANDARD 11)
endif()
if (BUILDSYS_CPP_STANDARD EQUAL 11)
enable_cpp11()
elseif (BUILDSYS_CPP_STANDARD EQUAL 14)
enable_cpp14()
elseif (BUILDSYS_CPP_STANDARD EQUAL 17)
enable_cpp17()
else()
message(FATAL_ERROR "Unknown C++ standard ${BUILDSYS_CPP_STANDARD} requested.")
endif()
# C++ standard as a fake dependency
set(C++_FOUND TRUE)
set(C++_VERSION ${BUILDSYS_CPP_STANDARD})
set(C++_LIBRARIES)
set(C++_DEFINITION)
# enable C11 by default
enable_c11()
enable_threads()
if(CMAKE_Fortran_COMPILER)
set(Fortran_FOUND TRUE)
set(Fortran_VERSION 95)
set(Fortran_LIBRARIES)
set(Fortran_DEFINITION)
endif()
# setup include dirs
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# operating system specific stuff
setup_build_system_os_specific()
# overrides
setup_build_system_overrides()
# customer setup
setup_customer()
endmacro()
# find python2 binary to be used in tools
if (WIN32)
find_package(Python2 COMPONENTS Interpreter)
set(PYTHON3_BINARY ${Python2_EXECUTABLE})
find_package(Python3 COMPONENTS Interpreter)
set(PYTHON3_BINARY ${Python3_EXECUTABLE})
else()
find_program(PYTHON2_BINARY python2)
find_program(PYTHON3_BINARY python3)
endif()
if(PYTHON3_BINARY)
set(PYTHON_BINARY ${PYTHON3_BINARY})
else()
set(PYTHON_BINARY ${PYTHON2_BINARY})
endif()
if(NOT PYTHON_BINARY)
message(FATAL_ERROR "Please install python2 and/or python3.")
else()
message(STATUS "Using ${PYTHON_BINARY} as buildsys python.")
endif()
# load sub modules
foreach(submodule
module
profiler
openmp
ccache
cuda
opencl
opencv
test
legacy
traceback
hostname
make-output-file
install-conan-deps
install-prefix
output-paths
python
customer
debug
dict
clone
library-support
opengl
symlink-fixes
tensorflow
torch
torchvision
tensorrt
exclude-from-all
build-types/release
build-types/customerdebug
build-types/customerrelease
)
include(${CMAKE_CURRENT_LIST_DIR}/macros/${submodule}.cmake)
endforeach()
# load tools
foreach(tool
file2cpp
sqlite32cpp
py2cpp
pathstrip
ocl2cpp
pandoc
py-runnable
compile-pyc
)
include(${CMAKE_CURRENT_LIST_DIR}/tools/${tool}/${tool}.cmake)
endforeach()
# ------------------------------------------------------------------------
# setup the build system now
# ------------------------------------------------------------------------
setup_build_system()
# ------------------------------------------------------------------------
# load extra project configuration if exists
# ------------------------------------------------------------------------
# main stuff
include(${CMAKE_SOURCE_DIR}/cmake/config.cmake OPTIONAL
RESULT_VARIABLE file_included)
if(file_included)
message(STATUS "Loaded configuration from ${file_included}.")
endif()
# customer stuff
if(BUILDSYS_CUSTOMER_BUILD)
include(${CMAKE_SOURCE_DIR}/cmake/config.${BUILDSYS_CUSTOMER}.cmake
OPTIONAL RESULT_VARIABLE file_included)
if(file_included)
message(STATUS "Loaded customer configuration from ${file_included}.")
endif()
endif()
if(COMMAND buildsys_fix_sources)
buildsys_fix_sources()
endif()