forked from turanszkij/WickedEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (66 loc) · 2.48 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
cmake_minimum_required(VERSION 3.12)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"In-source builds are not supported!\n"
"Run `git clean -d -f` to clean up the files CMake has created (stash "
"your changes first, if you have made any), then run `cmake -B build "
"<other_options>` followed by `cmake --build build --parallel`"
)
endif()
set(WICKED_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
option(WICKED_DYNAMIC_LIBRARY "Build WickedEngine as a dynamic library" OFF)
option(USE_LIBCXX "Link WickedEngine to llvm libc++ library - only available with the Clang compiler" OFF)
option(WICKED_EDITOR "Build WickedEngine editor" ON)
option(WICKED_TESTS "Build WickedEngine tests" ON)
option(WICKED_IMGUI_EXAMPLE "Build WickedEngine imgui example" ON)
include(CMakeDependentOption)
if(UNIX)
option(WICKED_LINUX_TEMPLATE "Build WickedEngine Linux template" ON)
elseif(WIN32)
option(WICKED_WINDOWS_TEMPLATE "Build WickedEngine Windows template" ON)
endif()
# Configure CMake global variables
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Use solution folders to organize projects
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(WickedEngine)
if (WIN32)
set(PLATFORM "Windows")
add_compile_definitions(WIN32=1)
# add_compile_definitions(_WIN32=1) this is a given from the compiler
set(DXC_TARGET "${CMAKE_CURRENT_SOURCE_DIR}/WickedEngine/dxc.exe")
elseif(UNIX)
set(PLATFORM "SDL2")
add_compile_definitions(SDL2=1)
set(DXC_TARGET "dxc")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdeclspec -fms-extensions")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} $<$<NOT:$<WICKED_DYNAMIC_LIBRARY>>:--for-linker=-no-pie>" )
if (USE_LIBCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
else()
endif()
add_subdirectory(WickedEngine)
add_subdirectory(Content)
if (WICKED_EDITOR)
add_subdirectory(Editor)
endif()
if (WICKED_TESTS)
add_subdirectory(Samples/Tests)
endif()
if (WICKED_IMGUI_EXAMPLE)
add_subdirectory(Samples/Example_ImGui)
add_subdirectory(Samples/Example_ImGui_Docking)
endif()
if (WICKED_LINUX_TEMPLATE)
add_subdirectory(Samples/Template_Linux)
endif()
if (WICKED_WINDOWS_TEMPLATE)
add_subdirectory(Samples/Template_Windows)
endif()