-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
73 lines (51 loc) · 2.12 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.19)
PROJECT("CMake Conan Template")
# Prevent concurrent CMake runs.
FILE(LOCK ${CMAKE_SOURCE_DIR}/cmake.lock)
# Get compiler name and build type.
STRING(TOLOWER ${CMAKE_CXX_COMPILER_ID} CXX_COMPILER_ID_LOWER)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_LOWER)
# RelWithDebInfo -> FastDebug
IF (${BUILD_TYPE_LOWER} STREQUAL "relwithdebinfo")
SET(BUILD_TYPE_LOWER "fastdebug")
ENDIF()
# Command line options.
SET(SYMLINK_ASSETS ON CACHE BOOL "Generate symlinks for the assets folder rather than copying it.")
SET(ENABLE_TESTING ON CACHE BOOL "Generate test targets.")
SET(PROFILE_NAME "${CXX_COMPILER_ID_LOWER}-${BUILD_TYPE_LOWER}" CACHE STRING "Name of the current CMake profile. Will be used as the folder name for build artifacts.")
SET(COMPILER_PROFILE ON CACHE BOOL "Use a preconfigured profile with compiler-specific settings for e.g. warnings.")
SET(WARNINGS_ARE_ERRORS ON CACHE BOOL "Treat all warnings as errors.")
# Change to require a specific C++ version.
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
# Export all symbols on Windows.
# TODO: Replace this with SymbolGenerator later!
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Allow loading of scripts from cmake folder.
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Store builds in out folder.
SET(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/out")
# Allow including from the root directory.
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
# Enable Testing
IF (ENABLE_TESTING)
INCLUDE(CTest)
ENABLE_TESTING()
ENDIF()
# Install Dependencies
INCLUDE(install_dependencies)
INSTALL_GIT_DEPENDENCIES()
INSTALL_CONAN_DEPENDENCIES()
# Enable compiler-specific compatibility flags and warnings.
IF (COMPILER_PROFILE)
INCLUDE(compiler_config)
CONFIGURE_COMPILER()
ENDIF()
# Add subprojects.
FILE(GLOB SUBFOLDERS CONFIGURE_DEPENDS LIST_DIRECTORIES ON "*")
FOREACH (SUBFOLDER IN ITEMS ${SUBFOLDERS})
IF (IS_DIRECTORY "${SUBFOLDER}" AND EXISTS "${SUBFOLDER}/CMakeLists.txt")
MESSAGE(STATUS "Found Target Subdirectory ${SUBFOLDER}.")
ADD_SUBDIRECTORY(${SUBFOLDER})
ENDIF()
ENDFOREACH()