-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
111 lines (93 loc) · 3.99 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
cmake_minimum_required(VERSION 3.22)
project(FIRESTARTER)
include(cmake/GitSubmoduleUpdate.cmake)
# set FIRESTARTER version
find_package(Git)
if(Git_FOUND)
_is_git(${CMAKE_CURRENT_SOURCE_DIR} IN_GIT)
endif()
SET (_FIRESTARTER_VERSION_TEMPERED OFF)
SET(_FIRESTARTER_VERSION_STRING "default" CACHE STRING "_FIRESTARTER_VERSION_STRING should not be used if you do not know what to do.")
if("${_FIRESTARTER_VERSION_STRING}" STREQUAL "default")
if (IN_GIT)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _FIRESTARTER_VERSION_STRING
)
string(STRIP ${_FIRESTARTER_VERSION_STRING} _FIRESTARTER_VERSION_STRING)
else()
message(AUTHOR_WARNING "Cannot detect FIRESTARTER version.")
SET(_FIRESTARTER_VERSION_STRING "unknown")
endif()
else()
SET (_FIRESTARTER_VERSION_TEMPERED ON)
endif()
add_compile_definitions(_FIRESTARTER_VERSION_STRING="${_FIRESTARTER_VERSION_STRING}")
SET(_FIRESTARTER_BUILD_YEAR "default" CACHE STRING "_FIRESTARTER_BUILD_YEAR should not be used if you do not know what to do.")
if("${_FIRESTARTER_BUILD_YEAR}" STREQUAL "default")
if(IN_GIT)
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE _FIRESTARTER_BUILD_YEAR
)
string(SUBSTRING ${_FIRESTARTER_BUILD_YEAR} 0 4 _FIRESTARTER_BUILD_YEAR)
else()
message(AUTHOR_WARNING "Cannot detect FIRESTARTER build year.")
SET(_FIRESTARTER_BUILD_YEAR "unknown")
endif()
else()
SET (_FIRESTARTER_VERSION_TEMPERED ON)
endif()
add_compile_definitions(_FIRESTARTER_BUILD_YEAR="${_FIRESTARTER_BUILD_YEAR}")
if(_FIRESTARTER_VERSION_TEMPERED)
add_compile_definitions(_FIRESTARTER_VERSION_TEMPERED)
endif()
# init git submodules
include(cmake/GitSubmoduleUpdate.cmake)
git_submodule_update()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2 -fdata-sections -ffunction-sections")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
else()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
endif()
# enable debug features on linux
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(FIRESTARTER_DEBUG_FEATURES "Enable debug features" ON)
if (FIRESTARTER_DEBUG_FEATURES)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_DEBUG_FEATURES")
endif()
endif()
set(FIRESTARTER_BUILD_TYPE "FIRESTARTER" CACHE STRING "FIRESTARTER_BUILD_TYPE can be any of FIRESTARTER, FIRESTARTER_CUDA, FIRESTARTER_ONEAPI, or FIRESTARTER_HIP.")
set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTARTER_CUDA FIRESTARTER_ONEAPI)
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA or OneAPI enabled." ON)
endif()
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_CUDA")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_ONEAPI")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_HIP")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
endif()
option(FIRESTARTER_THREAD_AFFINITY "Enable FIRESTARTER to set affinity to hardware threads." ON)
if(NOT DEFINED ASMJIT_STATIC)
set(ASMJIT_STATIC TRUE)
endif()
add_subdirectory(lib/asmjit)
add_subdirectory(lib/nitro)
include_directories(include)
include_directories(lib/cxxopts/include)
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install OFF CACHE INTERNAL "")
add_subdirectory(lib/json)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(cmake/InstallHwloc.cmake)
add_subdirectory(src)