-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
71 lines (54 loc) · 1.99 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
cmake_minimum_required(VERSION 3.26)
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
message(STATUS "TOOLCHAIN: ${CMAKE_TOOLCHAIN_FILE}")
project(SupernovaEngine)
if(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") # .lib, .a
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") # .dll, .so
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # .exe
set(Boost_NO_WARN_NEW_VERSIONS 1)
if(${CMAKE_VERSION} VERSION_LESS "3.25.0")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX YES)
endif()
endif()
if(WIN32)
message(STATUS "Build for WIN32")
add_definitions(-DNOMINMAX)
elseif(LINUX)
message(STATUS "Build for Linux")
endif()
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
set(CMAKE_CXX_FLAGS_DISTRIBUTION "/GS- /Gy /O2 /Oi /Ot")
set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
function(SET_WARNING_LEVEL)
if(MSVC)
target_compile_options(${ARGV0} PRIVATE /W4)
else()
target_compile_options(${ARGV0} PRIVATE -Wall -Wextra -Wpedantic -Wno-missing-field-initializers)
endif()
endfunction()
function(SET_DEBUGGER_WORKING_DIRECTORY)
set_target_properties(${ARGV0} PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/")
endfunction()
add_subdirectory(extern)
include(cmake/AddResources.cmake)
include(cmake/GroupProjectFiles.cmake)
add_subdirectory(modules)
add_subdirectory(tools)
add_subdirectory(examples)