Skip to content

Commit 4a36f73

Browse files
jcfrjamesobutler
authored andcommitted
cmake: Simplify build-system leveraging AUTOMOC capability
1 parent 83a47ab commit 4a36f73

1 file changed

Lines changed: 11 additions & 37 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ foreach(qt_component ${qt_required_components})
133133
list(APPEND QT_LIBRARIES Qt5::${qt_component})
134134
endforeach()
135135

136-
macro(pythonqt_wrap_cpp)
137-
qt5_wrap_cpp(${ARGV})
138-
endmacro()
139-
140136
if(UNIX)
141137
find_package(OpenGL)
142138
if(OPENGL_FOUND)
@@ -222,19 +218,6 @@ set(headers
222218
generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h
223219
)
224220

225-
#-----------------------------------------------------------------------------
226-
# Headers that should run through moc
227-
228-
set(moc_sources
229-
src/PythonQt.h
230-
src/PythonQtSignalReceiver.h
231-
src/PythonQtStdDecorators.h
232-
src/gui/PythonQtScriptingConsole.h
233-
234-
generated_cpp${generated_cpp_suffix}/com_trolltech_qt_core_builtin/com_trolltech_qt_core_builtin0.h
235-
generated_cpp${generated_cpp_suffix}/com_trolltech_qt_gui_builtin/com_trolltech_qt_gui_builtin0.h
236-
)
237-
238221
#-----------------------------------------------------------------------------
239222
# Add extra sources
240223

@@ -255,11 +238,6 @@ foreach(qtlib ${qtlibs})
255238
list(APPEND sources ${file_prefix}${index}.cpp)
256239
endif()
257240

258-
# Headers that should run through moc
259-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file_prefix}${index}.h)
260-
list(APPEND moc_sources ${file_prefix}${index}.h)
261-
endif()
262-
263241
endforeach()
264242

265243
list(APPEND sources ${file_prefix}_init.cpp)
@@ -284,19 +262,17 @@ list(APPEND headers
284262
${CMAKE_CURRENT_BINARY_DIR}/src/PythonQtConfigure.h
285263
)
286264

287-
#-----------------------------------------------------------------------------
288-
# Do wrapping
289-
pythonqt_wrap_cpp(gen_moc_sources ${moc_sources})
290-
291265
#-----------------------------------------------------------------------------
292266
# Build the library
293267

294-
add_library(PythonQt SHARED
295-
${sources}
296-
${gen_moc_sources}
297-
)
268+
add_library(PythonQt SHARED ${sources})
298269
set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)
299270

271+
set_target_properties(PythonQt
272+
PROPERTIES
273+
AUTOMOC TRUE
274+
)
275+
300276
target_compile_definitions(PythonQt
301277
PRIVATE
302278
$<$<BOOL:${PythonQt_DEBUG}>:PYTHONQT_DEBUG>
@@ -352,18 +328,11 @@ if(BUILD_TESTING)
352328
tests/PythonQtTests.h
353329
)
354330

355-
pythonqt_wrap_cpp(test_sources
356-
tests/PythonQtTests.h
357-
)
358-
359331
if(PythonQt_Wrap_QtCore)
360332
list(APPEND test_sources
361333
tests/PythonQtTestCleanup.cpp
362334
tests/PythonQtTestCleanup.h
363335
)
364-
pythonqt_wrap_cpp(test_sources
365-
tests/PythonQtTestCleanup.h
366-
)
367336

368337
set_property(SOURCE tests/PythonQtTestMain.cpp APPEND PROPERTY COMPILE_DEFINITIONS "PythonQt_Wrap_QtCore")
369338
endif()
@@ -377,6 +346,11 @@ if(BUILD_TESTING)
377346

378347
target_link_libraries(PythonQtCppTests PythonQt)
379348

349+
set_target_properties(PythonQtCppTests
350+
PROPERTIES
351+
AUTOMOC TRUE
352+
)
353+
380354
target_compile_definitions(PythonQtCppTests
381355
PRIVATE
382356
$<$<BOOL:${PythonQt_SUPPORT_NAME_PROPERTY}>:PYTHONQT_SUPPORT_NAME_PROPERTY>

0 commit comments

Comments
 (0)