forked from WishMakers0/Danmakufu-Woo-Edition
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
164 lines (129 loc) · 4.24 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
##
# @file CMakeLists.txt
# @author Arves100
# @date 06/03/2023
# @brief Main cmake processor
##
cmake_minimum_required(VERSION 3.20)
project(Danmakufu LANGUAGES CXX ASM)
# 0. Basic configurations
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
#include(CheckFunctionExists)
#include(CheckSymbolExists)
#include(CheckTypeSize)
include(Git)
## C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
## 64-bit build
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(DNH_X64 1)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(DNH_X64 0)
endif()
## Options
#option(DNH_BUILD_VIEWER "Build the Danmakufu viewer" ON)
#option(DNH_BUILD_EXECUTOR "Build the Danmakufu executor" ON)
#option(DNH_BUILD_TOOLS "Build the Danmakufu tools" ON)
#option(DNH_BUILD_CONFIG "Build the config utility" ON)
if (ENABLE_QT)
# Qt auto functions
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
endif()
function(set_target_name proj out)
# this function fixes up postfix, output name and directories (and removes out dir postifx for vs)
set_target_properties(${proj} PROPERTIES
RELEASE_POSTFIX ""
MINSIZEREL_POSTFIX "_msr"
RELWITHDEBINFO_POSTFIX "_rbi"
DEBUG_POSTFIX "_d"
OUTPUT_NAME "${out}"
)
# removes Debug/ Release/ in vs
set(TARGETS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
foreach (TARGET IN ITEMS ${TARGETS})
set_target_properties(${proj} PROPERTIES ${TARGET}_OUTPUT_NAME "${out}" RUNTIME_OUTPUT_DIRECTORY_${TARGET} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endforeach()
endfunction()
# 1. Compiler/platform specific configurations
if (MSVC)
include(FindDirectX) # MinGW already has DirectX9 SDK
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /permissive- /MP /fp:fast /W4 /arch:sse2") # (/WX)
if ("${VCPKG_TARGET_TRIPLET}" MATCHES "-static")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(MSVC_STATIC 1)
else()
set(MSVC_STATIC 0)
endif()
if (BUILD_64BIT)
enable_language(ASM_MASM) # fpfast asm routine
endif()
add_definitions(-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0601 -DWIN32_LEAN_AND_MEAN=1 -DSTRICT=1) # Default target Windows7+
else()
if (MINGW OR CYGWIN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode -mwindows")
if (MINGW)
set(CMAKE_EXE_LINKER ${CMAKE_CXX_COMPILER}) # bad linker toolchain fix
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS "-Wall -Wextra -ansi -pedantic -Werror -msse2 -ffast-math")
# gcc shouldn't have debug/ndebug macros
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
endif()
# 2. Dependencies
## libvorbis
find_package(Vorbis CONFIG REQUIRED) # Vorbis::vorbis Vorbis::vorbisenc Vorbis::vorbisfile
## Qt5
if (ENABLE_QT)
find_package(Qt5 REQUIRED COMPONENTS Widgets)
if (WIN32)
set(QT5_WINMAIN Qt5::WinMain)
else()
set(QT5_WINMAIN ) # Linux doesn't need this
endif()
endif()
## fmt
find_package(fmt CONFIG REQUIRED) # fmt::fmt
## spdlog
find_package(spdlog CONFIG REQUIRED) # spdlog::spdlog
## SDL2
find_package(SDL2 CONFIG REQUIRED) # $<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
## zlib
find_package(ZLIB REQUIRED) # ZLIB::ZLIB
## Boost
find_package(Boost REQUIRED COMPONENTS locale) # Boost::boost Boost::locale
## glm
#find_package(glm CONFIG REQUIRED) # glm::glm
## freetype2
#find_package(freetype CONFIG REQUIRED) # freetype
## harfbuzz
#find_package(harfbuzz CONFIG REQUIRED) # harfbuzz
## bgfx
#if (NOT DEFINED BX_ROOT_DIR)
# set(BX_ROOT_DIR "${CMAKE_SOURCE_DIR}/deps/bx")
#endif()
#if (NOT DEFINED BIMG_ROOT_DIR)
# set(BIMG_ROOT_DIR "${CMAKE_SOURCE_DIR}/deps/bimg")
#endif()
#if (NOT DEFINED BGFX_ROOT_DIR)
# set(BGFX_ROOT_DIR "${CMAKE_SOURCE_DIR}/deps/bgfx")
#endif()
# 3. extra checks or operations
#check_function_exists(getopt HAVE_GETOPT)
#
#check_type_size(ssize_t SIZEOF_SSIZE_T)
#
#if (NOT ${SIZEOF_SSIZE_T} EQUAL 0)
# add_definitions(-DDNH_HAVE_SSIZE_T)
#endif()
# 4. Add source code
add_subdirectory(deps)
add_subdirectory(source)