-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
108 lines (89 loc) · 2.85 KB
/
CMakeLists.txt
File metadata and controls
108 lines (89 loc) · 2.85 KB
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
cmake_minimum_required(VERSION 3.28)
# option determining static linking (on if is monolithic is on)
option(IS_MONOLITHIC "Is Monolithic" OFF)
set(VCPKG_CRT_LINKAGE "static" CACHE STRING "")
set(VCPKG_LIBRARY_LINKAGE "static" CACHE STRING "")
if (NOT IS_MONOLITHIC)
#set(VCPKG_CRT_LINKAGE "dynamic" CACHE STRING "")
endif ()
# Additional package-specific settings (optional)
set(GLAD_PROFILE "core" CACHE STRING "")
# MINGW is always static triplet
if (MINGW OR VCPKG_CMAKE_SYSTEM STREQUAL MINGW)
set(VCPKG_TARGET_TRIPLET "x64-mingw-static" CACHE STRING "")
set(VCPKG_HOST_TRIPLET "x64-mingw-static" CACHE STRING "")
endif()
if (MSVC OR VCPKG_CMAKE_SYSTEM STREQUAL MSVC)
if (IS_MONOLITHIC)
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "")
set(VCPKG_HOST_TRIPLET "x64-windows-static" CACHE STRING "")
else ()
set(VCPKG_TARGET_TRIPLET "x64-windows-static-md" CACHE STRING "")
set(VCPKG_HOST_TRIPLET "x64-windows-static-md" CACHE STRING "")
endif ()
if (IS_MONOLITHIC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else ()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif ()
add_compile_options(
/utf-8
/wd4251
/EHsc
)
endif()
# vcpkg
if (DEFINED ENV{VCPKG_ROOT})
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
else ()
message(STATUS "Downloading vcpkg")
include(FetchContent)
FetchContent_Declare(vcpkg
GIT_REPOSITORY https://github.com/microsoft/vcpkg/
)
FetchContent_MakeAvailable(vcpkg)
set(VCPKG_ROOT ${vcpkg_SOURCE_DIR})
endif()
message(STATUS "Using VCPKG_ROOT: ${VCPKG_ROOT}")
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "vcpkg toolchain file")
#--------
# project
# -------
project(moon CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG ME_DEBUG)
else ()
add_compile_definitions(NDEBUG ME_NDEBUG)
endif ()
# platform specific stuff
if (WIN32 OR MINGW)
set(PLATFORM_DEFINITIONS ME_WINDOWS)
elseif (APPLE)
set(PLATFORM_DEFINITIONS ME_OSX)
elseif (UNIX AND NOT APPLE)
set(PLATFORM_DEFINITIONS ME_LINUX)
endif ()
add_compile_definitions(${PLATFORM_DEFINITIONS})
if (IS_MONOLITHIC)
# specify static linking as a macro
add_compile_definitions(MOON_IS_MONOLITHIC)
endif ()
if (WIN32 OR MINGW)
add_compile_definitions(NOMINMAX _CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN)
endif ()
# multiprocessor compiling
if(MSVC)
add_compile_options(/MP)
else()
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
set(CMAKE_BUILD_PARALLEL_LEVEL ${N})
endif()
endif()
add_subdirectory(engine)
add_subdirectory(editor)
add_subdirectory(sandbox)