-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
150 lines (114 loc) · 4.28 KB
/
CMakeLists.txt
File metadata and controls
150 lines (114 loc) · 4.28 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
cmake_minimum_required(VERSION 4.0 FATAL_ERROR)
# Enable std module support for MSVC - MUST be before project()
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
set(CMAKE_CXX_MODULE_STD ON)
#Set CMake tools location
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/tool/CMake)
##############################################
#Project
project(SoulEngine
VERSION 0.0.1
DESCRIPTION "Real-time simulation and rendering engine."
LANGUAGES CXX
)
##############################################
#Dependencies
find_package(honesty REQUIRED)
find_package(synodic-template-library REQUIRED)
find_package(cppaste REQUIRED)
find_package(SDL3 REQUIRED)
##############################################
#Options
option(BUILD_TESTING "Build the tests verifying functionality" ${PROJECT_IS_TOP_LEVEL})
option(BUILD_EXAMPLES "Build example projects" ${PROJECT_IS_TOP_LEVEL})
option(BUILD_SHARED_LIBS "Build shared library" OFF)#TODO: Implement use of this option
option(BUILD_CPU_COMPUTE "Build the OpenCL Compute backend" ON)#TODO: Implement use of this option
option(BUILD_CUDA_COMPUTE "Build the CUDA Compute backend" ${CUDA_FOUND})#TODO: Implement use of this option
option(BUILD_OPENCL_COMPUTE "Build the OpenCL Compute backend" ${OpenCL_FOUND})#TODO: Implement use of this option
option(BUILD_VULKAN_RASTER "Build the Vulkan Raster backend" OFF)#TODO: Implement use of this option
option(BUILD_FIBER_SCHEDULER "Build the Fiber Scheduler backend" OFF)
option(BUILD_ENTITY_GRAPH "Build the Entity Graph backend" ON)
##############################################
#Project Target
add_library(soul-engine)
add_library(synodic::soul-engine ALIAS soul-engine)
set_target_properties(soul-engine
PROPERTIES
LINKER_LANGUAGE CXX
CXX_EXTENSIONS OFF
CUDA_SEPARABLE_COMPILATION ON
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
USE_FOLDERS ON
)
target_compile_features(soul-engine PUBLIC cxx_std_23)
target_link_libraries(soul-engine
PUBLIC
synodic::cppaste
PRIVATE
synodic::honesty
synodic::synodic-template-library
SDL3::SDL3
)
# Create file set for C++20 modules
target_sources(soul-engine
PUBLIC
FILE_SET CXX_MODULES FILES
)
##############################################
#Sources
add_subdirectory(
src
)
# NOTE: For IDE setups that do not use CMake directly, we setup all IDE directories to mimic
# their system directory structure. See https://gitlab.kitware.com/cmake/cmake/-/issues/25992
file(GLOB_RECURSE file_list ${CMAKE_CURRENT_SOURCE_DIR}/src/*)
# Must be called from the target definition directory. Only matched against 'target_sources'
# files (No nested CMakeList.txt, docs, etc).
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src FILES ${file_list})
##############################################
#Sub-projects
if(BUILD_TESTING AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/tests)
# Do not include CTest because it adds targets and integrations we do not want to support
enable_testing()
add_subdirectory(tests)
endif()
if(BUILD_EXAMPLES AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples)
add_subdirectory(examples)
endif()
# Installation
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Generate package config files
write_basic_package_version_file(
soul-engineConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
tool/cmake/soul-engineConfig.cmake.in
soul-engineConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soul-engine
)
install(TARGETS soul-engine
EXPORT soul-engineTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soul-engine
)
# Create empty include directory to satisfy CMake's exported target requirements
# (module-only library with no headers, but CMake expects the directory to exist)
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Export and package configuration
install(EXPORT soul-engineTargets
FILE soul-engineTargets.cmake
NAMESPACE synodic::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soul-engine
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/soul-engineConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/soul-engineConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/soul-engine
)