forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
186 lines (148 loc) · 3.92 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
cmake_minimum_required(VERSION 3.4)
# version 3.4 is required as other do not work with C++14 and clang
project(NodeEditor CXX)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
option(BUILD_STATIC_LIBS "Build static library" OFF)
option(BUILD_SHARED_LIBS "Build shared library" ON)
find_package(ament_cmake REQUIRED)
# Find the QtWidgets library
find_package(Qt5 5.3 COMPONENTS
Core
Widgets
Gui
OpenGL
Svg
Xml REQUIRED)
qt5_add_resources(RESOURCES ./resources/resources.qrc)
# Unfortunately, as we have a split include/src, AUTOMOC doesn't work.
# We'll have to manually specify some files
set(CMAKE_AUTOMOC ON)
set(CPP_SOURCE_FILES
src/Connection.cpp
src/ConnectionBlurEffect.cpp
src/ConnectionGeometry.cpp
src/ConnectionGraphicsObject.cpp
src/ConnectionPainter.cpp
src/ConnectionState.cpp
src/ConnectionStyle.cpp
src/DataModelRegistry.cpp
src/FlowScene.cpp
src/FlowView.cpp
src/FlowViewStyle.cpp
src/Node.cpp
src/NodeConnectionInteraction.cpp
src/NodeDataModel.cpp
src/NodeGeometry.cpp
src/NodeGraphicsObject.cpp
src/NodePainter.cpp
src/NodeState.cpp
src/NodeStyle.cpp
src/Properties.cpp
src/StyleCollection.cpp
)
set(THIS_PACKAGE_INCLUDE_DEPENDS
Qt5
)
# If we want to give the option to build a static library,
# set BUILD_SHARED_LIBS option to OFF
add_library(nodes SHARED
${CPP_SOURCE_FILES}
${RESOURCES}
)
ament_target_dependencies(nodes ${THIS_PACKAGE_INCLUDE_DEPENDS})
add_library(NodeEditor::nodes ALIAS nodes)
target_include_directories(nodes
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/nodes/internal>
)
target_link_libraries(nodes
PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Gui
Qt5::OpenGL
Qt5::Xml
Qt5::Svg
)
target_compile_definitions(nodes
PUBLIC
${Qt5Widgets_DEFINITIONS}
NODE_EDITOR_SHARED
PRIVATE
NODE_EDITOR_EXPORTS
#NODE_DEBUG_DRAWING
)
target_compile_options(nodes
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4127 /EHsc>
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -std=c++11>
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -std=c++11>
)
target_compile_features(nodes
PUBLIC
cxx_generic_lambdas # Require C++14
)
# set_target_properties(nodes
# PROPERTIES
# ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
# )
######
# Moc
##
file(GLOB_RECURSE HEADERS_TO_MOC include/nodes/internal/*.hpp)
qt5_wrap_cpp(nodes_moc
${HEADERS_TO_MOC}
TARGET nodes
OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp
)
target_sources(nodes PRIVATE ${nodes_moc})
###########
# Examples
##
set(BUILD_EXAMPLES false)
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
##################
# Automated Tests
##
set(BUILD_TESTING false)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
###############
# Installation
##
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR lib/cmake/NodeEditor)
install(TARGETS nodes
EXPORT export_nodes
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
install(DIRECTORY include/ DESTINATION include)
install(EXPORT export_nodes
FILE NodeEditorTargets.cmake
NAMESPACE NodeEditor::
DESTINATION ${INSTALL_CONFIGDIR}
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/NodeEditorConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NodeEditorConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/NodeEditorConfig.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
ament_export_targets(export_nodes HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()