forked from Ataraxia-Mechanica/InfiniSweeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
108 lines (86 loc) · 2.92 KB
/
CMakeLists.txt
File metadata and controls
108 lines (86 loc) · 2.92 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.14)
set(CMAKE_CXX_STANDARD 20)
project(Template
VERSION 0.0.1
LANGUAGES C CXX)
set(LOCAL_EXECUTABLE_NAME "InfiniSweeper")
# Source files (just grab all of them)
file(GLOB SOURCES CONFIGURE_DEPENDS
"src/*.h"
"src/*.hpp"
"src/*.cpp"
)
# Compiler definitions
set(DEFINES
)
# Compiler options
set(OPTIONS
)
# LTO magic and fast math when releasing
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if(supported)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
add_compile_options("/fp:fast")
else()
add_compile_options("-ffast-math")
endif()
endif()
add_executable(${LOCAL_EXECUTABLE_NAME})
target_sources(${LOCAL_EXECUTABLE_NAME} PRIVATE ${SOURCES})
target_compile_definitions(${LOCAL_EXECUTABLE_NAME} PRIVATE ${DEFINES})
target_compile_options(${LOCAL_EXECUTABLE_NAME} PRIVATE ${OPTIONS})
if(WIN32)
target_sources(${LOCAL_EXECUTABLE_NAME} PRIVATE "res/icon.rc")
endif()
# On Windows, disable console on release. -mwindows does not work in Clang with GCC-like commandline mode but same argument as MSVC mode works
if(WIN32)
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_link_options(${LOCAL_EXECUTABLE_NAME} PRIVATE "/SUBSYSTEM:WINDOWS" "/ENTRY:mainCRTStartup")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_options(${LOCAL_EXECUTABLE_NAME} PRIVATE "-Wl,-subsystem:windows,-entry:mainCRTStartup")
else()# GCC only
target_link_options(${LOCAL_EXECUTABLE_NAME} PRIVATE "-mwindows")
endif()
endif()
endif()
set_target_properties(${LOCAL_EXECUTABLE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "bin")
# Libraries
set(ADDITIONAL_INCLUDES
"imgui/"
"rlImGui/"
"raylib/src/external/glfw/deps/"
"tomlplusplus/include/toml++/"
)
list(TRANSFORM ADDITIONAL_INCLUDES PREPEND "vendor/")
target_include_directories(${LOCAL_EXECUTABLE_NAME} PRIVATE ${ADDITIONAL_INCLUDES})
set(LOCAL_SUBDIRECTORIES
"raylib"
"raylib-cpp"
)
list(TRANSFORM LOCAL_SUBDIRECTORIES PREPEND "vendor/")
list(TRANSFORM LOCAL_SUBDIRECTORIES APPEND "/")
set(LIBRARIES
"raylib"
"raylib_cpp"
)
target_link_libraries(${LOCAL_EXECUTABLE_NAME} PRIVATE ${LIBRARIES})
foreach(SUBDIRECTORY ${LOCAL_SUBDIRECTORIES})
add_subdirectory(${SUBDIRECTORY})
endforeach()
# imgui & rlImGui, simply compile together with project
file(GLOB IMGUI CONFIGURE_DEPENDS
"vendor/imgui/*.h"
"vendor/imgui/*.hpp"
"vendor/imgui/*.cpp"
"vendor/rlImGui/*.h"
"vendor/rlImGui/*.hpp"
"vendor/rlImGui/*.cpp"
)
target_sources(${LOCAL_EXECUTABLE_NAME} PRIVATE ${IMGUI})