forked from dfeneyrou/palanteer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
100 lines (79 loc) · 3.79 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
cmake_minimum_required(VERSION 3.15)
project(palanteer VERSION 1.0.0 DESCRIPTION "Palanteer")
# Options
# All targets are not required for all usages
# * C++ developer who does not plan to script : only the viewer (as the C++ instrumentation library is a header file). No Python required.
# * C++ developer who wants to script only : only the python scripting package
# * Python developer who does not plan to script: the viewer and the python instrumentation package
# * Python developer who wants to script only : the python scripting package and the python instrumentation package
option(PALANTEER_BUILD_VIEWER "Build the Server/Viewer" ON)
option(PALANTEER_BUILD_CPP_EXAMPLE "Build the C++ example program" ON)
option(PALANTEER_BUILD_PYTHON_INSTRUMENTATION "Build the python instrumentation" ON)
option(PALANTEER_BUILD_SERVER_SCRIPTING "Build the python scripting package" ON)
# Policies
cmake_policy(SET CMP0009 NEW) # For GLOB_RECURSE
cmake_policy(SET CMP0072 NEW) # For OpenGL (Linux)
# Use ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif(CCACHE_PROGRAM)
# Add the ASAN target
set(CMAKE_CXX_FLAGS_ASAN "-Wall -fsanitize=address -fno-omit-frame-pointer -g" CACHE STRING
"Flags used by the C++ compiler during asan builds." FORCE)
set(CMAKE_C_FLAGS_ASAN "-Wall -fsanitize=address -fno-omit-frame-pointer -g" CACHE STRING
"Flags used by the C compiler during asan builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN
"-fsanitize=address" CACHE STRING "Flags used for linking binaries during asan builds." FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_ASAN
"-fsanitize=address" CACHE STRING "Flags used by the shared libraries linker during asan builds." FORCE)
mark_as_advanced(CMAKE_CXX_FLAGS_ASAN CMAKE_C_FLAGS_ASAN CMAKE_EXE_LINKER_FLAGS_ASAN CMAKE_SHARED_LINKER_FLAGS_ASAN)
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Asan." FORCE)
# Built type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build" FORCE)
endif()
message("Build type: ${CMAKE_BUILD_TYPE} (change with -DCMAKE_BUILD_TYPE=<Debug|Release|RelWithDebInfo|MinSizeRel|Asan>)")
message("Custom configuration flags can be passed with -DCUSTOM_FLAGS=\"-D<name1>=value1 -D<name2>=value2 ...\"")
# Store output in an easy location
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
if (POLICY CMP0094) # https://cmake.org/cmake/help/latest/policy/CMP0094.html
cmake_policy(SET CMP0094 NEW) # FindPython should return the first matching Python
endif ()
# needed on GitHub Actions CI: actions/setup-python does not touch registry/frameworks on Windows/macOS
# this mirrors PythonInterp behavior which did not consult registry/frameworks first
if (NOT DEFINED Python_FIND_REGISTRY)
set(Python_FIND_REGISTRY "LAST")
endif ()
if (NOT DEFINED Python_FIND_FRAMEWORK)
set(Python_FIND_FRAMEWORK "LAST")
endif ()
# System flags
# ============
# Register our package finders
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
# Multithreading is used (both client and server applications)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Palanteer
# ==========
# Build libpalanteer
add_subdirectory(c++)
# Build the viewer
if (PALANTEER_BUILD_VIEWER)
add_subdirectory(server/viewer)
endif()
# Build the C++ example
if (PALANTEER_BUILD_CPP_EXAMPLE)
add_subdirectory(c++/testprogram)
endif()
# Build the python instrumentation package
if (PALANTEER_BUILD_PYTHON_INSTRUMENTATION)
add_subdirectory(python)
endif()
# Build the python scripting package
if (PALANTEER_BUILD_SERVER_SCRIPTING)
add_subdirectory(server/scripting)
endif()