-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathCMakeLists.txt
77 lines (59 loc) · 3.06 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
cmake_minimum_required (VERSION 3.13.0)
project (REGoth)
option(REGOTH_USE_SYSTEM_BSF "Whether to use the system installed bsf via find_package." OFF)
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR "REGoth does not support to be built on architectures other than 64 bit.")
endif()
###############################################################################
# Configuration #
###############################################################################
# Make sure to use the C++14 standard
set(CMAKE_CXX_STANDARD 14)
# Set up binary output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Add compiler flags required by bsf (See: https://www.bsframework.io/docs/build.html)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-fno-rtti)
# So that REGoth-Symbols will show up in the bs:f-crash handler
add_link_options(-rdynamic)
endif()
###############################################################################
# Add external libraries #
###############################################################################
# Let CMake know where to find the Findbsf.cmake file
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if (REGOTH_USE_SYSTEM_BSF)
find_package(bsf REQUIRED)
else()
# Need to reset RPATH-settings to default again because bsf has messed with them.
# See https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# Enable exceptions in bsf as some dependencies (like cxxopts) rely on them.
set(BSF_ENABLE_EXCEPTIONS ON CACHE BOOL "" FORCE)
add_subdirectory(lib/bsf)
endif()
# BsZenLib will try to find bs:f for itself as well. Since we already have a bsf-target, skip that.
set(BSZENLIB_SKIP_FIND_BSF ON CACHE BOOL "" FORCE)
add_subdirectory(lib/BsZenLib)
# cxxopts as library to parse command line options.
set(CXXOPTS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # Disable unnecessary targets for examples.
set(CXXOPTS_BUILD_TESTS OFF CACHE BOOL "" FORCE) # Disable unnecessary targets for unit tests.
add_definitions(-DCXXOPTS_NO_RTTI) # Disable RTTI dependent instructions.
add_subdirectory(lib/cxxopts)
# Assertions.
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
add_definitions(-DREGOTH_ENABLE_ASSERTIONS)
endif()
###############################################################################
# Add Samples, etc #
###############################################################################
add_subdirectory(docs-source)
add_subdirectory(src)