forked from WohlSoft/PGE-File-Library-STL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
100 lines (82 loc) · 2.85 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
cmake_minimum_required (VERSION 2.8.12)
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()
if(NOT VITA)
find_package(Qt5Core QUIET)
endif()
if(VITA OR Qt5Core_FOUND)
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)
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)
pge_cxx_standard(11)
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}")
list(APPEND PGEFL_INSTALLS pgefl)
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 ${Qt5Core_DEFINITIONS})
target_include_directories(pgefl_qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" ${Qt5Core_INCLUDE_DIRS})
list(APPEND PGEFL_INSTALLS pgefl_qt)
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()