forked from greenjava/camp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
264 lines (232 loc) · 7.57 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
###############################################################################
##
## Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company.
## Contact: Tegesoft Information ([email protected])
##
## This file is part of the CAMP library.
##
## The MIT License (MIT)
##
## Copyright (c) 2009-2014 TEGESO/TEGESOFT
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
## THE SOFTWARE.
##
###############################################################################
cmake_minimum_required(VERSION 2.8.8)
# set project's name
project(CAMP)
# require C++11 standard by default
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# include project configuration
include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/PackageFilename.cmake)
# all source files
set(CAMP_SRCS
include/camp/userproperty.hpp
src/userproperty.cpp
include/camp/userobject.hpp
include/camp/userobject.inl
src/userobject.cpp
include/camp/tagholder.hpp
src/tagholder.cpp
include/camp/simpleproperty.hpp
src/simpleproperty.cpp
include/camp/property.hpp
src/property.cpp
include/camp/observer.hpp
src/observer.cpp
include/camp/errors.hpp
src/errors.cpp
include/camp/function.hpp
src/function.cpp
include/camp/error.hpp
src/error.cpp
include/camp/enumproperty.hpp
src/enumproperty.cpp
include/camp/enumobject.hpp
include/camp/enumobject.inl
src/enumobject.cpp
include/camp/enumbuilder.hpp
src/enumbuilder.cpp
include/camp/enum.hpp
include/camp/enum.inl
src/enum.cpp
include/camp/classvisitor.hpp
src/classvisitor.cpp
include/camp/class.hpp
include/camp/class.inl
src/class.cpp
include/camp/arrayproperty.hpp
src/arrayproperty.cpp
include/camp/args.hpp
src/args.cpp
include/camp/value.hpp
include/camp/value.inl
src/value.cpp
include/camp/detail/classmanager.hpp
src/classmanager.cpp
include/camp/detail/enummanager.hpp
src/enummanager.cpp
include/camp/detail/observernotifier.hpp
src/observernotifier.cpp
include/camp/camptype.hpp
src/camptype.cpp
include/camp/classcast.hpp
src/classcast.cpp
include/camp/type.hpp
include/camp/enumget.hpp
include/camp/enumget.inl
include/camp/constructor.hpp
include/camp/config.hpp
include/camp/classget.hpp
include/camp/classget.inl
include/camp/classbuilder.hpp
include/camp/classbuilder.inl
include/camp/arraymapper.hpp
include/camp/valuemapper.hpp
include/camp/valuevisitor.hpp
include/camp/detail/valueimpl.hpp
include/camp/detail/userpropertyimpl.hpp
include/camp/detail/userpropertyimpl.inl
include/camp/detail/typeid.hpp
include/camp/detail/simplepropertyimpl.hpp
include/camp/detail/simplepropertyimpl.inl
include/camp/detail/returntype.hpp
include/camp/detail/rawtype.hpp
include/camp/detail/propertyfactory.hpp
include/camp/detail/objecttraits.hpp
include/camp/detail/issmartpointer.hpp
include/camp/detail/getter.hpp
include/camp/detail/getter.inl
include/camp/detail/functiontraits.hpp
include/camp/detail/functionimpl.hpp
include/camp/detail/enumpropertyimpl.hpp
include/camp/detail/enumpropertyimpl.inl
include/camp/detail/constructorimpl.hpp
include/camp/detail/callhelper.hpp
include/camp/detail/arraypropertyimpl.hpp
include/camp/detail/arraypropertyimpl.inl
include/camp/detail/yesnotype.hpp
include/camp/detail/objectholder.hpp
include/camp/detail/objectholder.inl
include/camp/detail/valueprovider.hpp
include/camp/qt/qthelper.hpp
include/camp/qt/qtsimpleproperty.hpp
include/camp/qt/qtmapper.hpp
include/camp/qt/qt.hpp
include/camp/qt/qstring.hpp
include/camp/qt/qlist.hpp
include/camp/qt/qvector.hpp
include/camp/qt/qtfunction.hpp
)
# find Boost
find_package(Boost 1.38.0 REQUIRED)
# include files search paths
include_directories(
${CAMP_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
)
# generate version.hpp
message("Generate version.hpp")
configure_file(${CMAKE_SOURCE_DIR}/version.in ${CMAKE_BINARY_DIR}/version.hpp @ONLY)
# instruct CMake to build a shared library from all of the source files
add_library(camp ${CAMP_SRCS})
# define the export macro
if(BUILD_SHARED_LIBS)
set_target_properties(camp PROPERTIES DEFINE_SYMBOL CAMP_EXPORTS SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}" VERSION "${VERSION_STR}")
else()
add_definitions(-DCAMP_STATIC)
endif()
# define d suffix on windows
if(WIN32)
set_target_properties(camp PROPERTIES DEBUG_POSTFIX d)
endif()
# gcc 4.x on Windows requires the -static-libgcc linker option to get rid of an extra DLL
if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
if(${GCC_VERSION} MATCHES "4\\..*")
set_target_properties(camp PROPERTIES LINK_FLAGS -static-libgcc)
endif()
endif()
# add the test subdirectory, but do not build it by default
if(BUILD_TEST)
enable_testing()
add_subdirectory(test)
endif()
###############################
# doc
###############################
add_subdirectory(doc)
###############################
# support files
###############################
# pkg-config
configure_file(cmake/camp.pc.in ${CMAKE_BINARY_DIR}/camp.pc @ONLY)
# cmake
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/CAMPConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CAMPConfig.cmake
INSTALL_DESTINATION lib/camp/cmake
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/CAMPConfigVersion.cmake
VERSION ${VERSION_STR}
COMPATIBILITY AnyNewerVersion
)
###############################
# installing
###############################
install(DIRECTORY include
DESTINATION .
COMPONENT devel
)
install(FILES ${CMAKE_BINARY_DIR}/version.hpp
DESTINATION include/camp
COMPONENT devel
)
install(TARGETS camp
EXPORT CAMPTargets
RUNTIME DESTINATION bin COMPONENT bin
LIBRARY DESTINATION lib COMPONENT bin
ARCHIVE DESTINATION lib COMPONENT devel
)
install(FILES ${CMAKE_BINARY_DIR}/camp.pc
DESTINATION lib/pkgconfig
COMPONENT devel
)
install(EXPORT CAMPTargets
NAMESPACE camp::
DESTINATION lib/camp/cmake
COMPONENT devel
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CAMPConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CAMPConfigVersion.cmake
DESTINATION lib/camp/cmake
COMPONENT devel
)
install(FILES README.txt COPYING.txt
DESTINATION ${INSTALL_MISC_DIR}
)
install(DIRECTORY cmake
DESTINATION ${INSTALL_MISC_DIR}
COMPONENT utils
)
###############################
# packaging
###############################
include(${CAMP_SOURCE_DIR}/cmake/Packaging.cmake OPTIONAL)