-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
106 lines (88 loc) · 4.34 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
cmake_minimum_required(VERSION 3.22)
file(STRINGS "version.txt" MORPHEUS_VERSION)
project(Morpheus
VERSION ${MORPHEUS_VERSION}
DESCRIPTION "A high performance focused game engine using object oriented techniques based in the latest C++"
LANGUAGES C CXX
)
set(CMAKE_POLICY_DEFAULT_CMP0076 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0077 NEW)
cmake_policy(SET CMP0127 NEW)
cmake_policy(SET CMP0135 NEW)
cmake_policy(SET CMP0140 NEW)
#------------------------------------------------------------------------------------------------------------------------------------------
# Standard CMake Includes
include(CTest)
include(FetchContent)
include(GNUInstallDirs)
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
option(MORPHEUS_RENDER_SYSTEM_DIRECT_X12 "Build with support for the Dirext X 12 render system" ON)
option(MORPHEUS_RENDER_SYSTEM_METAL "Build with support for the Metal render system" ON)
option(MORPHEUS_RENDER_SYSTEM_OPENGL "Build with support for the Open GL render system" ON)
option(MORPHEUS_RENDER_SYSTEM_VULKAN "Build with support for the Vulkan render system" ON)
cmake_dependent_option(MORPHEUS_LINK_WITH_MOLD "Enable the mold linker" ON "LINUX OR APPLE" OFF)
cmake_dependent_option(MORPHEUS_CODE_COVERAGE "Enable code coverage" ON "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\"" OFF)
cmake_dependent_option(MORPHEUS_INCLUDE_NATVIS "Enable inclusion of a natvis files for debugging" ON "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\"" OFF)
set(BUILD_SHARED_LIBS NO)
# Include necessary submodules
list(APPEND CMAKE_MODULE_PATH
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/modules
)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/generators")
#------------------------------------------------------------------------------------------------------------------------------------------
# Custom CMake Includes
include(coverage)
include(compiler)
include(conformance)
include(documentation)
include(IDESettings)
include(linker)
include(morpheus_add_executable)
include(morpheus_add_library)
include(morpheus_add_testing_library)
include(morpheus_add_tests)
include(sanitisers)
include(third_party)
enable_testing()
#------------------------------------------------------------------------------------------------------------------------------------------
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for header files")
# Build the RPath relative to the executable locations (i.e. from the bin directory, up back to the install root and in to the lib folder.
file(RELATIVE_PATH MORPHEUS_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR} ${CMAKE_INSTALL_PREFIX})
if (APPLE)
set(MORPHEUS_INSTALL_RPATH "@executable_path/${MORPHEUS_INSTALL_RPATH}")
else()
set(MORPHEUS_INSTALL_RPATH "$ORIGIN/${MORPHEUS_INSTALL_RPATH}")
endif()
file(TO_NATIVE_PATH "${MORPHEUS_INSTALL_RPATH}/${INSTALL_LIBDIR}" MORPHEUS_INSTALL_RPATH )
set(CMAKE_INSTALL_RPATH ${MORPHEUS_INSTALL_RPATH})
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTI_CONFIG)
set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)
set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/$<CONFIG>)
file(RELATIVE_PATH MORPHEUS_RELATIVE_BUILD_RPATH ${RUNTIME_OUTPUT_DIRECTORY} ${LIBRARY_OUTPUT_DIRECTORY})
if (APPLE)
set(MORPHEUS_BUILD_RPATH "@executable_path/${MORPHEUS_RELATIVE_BUILD_RPATH}")
else()
set(MORPHEUS_BUILD_RPATH "$ORIGIN/${MORPHEUS_RELATIVE_BUILD_RPATH}")
endif()
set(CMAKE_BUILD_RPATH ${MORPHEUS_BUILD_RPATH})
set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
endif()
#------------------------------------------------------------------------------------------------------------------------------------------
add_subdirectory(libraries)
add_subdirectory(examples)
if (ENABLE_CODE_COVERAGE)
enable_code_coverage()
endif()