-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
146 lines (121 loc) · 4.31 KB
/
CMakeLists.txt
File metadata and controls
146 lines (121 loc) · 4.31 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
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
cmake_minimum_required (VERSION 2.8.12...3.10)
project(PGEFileLibrary C CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
message("== Using default build configuration which is a Release!")
endif()
if(POLICY CMP0077) # Allow external configuring when building as sub-directory
cmake_policy(SET CMP0077 NEW)
endif()
if(POLICY CMP0069) # Allow CMAKE_INTERPROCEDURAL_OPTIMIZATION (lto) to be set
cmake_policy(SET CMP0069 NEW)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "d")
endif()
option(PGEFL_ENABLE_RWOPS "Enable SDL_RWops interfaces (if this option is enabled, then PGE-FL has a build-time dependency on SDL2's headers)" OFF)
if(NOT DEFINED PGE_FORCE_QT5 AND NOT DEFINED PGEFL_PREFER_QT5)
option(PGE_FORCE_QT5 "Try to find Qt5 instead of Qt6 if available" ON)
endif()
macro(pgeflFindQt)
if(NOT PGE_FORCE_QT5 AND NOT PGEFL_PREFER_QT5)
find_package(Qt6Core QUIET)
endif()
if(PGE_FORCE_QT5 OR PGEFL_PREFER_QT5 OR NOT Qt6Core_FOUND)
find_package(Qt5Core QUIET)
set(PGEFL_USE_QT5 TRUE)
set(PGEFL_QT_CORE_DEFS ${Qt5Core_DEFINITIONS})
set(PGEFL_QT_CORE_INCS ${Qt5Core_INCLUDE_DIRS})
message("-- PGE-FL Qt 5 detected")
else()
set(PGEFL_USE_QT6 TRUE)
set(PGEFL_QT_CORE_DEFS ${Qt6Core_DEFINITIONS})
set(PGEFL_QT_CORE_INCS ${Qt6Core_INCLUDE_DIRS})
message("-- PGE-FL Qt 6 detected")
endif()
endmacro()
if(NOT DEFINED PGEFL_QT_SUPPORT AND NOT VITA AND NOT PS2)
pgeflFindQt()
endif()
if(PGEFL_QT_SUPPORT)
pgeflFindQt()
endif()
if(VITA OR PS2 OR PGEFL_USE_QT5 OR PGEFL_USE_QT6)
set(OPT_DEF_PGEFL_QT_SUPPORT OFF)
else()
set(OPT_DEF_PGEFL_QT_SUPPORT ON)
endif()
if(NOT PGEFL_QT_SUPPORT)
option(PGEFL_QT_SUPPORT "Build also Qt variant" ${OPT_DEF_PGEFL_QT_SUPPORT})
endif()
if(PGEFL_QT_SUPPORT AND NOT VITA AND NOT NINTENDO_3DS AND NOT NINTENDO_WII AND NOT NINTENDO_WIIU AND NOT NINTENDO_SWITCH)
message("== PGE-FL Qt Edition WILL be built!")
if(POLICY CMP0071) # Automoc
cmake_policy(SET CMP0071 NEW)
endif()
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
message("== PGE-FL Qt Edition is disabled")
endif()
set(LIBRARY_PROJECT 1)
include(build_props.cmake)
include(pge_file_library.cmake)
if(PGEFL_USE_QT6)
pge_cxx_standard(17)
else()
pge_cxx_standard(11)
endif()
pgefl_disable_cxx_warning_flag("deprecated-copy" NO_DEPRECATED_COPY)
set(PGEFL_INSTALLS)
add_library(pgefl STATIC
${PGE_FILE_LIBRARY_SRCS}
)
set_target_properties(pgefl PROPERTIES AUTOMOC OFF)
target_include_directories(pgefl PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src")
list(APPEND PGEFL_INSTALLS pgefl)
if(PGEFL_ENABLE_RWOPS)
target_compile_definitions(pgefl PUBLIC -DPGEFL_ENABLE_RWOPS)
endif()
if(PGEFL_QT_SUPPORT)
add_library(pgefl_qt STATIC
${PGE_FILE_LIBRARY_SRCS}
)
set_target_properties(pgefl_qt PROPERTIES AUTOMOC ON)
target_compile_definitions(pgefl_qt PUBLIC -DPGE_FILES_QT ${PGEFL_QT_CORE_DEFS})
target_include_directories(pgefl_qt PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
${PGEFL_QT_CORE_INCS})
list(APPEND PGEFL_INSTALLS pgefl_qt)
if(PGEFL_ENABLE_RWOPS)
target_compile_definitions(pgefl_qt PUBLIC -DPGEFL_ENABLE_RWOPS)
endif()
endif()
# Don't install libraries when PGE-FL was built as a part of Moondust master project
if(NOT Moondust_SOURCE_DIR)
install(TARGETS ${PGEFL_INSTALLS}
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
FRAMEWORK DESTINATION "lib"
INCLUDES DESTINATION "include"
)
file(GLOB PGE_FL_HEADS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
install(FILES
${PGE_FL_HEADS}
DESTINATION include/PGE_File_Formats
)
endif()
# === Unit tests ====
option(WITH_UNIT_TESTS "Enable unit testing" OFF)
if(WITH_UNIT_TESTS)
enable_testing()
add_subdirectory(test)
endif()