-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
64 lines (48 loc) · 1.98 KB
/
CMakeLists.txt
File metadata and controls
64 lines (48 loc) · 1.98 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
cmake_minimum_required(VERSION 3.26.0)
# 加载用户配置
include("${CMAKE_SOURCE_DIR}/cmake/load_config.cmake")
# 项目相关
if (WITH_CUDA)
project(MoerEngine LANGUAGES CXX C CUDA)
else()
project(MoerEngine LANGUAGES CXX C)
endif()
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 1)
set(PROJECT_VERSION_PATCH 0)
# 路径
set(moer_root_dir ${CMAKE_CURRENT_SOURCE_DIR})
set(moer_source_dir ${moer_root_dir}/source)
set(moer_third_party_dir "${moer_root_dir}/3rdparty")
set(moer_shader_dir "${moer_root_dir}/shaders")
# 构建相关
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 统一输出路径:MSVC 与 Clang(Ninja) 均使用 target/bin/<Config>/ 与 target/lib/<Config>/
# $<CONFIG> 在 multi-config(MSVC) 下为构建时选择的配置,在 single-config(Ninja) 下为 CMAKE_BUILD_TYPE
set(CMAKE_INSTALL_PREFIX "${moer_root_dir}/target")
set(BINARY_ROOT_DIR "${moer_root_dir}/target")
# set output folder (使用 generator expression 保证两种生成器输出目录一致)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINARY_ROOT_DIR}/bin/$<CONFIG>")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BINARY_ROOT_DIR}/lib/$<CONFIG>")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BINARY_ROOT_DIR}/lib/$<CONFIG>")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${BINARY_ROOT_DIR}/bin/$<CONFIG>")
add_compile_definitions(EDITOR_MODE_ON=1)
option(moer_build_test "build test unit" ON)
if(${MSVC})
add_compile_options("/Zc:preprocessor")
add_compile_options("/wd5105")
add_compile_options("/wd5104")
add_compile_options("/wd4267") # 禁用MSVC C4267警告 (size_t -> int)
add_compile_options("/FS")
add_compile_options("/MP")
# Support Chinese Comments
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
endif()
# 子目录:3rdparty
include(${CMAKE_SOURCE_DIR}/cmake/functions.cmake)
add_subdirectory_silent("3rdparty")
# 子目录:source
add_subdirectory("source")