Skip to content

Commit ddb5498

Browse files
committed
Use AUTOMOC instead of manually wrapping the headers
1 parent 0879d3a commit ddb5498

1 file changed

Lines changed: 2 additions & 28 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,6 @@ if (${QT_VERSION} VERSION_LESS 5.11.0)
6060
message(FATAL_ERROR "Requires qt version >= 5.11.0, Your current version is ${QT_VERSION}")
6161
endif()
6262

63-
if (${QT_VERSION_MAJOR} EQUAL 6)
64-
qt_add_resources(RESOURCES ./resources/resources.qrc)
65-
else()
66-
qt5_add_resources(RESOURCES ./resources/resources.qrc)
67-
endif()
68-
69-
# Unfortunately, as we have a split include/src, AUTOMOC doesn't work.
70-
# We'll have to manually specify some files
71-
set(CMAKE_AUTOMOC ON)
72-
7363
set(CPP_SOURCE_FILES
7464
src/AbstractGraphModel.cpp
7565
src/AbstractNodeGeometry.cpp
@@ -95,6 +85,7 @@ set(CPP_SOURCE_FILES
9585
src/StyleCollection.cpp
9686
src/UndoCommands.cpp
9787
src/locateNode.cpp
88+
resources/resources.qrc
9889
)
9990

10091
set(HPP_HEADER_FILES
@@ -141,7 +132,6 @@ set(HPP_HEADER_FILES
141132
add_library(QtNodes
142133
${CPP_SOURCE_FILES}
143134
${HPP_HEADER_FILES}
144-
${RESOURCES}
145135
)
146136

147137
add_library(QtNodes::QtNodes ALIAS QtNodes)
@@ -204,24 +194,8 @@ set_target_properties(QtNodes
204194
######
205195
# Moc
206196
##
197+
set_target_properties(QtNodes PROPERTIES AUTOMOC ON AUTORCC ON)
207198

208-
file(GLOB_RECURSE HEADERS_TO_MOC include/QtNodes/internal/*.hpp)
209-
210-
if (${QT_VERSION_MAJOR} EQUAL 6)
211-
qt_wrap_cpp(nodes_moc
212-
${HEADERS_TO_MOC}
213-
TARGET QtNodes
214-
OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp
215-
)
216-
else()
217-
qt5_wrap_cpp(nodes_moc
218-
${HEADERS_TO_MOC}
219-
TARGET QtNodes
220-
OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp
221-
)
222-
endif()
223-
224-
target_sources(QtNodes PRIVATE ${nodes_moc})
225199

226200
###########
227201
# Examples

0 commit comments

Comments
 (0)