-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
173 lines (137 loc) · 5.16 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#[[ Project: Mandelscape
[[ Copyright (C) 2020-2021 Erik Präntare
[[
[[ This program is free software: you can redistribute it and/or modify
[[ it under the terms of the GNU Affero General Public License as published by
[[ the Free Software Foundation, either version 3 of the License, or
[[ (at your option) any later version.
[[
[[ This program is distributed in the hope that it will be useful,
[[ but WITHOUT ANY WARRANTY; without even the implied warranty of
[[ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[[ GNU Affero General Public License for more details.
[[
[[ You should have received a copy of the GNU Affero General Public License
[[ along with this program. If not, see <http://www.gnu.org/licenses/>.
#]]
include(ExternalProject)
#---------------------------CMake Project Config-------------------------------
if(WIN32)
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
else()
cmake_minimum_required(VERSION 3.12)
endif()
project(Mandelscape LANGUAGES CXX)
if(NOT CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(CLANG_TIDY "Run clang-tidy on Mandelscape" OFF)
option(BUILD_TESTING OFF)
#---------------------------Compilation database generation--------------------
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_custom_target(copy-compile-commands ALL
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/compile_commands.json
${PROJECT_SOURCE_DIR}/compile_commands.json)
#---------------------------git submodule setup--------------------------------
option(UPDATE_SUBMODULES "Update git submodules before configuration" ON)
if(UPDATE_SUBMODULES)
include(UpdateSubmodules)
endif()
#---------------------------CCache setup---------------------------------------
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
endif()
#---------------------------Threading library----------------------------------
find_package(Threads REQUIRED)
#---------------------------Glad-----------------------------------------------
add_subdirectory(extern/glad)
#---------------------------glm------------------------------------------------
#find_package(glm CONFIG QUIET)
if(NOT glm_FOUND)
add_subdirectory(extern/glm)
endif()
if(NOT TARGET glm::glm)
add_library(glm::glm INTERFACE IMPORTED)
target_link_libraries(glm::glm
INTERFACE glm)
endif()
#---------------------------glfw-----------------------------------------------
#find_package(GLFW QUIET)
if(NOT GLFW_FOUND)
option(BUILD_SHARED_LIBS OFF)
option(GLFW_BUILD_DOCS OFF)
option(GLFW_INSTALL OFF)
option(USE_MSVC_RUNTIME_LIBRARY_DLL OFF)
add_subdirectory(extern/glfw)
endif()
if(NOT TARGET glfw::glfw)
add_library(glfw::glfw INTERFACE IMPORTED)
target_link_libraries(glfw::glfw
INTERFACE glfw)
endif()
#---------------------------stb------------------------------------------------
#find_package(stb QUIET)
if(NOT TARGET stb::stb)
add_library(stb::stb INTERFACE IMPORTED)
if(stb_FOUND)
target_include_directories(stb::stb
INTERFACE ${stb_INCLUDE_DIR})
else()
target_include_directories(stb::stb
INTERFACE extern/stb)
endif()
endif()
#---------------------------luajit---------------------------------------------
add_library(luajit::luajit INTERFACE IMPORTED)
if(MINGW)
set(LUAJIT_HOST_CC "gcc -m64")
set(LUAJIT_CROSS "x86_64-w64-mingw32-")
ExternalProject_Add(luajit
SOURCE_DIR ${PROJECT_SOURCE_DIR}/extern/luajit-2.0
BUILD_IN_SOURCE 1
BUILD_COMMAND make
HOST_CC=${LUAJIT_HOST_CC}
CROSS=${LUAJIT_CROSS}
TARGET_SYS=Windows
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND "")
add_dependencies(luajit::luajit luajit)
target_link_libraries(luajit::luajit
INTERFACE
"${PROJECT_SOURCE_DIR}/extern/luajit-2.0/src/libluajit-5.1.dll.a")
else()
ExternalProject_Add(luajit
SOURCE_DIR ${PROJECT_SOURCE_DIR}/extern/luajit-2.0
BUILD_IN_SOURCE 1
BUILD_COMMAND make
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
INSTALL_COMMAND "")
add_dependencies(luajit::luajit luajit)
target_link_libraries(luajit::luajit
INTERFACE "${PROJECT_SOURCE_DIR}/extern/luajit-2.0/src/libluajit.a")
endif()
#---------------------------nativefiledialog-extended--------------------------
add_library(nfde::nfde INTERFACE IMPORTED)
add_subdirectory(extern/nfde)
target_link_libraries(nfde::nfde INTERFACE nfd)
#---------------------------Catch2---------------------------------------------
if(BUILD_TESTING)
find_package(Catch2 QUIET)
if(NOT Catch2_FOUND)
add_subdirectory(${PROJECT_SOURCE_DIR}/extern/Catch2)
endif()
endif()
#---------------------------tests----------------------------------------------
if(BUILD_TESTING)
option(COVERAGE "Run gcovr after testing" ON)
option(GCOVR_GEN_HTML "Generate html files from coverage" OFF)
add_subdirectory(tests)
endif()
#---------------------------Mandelscape----------------------------------------
add_subdirectory(src)