This repository has been archived by the owner on Nov 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
154 lines (135 loc) · 5.17 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# CMake entry point
cmake_minimum_required (VERSION 3.12.0)
project (TEngine)
find_package(OpenGL REQUIRED)
if (CMAKE_CROSSCOMPILING)
message(STATUS "Cross-compiling enabled")
endif()
if (NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(X11 REQUIRED)
endif()
# Check for MSVC and adjust compiler flags
if (MSVC)
message(STATUS "Building with MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /MP /O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /W3 /MP /O2")
else()
if (CMAKE_CROSSCOMPILING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_WIN32_WINNT=0x0601 -DWIN32_WINNT=0x0601 -DWINVER=0x0601 -fstack-protector-strong -fpic -fpie -pie -Wdeprecated-declarations -mavx2 -Ofast --static -fcf-protection=full -mshstk")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWIN32_WINNT=0x0601 -DWINVER=0x0601 -fstack-protector-strong -fpic -fpie -pie -std=gnu++23 -mavx2 -Wdeprecated-declarations --static -Ofast -fcf-protection=full -mshstk")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -D_WIN32_WINNT=0x0601 -DWIN32_WINNT=0x0601 -DWINVER=0x0601 -ftree-vectorize -fopt-info-vec -funroll-loops -fomit-frame-pointer -fstack-protector-strong -fpic -fpie -pie -Wdeprecated-declarations -pthread -mavx2 -Ofast --static -fcf-protection=full -mshstk -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -D_WIN32_WINNT=0x0601 -DWIN32_WINNT=0x0601 -DWINVER=0x0601 -ftree-vectorize -fopt-info-vec -funroll-loops -fomit-frame-pointer -fstack-protector-strong -fpic -fpie -pie -std=gnu++23 -Wdeprecated-declarations -pthread -mavx2 -Ofast --static -fcf-protection=full -mshstk -march=native")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--nxcompat -flto -Wl,--gc-sections -Wl,-Map=memory_map.map")
endif()
endif()
if( CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR )
message( FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like bin_Visual2012_64bits/)" )
endif()
if( CMAKE_SOURCE_DIR MATCHES " " )
message( "Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if( CMAKE_BINARY_DIR MATCHES " " )
message( "Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
# Compile external dependencies
add_subdirectory (external)
# On Visual Studio, enable multi-process compilation
if (MSVC)
cmake_policy(SET CMP0026 OLD)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-fe2273")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP
endif()
if(INCLUDE_DISTRIB)
add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)
include_directories(
external/AntTweakBar-1.16/include/
external/glfw-3.3/include/
external/glm-0.9.9.7/
external/glew-2.1.0/include/
external/assimp-3.0.1270/include/
external/bullet-2.81-rev2613/src/
${freetype_SOURCE_DIR}/include
${freetype_BINARY_DIR}/include
${lunasvg_SOURCE_DIR}/include
${lunasvg_BINARY_DIR}/include
external/imgui-1.91.0/
external/imgui-1.91.0/backends
external/imgui-1.91.0/misc/freetype
external/stb/include
external/json/include
external/crash-handler/
.
)
# Add Dear ImGui source files
set(IMGUI_SOURCE
external/imgui-1.91.0/imgui.cpp
external/imgui-1.91.0/imgui_demo.cpp
external/imgui-1.91.0/imgui_draw.cpp
external/imgui-1.91.0/imgui_tables.cpp
external/imgui-1.91.0/imgui_widgets.cpp
external/imgui-1.91.0/backends/imgui_impl_glfw.cpp
external/imgui-1.91.0/backends/imgui_impl_opengl3.cpp
external/imgui-1.91.0/misc/freetype/imgui_freetype.cpp
)
add_library(ImGui STATIC ${IMGUI_SOURCE})
if (NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_210
ImGui
assimp
freetype
lunasvg
)
else()
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_210
ImGui
assimp
dbghelp
psapi
freetype
lunasvg
)
endif()
if (NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND ALL_LIBS ${X11_LIBRARIES} Xxf86vm)
endif()
# Add MSVC-specific libraries
if (MSVC)
list(APPEND ALL_LIBS opengl32.lib glfw.lib GLEW_210.lib ImGui.lib)
endif()
if (NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
else()
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
endif()
# TEngine build target
add_executable(TEngine
src/Main.cpp
)
target_compile_definitions(TEngine PUBLIC _WIN32_WINNT=0x0601 WIN32_WINNT=0x0601 WINVER=0x0601)
target_link_libraries(TEngine
${ALL_LIBS}
)
# Xcode and Visual working directories
set_target_properties(TEngine PROPERTIES XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/")
# create_target_launcher(TEngine WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/")