-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
232 lines (188 loc) · 11.9 KB
/
CMakeLists.txt
File metadata and controls
232 lines (188 loc) · 11.9 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
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
set(MIN_VERSION 3.22)
cmake_minimum_required(VERSION ${MIN_VERSION})
set(PROJECT_NAME LifeEngineExtended)
project(${PROJECT_NAME})
option(WIN_COMPILATION "If compiling for windows" OFF)
option(NO_RECORDER "If you don't want recorder" ON)
#set(NO_RECORDER ON)
#option(Qt6_DIR "Set path to qt6 binary" "/home/spaceeye/qt6/qt6-build/lib/cmake/Qt6")
option(USE_MARCH_NATIVE "Use -march=native option" OFF)
#set(Qt6_DIR "/home/spaceeye/qt6/qt6-build/qtbase/lib/cmake/Qt6")
#set(CMAKE_PREFIX_PATH "/home/spaceeye/qt6/qt6-build/qtbase/lib/cmake")
option(BOOST_ROOT "If on windows, set path to boost root directory" "C:\\libs\\boost\\boost_1_79_0")
option(BOOST_LIBRARYDIR "If on windows, set path to compiled libraries, like 'boost\\stage\\libs'" "C:\\libs\\boost\\boost_1_79_0\\stage\\libs")
set(NO_RECORDER ON)
set(TESTING 0)
#set(DEBUG 1)
#set(INLINE 1)
#set(SANITIZE 1)
set(DEBUG 0)
set(INLINE 0)
set(SANITIZE 0)
# -ffast-math -funroll-loops -ftree-parallelize-loops=4
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
include_directories("Source")
if(USE_MARCH_NATIVE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
#https://developer.nvidia.com/cuda-gpus
#set(CMAKE_CUDA_ARCHITECTURES 35 37 50 52 53 60 61 62 70 72 75 80 86)
set(CMAKE_CUDA_ARCHITECTURES 61)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -03")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -cudart=shared")
if(DEBUG)
add_compile_definitions(__DEBUG__)
endif ()
if (INLINE OR DEBUG)
#for perf
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-inline-functions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-inline-functions")
endif ()
if(SANITIZE OR DEBUG)
#https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_LINK_DEF_FILE_FLAG "${CMAKE_LINK_DEF_FILE_FLAG} -fsanitize=address")
endif()
set(CUDA_HEADERS Source/SimulationEngine/SimulationEngineModes/del/SimulationEngineCuda.cuh Source/Stuff/cuda/cuda_image_creator.cuh Source/Stuff/cuda/get_device_count.cuh)
set(CUDA_SOURCES Source/SimulationEngine/SimulationEngineModes/del/SimulationEngineCuda.cu Source/Stuff/cuda/cuda_image_creator.cu Source/Stuff/cuda/get_device_count.cu)
if(NOT WIN_COMPILATION)
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.8/bin/nvcc")
set(CMAKE_NVCC_EXECUTABLE "/usr/local/cuda-11.8/bin")
endif()
if (NOT WIN_COMPILATION)
find_package(CUDAToolkit)
endif()
if (WIN_COMPILATION)
set(Boost_DEBUG 0)
set(Boost_ARCHITECTURE -x64)
set(Boost_LIB_PREFIX lib)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_DYNAMIC_LIBS ON)
set(Boost_USE_RELEASE_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME ON)
endif()
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
# Charts
REQUIRED)
find_package(Boost COMPONENTS random REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if (NO_RECORDER)
add_compile_definitions(__NO_RECORDER__)
endif()
if (NOT NO_RECORDER)
find_package(PkgConfig REQUIRED)
if(NOT WIN_COMPILATION)
find_package(NUMA REQUIRED)
else()
set(NUMA_LIBRARY "")
endif()
find_package(FFmpeg REQUIRED)
find_package(GnuTLS REQUIRED)
find_package(RSVG REQUIRED)
find_package(Threads REQUIRED)
find_package(x264 REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
find_package(ZLIB REQUIRED)
include_directories(${FFMPEG_INCLUDE_DIRS})
include_directories(Source/Stuff/external/moviemaker/include)
include_directories(${GNUTLS_INCLUDR_DIRS})
include_directories(${GTK3_INCLUDE_DIRS})
include_directories(${RSVG_INCLUDE_DIR})
include_directories(${SWSCALE_INCLUDE_DIRS})
include_directories(${X264_INCLUDE_DIR})
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lswresample -lm -lz")
set(ADDITIONAL_PROJECT_FILES Source/Stuff/external/moviemaker/include/movie.h Source/Stuff/external/moviemaker/src/reader.cpp Source/Stuff/external/moviemaker/src/writer.cpp Source/UIWindows/Recorder/RecorderWindowUI.h Source/UIWindows/Recorder/Recorder.cpp Source/UIWindows/Recorder/Recorder.h Source/UIWindows/Recorder/RecorderSlots.cpp)
endif()
if(CUDAToolkit_FOUND)
enable_language(CUDA)
set(CUDA_FILES ${CUDA_SOURCES} ${CUDA_HEADERS} Source/WorldRecorder/RecordingReconstructorCUDA.cu Source/WorldRecorder/RecordingReconstructorCUDA.cuh)
endif()
set(PROJECT_FILES Source/SimulationEngine/SimulationEngine.cpp Source/SimulationEngine/SimulationEngine.h Source/UIWindows/MainWindow/MainWindow.cpp Source/UIWindows/MainWindow/MainWindow.h Source/Organism/Organism.cpp Source/Organism/Organism.h Source/GridStuff/BaseGridBlock.h Source/Containers/ColorContainer.h Source/Organism/Anatomy/Anatomy.cpp Source/Organism/Anatomy/Anatomy.h Source/Stuff/enums/BlockTypes.hpp Source/Containers/SimulationParameters.h Source/Containers/EngineControlParametersContainer.h Source/Containers/OrganismBlockParameters.h Source/Stuff/Linspace.h Source/UIWindows/MainWindow/WindowUI.h Source/UIWindows/MainWindow/MainWindowSlots.cpp Source/UIWindows/MainWindow/MainWindowEvents.cpp Source/Organism/Brain/Brain.cpp Source/Organism/Brain/Brain.h Source/SimulationEngine/SimulationEngineModes/SimulationEngineSingleThread.cpp Source/Stuff/structs/Actions.h Source/PRNGS/xorshf96.h Source/Stuff/ImageStuff/textures.h Source/Organism/Brain/Observation.h Source/GridStuff/STGridWorld.h Source/UIWindows/MainWindow/MainWindowDataSavingStuff.cpp Source/UIWindows/Statistics/Statistics.h Source/UIWindows/OrganismEditor/OrganismEditor.h Source/UIWindows/OrganismEditor/OrganismEditor.cpp Source/UIWindows/OrganismEditor/OrganismEditorSlots.cpp Source/Stuff/UIMisc.h Source/Stuff/UIMisc.cpp Source/Stuff/external/PerlinNoise.hpp Source/UIWindows/OrganismEditor/OrganismEditorDataSaving.cpp Source/UIWindows/InfoWindow/InfoWindowUI.h Source/UIWindows/InfoWindow/InfoWindow.cpp Source/UIWindows/InfoWindow/InfoWindow.h Source/Stuff/ImageStuff/ImageCreation.h Source/Stuff/ImageStuff/ImageCreation.cpp Source/Stuff/DataSavingFunctions.h Source/Stuff/DataSavingFunctions.cpp Source/UIWindows/WorldEvents/WorldEvents.cpp Source/UIWindows/WorldEvents/WorldEvents.h Source/UIWindows/WorldEvents/EventNodes.h Source/UIWindows/WorldEvents/EventNodesWidgets/ChangeValueEventNodeWidget.cpp Source/UIWindows/WorldEvents/EventNodesWidgets/ChangeValueEventNodeWidget.h Source/UIWindows/WorldEvents/EventNodesWidgets/ConditionalEventNodeWidget.cpp Source/UIWindows/WorldEvents/EventNodesWidgets/ConditionalEventNodeWidget.h Source/UIWindows/WorldEvents/EventNodesWidgets/ConditionalEventNodeWidgetSlots.cpp Source/UIWindows/WorldEvents/Misc/ParametersList.h Source/UIWindows/WorldEvents/Misc/ParametersList.cpp Source/UIWindows/WorldEvents/EventNodesWidgets/ChangeValueEventNodeWidgetSlots.cpp Source/Containers/OrganismInfoContainer.h Source/UIWindows/WorldEvents/WorldEventsController.h Source/UIWindows/WorldEvents/WorldEventsController.cpp Source/UIWindows/WorldEvents/WorldEventsController.h Source/UIWindows/WorldEvents/WorldEventsSlots.cpp Source/UIWindows/Benchmark/Benchmarks.cpp Source/UIWindows/Benchmark/Benchmarks.h Source/UIWindows/Benchmark/BenchmarkSlots.cpp Source/SimulationEngine/OrganismsController.cpp Source/SimulationEngine/OrganismsController.h Source/Organism/OCC/OrganismConstructionCode.cpp Source/Organism/OCC/OrganismConstructionCode.h Source/Organism/Anatomy/SimpleAnatomyMutationLogic.h Source/Containers/OrganismConstructionCodeParameters.h Source/Containers/OCCLogicContainer.h Source/UIWindows/OCCParameters/OCCParameters.cpp Source/UIWindows/OCCParameters/OCCParameters.h Source/UIWindows/OCCParameters/OCCParametersSlots.cpp Source/UIWindows/OrganismEditor/OCCTranspiler/OCCTranspiler.cpp Source/UIWindows/OrganismEditor/OCCTranspiler/OCCTranspiler.h Source/WorldRecorder/WorldRecorder.cpp Source/WorldRecorder/WorldRecorder.h Source/WorldRecorder/RecordingReconstructor.cpp Source/WorldRecorder/RecordingReconstructor.h Source/Stuff/structs/ConstMap.h Source/Organism/Anatomy/AnatomyContainers.h Source/UIWindows/Statistics/Statistics.cpp Source/Organism/Anatomy/AnatomyCountersMap.h Source/Stuff/external/ArrayView.h Source/Stuff/iterate_between_two_points.h Source/UIWindows/MainWindow/MainWindowImageCreation.cpp)
add_executable(${PROJECT_NAME} main.cpp ${PROJECT_FILES} ${CUDA_FILES} ${ADDITIONAL_PROJECT_FILES})
if(CUDAToolkit_FOUND)
message(STATUS "Found CUDAToolkit version ${CUDAToolkit_VERSION}")
add_compile_definitions(__CUDA_USED__)
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
else()
message(STATUS "No CUDAToolkit found.")
endif()
if(CUDAToolkit_FOUND)
#should be set for each qt6 component for some reason
#https://gitlab.kitware.com/cmake/cmake/-/issues/16915
get_property( core_options TARGET Qt6::Core PROPERTY INTERFACE_COMPILE_OPTIONS )
string( REPLACE "-fPIC" "" new_core_options "${core_options}" )
set_property( TARGET Qt6::Core PROPERTY INTERFACE_COMPILE_OPTIONS ${new_core_options} )
set_property( TARGET Qt6::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON" )
get_property( core_options TARGET Qt6::Gui PROPERTY INTERFACE_COMPILE_OPTIONS )
string( REPLACE "-fPIC" "" new_core_options "${core_options}" )
set_property( TARGET Qt6::Gui PROPERTY INTERFACE_COMPILE_OPTIONS ${new_core_options} )
set_property( TARGET Qt6::Gui PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON" )
get_property( core_options TARGET Qt6::Widgets PROPERTY INTERFACE_COMPILE_OPTIONS )
string( REPLACE "-fPIC" "" new_core_options "${core_options}" )
set_property( TARGET Qt6::Widgets PROPERTY INTERFACE_COMPILE_OPTIONS ${new_core_options} )
set_property( TARGET Qt6::Widgets PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON" )
set( CMAKE_CXX_COMPILE_OPTIONS_PIE "-fPIC" )
endif()
target_link_libraries(${PROJECT_NAME}
Qt6::Core
Qt6::Gui
Qt6::Widgets
# Qt6::Charts
)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif()
if (NOT NO_RECORDER)
if (WIN_COMPILATION)
target_link_libraries(${PROJECT_NAME} ${FFMPEG_LIBRARIES} ${GTK3_LIBRARIES} ${SWSCALE_LIBRARIES} ${RSVG_LIBRARY} ${NUMA_LIBRARY} ZLIB::ZLIB)
else()
target_link_libraries(${PROJECT_NAME} ${FFMPEG_LIBRARIES} ${GTK3_LIBRARIES} ${X264_LIBRARIES} ${SWSCALE_LIBRARIES} ${RSVG_LIBRARY} ${NUMA_LIBRARY} ZLIB::ZLIB)
endif()
endif()
if (TESTING)
find_package(Catch2 3 REQUIRED)
include(CTest)
include(Catch)
set(TESTS Tests/Organism/Organism.cpp)
foreach(item ${TESTS})
# regex is a devil's toy
# extracting file name without fluff
string(REGEX MATCH "([^\\/]*$)" name_item "${item}")
string(REPLACE ".cpp" "" name_item "${name_item}")
add_executable(${name_item} ${item} ${PROJECT_FILES} ${CUDA_FILES} ${ADDITIONAL_PROJECT_FILES})
target_link_libraries(${name_item} Catch2::Catch2WithMain)
catch_discover_tests(${name_item})
if (CUDAToolkit_FOUND)
set_target_properties(${name_item} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif()
target_link_libraries(${name_item}
Qt6::Core
Qt6::Gui
Qt6::Widgets
# Qt6::Charts
)
if (Boost_FOUND)
target_link_libraries(${name_item} ${Boost_LIBRARIES})
endif()
if (NOT NO_RECORDER)
if (WIN_COMPILATION)
target_link_libraries(${name_item} ${FFMPEG_LIBRARIES} ${GTK3_LIBRARIES} ${SWSCALE_LIBRARIES} ${RSVG_LIBRARY} ${NUMA_LIBRARY} ZLIB::ZLIB)
else()
target_link_libraries(${name_item} ${FFMPEG_LIBRARIES} ${GTK3_LIBRARIES} ${X264_LIBRARIES} ${SWSCALE_LIBRARIES} ${RSVG_LIBRARY} ${NUMA_LIBRARY} ZLIB::ZLIB)
endif()
endif()
endforeach()
endif()