-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
172 lines (141 loc) · 5.41 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
cmake_minimum_required(VERSION 3.25)
project(PhotoBroom VERSION 1.7.0 LANGUAGES CXX)
if(POLICY CMP0140)
cmake_policy(SET CMP0140 NEW)
endif()
if(POLICY CMP0146)
cmake_policy(SET CMP0146 OLD)
endif()
if(POLICY CMP0160)
cmake_policy(SET CMP0160 NEW)
endif()
if(POLICY CMP0174)
cmake_policy(SET CMP0174 NEW)
endif()
if(POLICY CMP0177)
cmake_policy(SET CMP0177 NEW)
endif()
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake_modules;
)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
#check if git modules are setup
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/cmake_modules/FindEasyExif.cmake)
message(FATAL_ERROR "Git submodules were not updated. See docs/build.txt for instructions.")
endif()
#options for CPack
set(CPACK_PACKAGE_VENDOR "Michal Walenciak")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Photo Broom - tool for managing your photos")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/docs/gpl-3.0.txt)
#include modules
include(FeatureSummary)
include(GenerateExportHeader)
include(CheckCXXCompilerFlag)
include(CTest)
include(${PROJECT_SOURCE_DIR}/cmake/functions.cmake)
include(${PROJECT_SOURCE_DIR}/cmake_modules/DeveloperTools.cmake)
#objdump
if(ENABLE_OBJDUMPING)
add_custom_target(DumpObjs ALL)
endif()
#options:
option(BUILD_LEARNING_TESTS "Build learning tests" OFF)
option(RUN_TESTS_AFTER_BUILD "Run unit tests after build.")
option(BUILD_UPDATER "Enable 'updater' module" ${WIN32})
option(STATIC_PLUGINS "Build plugins as static" OFF)
#options description:
add_feature_info("Run unit test after build" RUN_TESTS_AFTER_BUILD "Runs unit tests after build. Feature controled by RUN_TESTS_AFTER_BUILD variable.")
add_feature_info("Enable 'updater' module" BUILD_UPDATER "Build module responsible for online version check.")
add_feature_info("Static plugins" STATIC_PLUGINS "Build all plugins as static modules.")
add_feature_info("Build id" PHOTO_BROOM_BUILD_ID "Build id attached to installer version")
#tests
enable_testing()
#system related definitions
if(UNIX OR CYGWIN)
add_definitions(-DOS_UNIX)
elseif(WIN32)
add_definitions(-DOS_WIN)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif(UNIX OR CYGWIN)
#base paths
if(UNIX OR CYGWIN)
set(PATH_BIN "bin")
set(PATH_LIBS "lib/photo_broom")
set(PATH_PLUGINS "lib/photo_broom/plugins")
set(PATH_TR "share/photo_broom/tr")
set(PATH_DOCS "share/photo_broom/docs")
set(PATH_ICONS "share/photo_broom/icons")
set(PATH_SCRIPTS "share/photo_broom/scripts")
set(PATH_DATA "share/photo_broom/")
elseif(WIN32)
set(PATH_BIN ".")
set(PATH_LIBS ".")
set(PATH_PLUGINS "plugins")
set(PATH_TR "tr")
set(PATH_DOCS "docs")
set(PATH_ICONS "icons")
set(PATH_SCRIPTS "scripts")
set(PATH_DATA ".")
endif(UNIX OR CYGWIN)
# RPATH
# http://www.cmake.org/Wiki/CMake_RPATH_handling
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PATH_LIBS}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#system dependent stuff
if(UNIX OR CYGWIN)
include(${PROJECT_SOURCE_DIR}/cmake/system/linux.cmake)
elseif(WIN32)
include(${PROJECT_SOURCE_DIR}/cmake/system/win32.cmake)
endif(UNIX OR CYGWIN)
#subdirs
add_subdirectory(src)
add_subdirectory(tr)
#documentation
find_program(DOXYGEN doxygen)
add_feature_info("Documentation generation" DOXYGEN "When doxygen program is found, extra build target is enabled.")
if(DOXYGEN)
add_custom_target(documentation
COMMAND ${DOXYGEN} ${CMAKE_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} )
endif(DOXYGEN)
#icons
set(SVG_ICONS images/photo_broom.svg)
#installation steps
install(FILES ${SVG_ICONS} DESTINATION ${PATH_ICONS}/svg)
#package
include(CPack)
#info
message("")
message("*************************************************************")
message("Configuration summary:")
message("")
message("Extra targets:")
if(DOXYGEN)
message("documentation - generates html in build dir")
endif()
message("generate_code_coverage - generates code coverage in build dir")
message("package - generates broom installer")
if(TARGET deploy)
message("deploy - generates list of external libraries used by project and adds them to instalation (and package). Run manually before package on Windows")
endif()
if(BUILD_TESTING)
message("test - runs tests (ctest command can also be used)")
message("run_unit_tests_code_coverage - runs tests and collects code coverage")
endif()
message("")
feature_summary(WHAT ALL)