forked from KDAB/KDStateMachineEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
184 lines (159 loc) · 6.25 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
# Top-level CMakeLists.txt file for the KDAB State Machine Editor Library.
cmake_minimum_required(VERSION 2.8.12) # because of ALIAS targets
project(kdstatemachineeditor)
# Version setup
set(KDSME_VERSION_MAJOR "0")
set(KDSME_VERSION_MINOR "0")
set(KDSME_VERSION_PATCH "95")
set(KDSME_VERSION "${KDSME_VERSION_MAJOR}.${KDSME_VERSION_MINOR}.${KDSME_VERSION_PATCH}")
set(KDSME_VERSION_STRING "${KDSME_VERSION}")
set(KDSME_SOVERSION "1.0.0")
set(PROJECT_VERSION_STRING "${KDSME_VERSION_STRING}")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH})
if(WIN32)
# Needed for qmake-integration because qmake's QT modules import mechanism does assume
# debug libraries at windows always have a d suffix.
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "debug library postfix, usually d on windows")
endif()
include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)
include(CTest)
include(GenerateExportHeader)
include(MacroLogFeature)
include(ECMAddTests)
include(ECMGeneratePriFile)
find_package(Qt5 5.3 REQUIRED Quick Test Widgets)
find_package(Qt5 5.3 REQUIRED QuickWidgets)
find_package(Qt5 5.4 OPTIONAL_COMPONENTS RemoteObjects)
set_package_properties(Qt5RemoteObjects PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Qt Remote Objects module"
PURPOSE "Needed for the QStateMachine adapter and remote debugging capabilities"
)
find_package(Qt5 5.3 OPTIONAL_COMPONENTS XmlPatterns)
set_package_properties(Qt5XmlPatterns PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Qt5 XmlPatterns library"
PURPOSE "Required for unit tests dealing with XML input/output"
)
option(DEPLOY_DEPENDENCIES "Install Qt5 and graphviz" ON)
option(BUILD_EXAMPLES "Build examples directory" ON)
# Don't require lots of include_directories(${CMAKE_CURRENT_SOURCE_DIR}) etc.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Automatically include the current dirs in the INTERFACE_INCLUDE_DIRS of targets.
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_AUTOMOC TRUE)
set(BIN_INSTALL_DIR bin)
set(LIB_INSTALL_DIR lib)
if(WIN32)
set(LIB_INSTALL_DIR ${BIN_INSTALL_DIR})
endif()
set(INCLUDE_INSTALL_DIR include/${CMAKE_PROJECT_NAME})
set(XDG_DATA_INSTALL_DIR share/${CMAKE_PROJECT_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${BIN_INSTALL_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIB_INSTALL_DIR})
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT Devel
BUNDLE DESTINATION "/Applications/Qt5"
)
set(GRAPHVIZ_MIN_VERSION "2.20")
find_package(Graphviz)
set_package_properties(Graphviz PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Graph visualization software"
PURPOSE "RECOMMENDED: Needed for automatic layout of state charts"
URL "http://www.graphviz.org/"
)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
check_cxx_compiler_flag(-Wunused-but-set-variable HAVE_GXX_UNUSED_BUT_SET)
check_cxx_compiler_flag(-Wlogical-op HAVE_GXX_LOGICAL_OP)
check_cxx_compiler_flag(-Wsizeof-pointer-memaccess HAVE_GXX_POINTER_MEMACCESS)
check_cxx_compiler_flag(-Wreorder HAVE_GXX_REORDER)
check_cxx_compiler_flag(-Wformat-security HAVE_GXX_FORMAT_SECURITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wextra -Woverloaded-virtual -Winit-self -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wmissing-noreturn -Werror=return-type")
if(HAVE_GXX_UNUSED_BUT_SET)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable")
endif()
if(HAVE_GXX_LOGICAL_OP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
endif()
if(HAVE_GXX_POINTER_MEMACCESS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsizeof-pointer-memaccess")
endif()
if(HAVE_GXX_REORDER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wreorder")
endif()
if(HAVE_GXX_FORMAT_SECURITY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security")
endif()
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") # required in C++11 mode
endif()
endif()
# linker flags
if(CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME STREQUAL GNU)
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
endif()
endif()
enable_testing()
set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
add_custom_target(copy_data ALL)
add_custom_command(TARGET copy_data
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data" "${PROJECT_BINARY_DIR}/data"
)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
set_package_properties(Doxygen PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Doxygen documentation generator"
PURPOSE "Needed for generating API documentation (make doc)"
)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
add_subdirectory(src)
set(CONFIG_DIR "KDSME")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_DIR}/KDSMEConfigVersion.cmake"
VERSION ${KDSME_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_file(cmake/KDSMEConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_DIR}/KDSMEConfig.cmake"
COPYONLY
)
set(CMAKECONFIG_INSTALL_DIR lib/cmake/${CONFIG_DIR})
install(EXPORT KDSME_TARGETS
NAMESPACE
KDSME::
FILE
KDSMETargets.cmake
DESTINATION
${CMAKECONFIG_INSTALL_DIR}
)
install(
FILES
cmake/KDSMEConfig.cmake
cmake/KDSMEFindDependencyMacro.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_DIR}/KDSMEConfigVersion.cmake"
DESTINATION
${CMAKECONFIG_INSTALL_DIR}
COMPONENT
Devel
)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)