-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (105 loc) · 3.54 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include(cmake/HunterGate.cmake)
#HunterGate(
# URL "https://github.com/cpp-pm/hunter/archive/v0.24.7.tar.gz"
# SHA1 "908ddcb223f25fa155315baae64ce0ab48a38bf7"
#)
option(AMS_BUILD_TESTS "Build tests" OFF)
option(AMS_ENABLE_MODULES "c++20+ Module Library" OFF)
option(AMS_EXCEPTIONS "Enable exceptions" ON)
option(AMS_NEGATIVE_INDEXING "Enable negative indexing for ams container types" OFF)
option(AMS_ENABLE_BOOST "Enable Boost" OFF)
cmake_minimum_required(VERSION 3.16)
project(ams
LANGUAGES CXX
VERSION 0.1
)
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
if(CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "C++20 or greater is required")
endif()
include(CMakePackageConfigHelpers)
include(CMakeFindDependencyMacro)
include(GenerateExportHeader)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(cmake/Utils.cmake)
include(cmake/ModulePlatformCheck.cmake)
if (AMS_BUILD_TESTS)
set(CMAKE_CXX_EXTENSIONS OFF)
enable_testing()
endif()
if (AMS_EXCEPTIONS)
add_compile_definitions(AMS_EXCEPTIONS)
endif()
check_compiler_can_compile_modules(_modules_supported)
if (AMS_ENABLE_MODULES AND _modules_supported)
# enable cmake experimental features
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "3c375311-a3c9-4396-a187-3227ef642046")
if(GNU)
include(gcc_modules.cmake)
endif()
message(STATUS "${PROJECT_NAME}: C++ Modules enabled")
if (CMAKE_CXX_STANDARD GREATER_EQUAL 23)
add_compile_definitions(AMS_MODULES_STD)
endif()
endif()
if(AMS_ENABLE_MODULES)
add_compile_definitions(AMS_MODULES)
endif()
# Discover system and platform information
set(AMS_OS "Unknown")
set(AMS_OS_VERSION 0)
set(AMS_COMPILER "Unknown")
set(AMS_COMPILER_VERSION 0)
set(AMS_0S_ARCH "Unknown")
set(AMS_TARGET_ARCH "Unknown")
set(AMS_CPU_CORES 1)
set(AMS_LIBRARY_VERSION ${PROJECT_VERSION})
system_discovery(UPPERCASE
OS_NAME AMS_OS
OS_VERSION AMS_OS_VERSION
COMPILER AMS_COMPILER
COMPILER_VERSION AMS_COMPILER_VERSION
OS_ARCH AMS_0S_ARCH
TARGET_ARCH AMS_TARGET_ARCH
CPU_CORES AMS_CPU_CORES
)
# convert AMS_CPU_CORES to number
string(REGEX REPLACE "[^0-9]" "" AMS_CPU_CORES "${AMS_CPU_CORES}")
message("Configuration:
OS: ${AMS_OS} ${AMS_OS_VERSION}
Generator: ${CMAKE_GENERATOR}
Compiler: ${AMS_COMPILER} ${AMS_COMPILER_VERSION}
System Architecture: ${AMS_0S_ARCH}
Target Architecture: ${AMS_TARGET_ARCH}
CPU Cores: ${AMS_CPU_CORES}
Library Version: ${AMS_LIBRARY_VERSION}
C++ Standard: ${CMAKE_CXX_STANDARD}"
)
# control where the static and shared libraries are built so that on windows
# we don't need to tinker with the path to run the executable
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
add_subdirectory(ams_core)
add_subdirectory(ams_spatial)
add_subdirectory(ams_game)
if (AMS_BUILD_TESTS)
add_subdirectory(test)
endif()
add_subdirectory(util)
#### INSTALLATION ####
configure_package_config_file(cmake/${PROJECT_NAME}-config.cmake.in
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")