@@ -152,9 +152,6 @@ foreach(qtlib ${qt_required_components})
152152 list (APPEND QT_LIBRARIES ${Qt5${qtlib} _LIBRARIES})
153153endforeach ()
154154
155- # Required for use of "QtCore/private/qmetaobjectbuilder_p.h" in "PythonQt.cpp"
156- include_directories (${Qt5Core_PRIVATE_INCLUDE_DIRS} )
157-
158155macro (pythonqt_wrap_cpp )
159156 qt5_wrap_cpp (${ARGV} )
160157endmacro ()
@@ -306,10 +303,6 @@ pythonqt_wrap_cpp(gen_moc_sources ${moc_sources})
306303#-----------------------------------------------------------------------------
307304# Build the library
308305
309- include_directories (
310- ${CMAKE_CURRENT_SOURCE_DIR} /src
311- )
312-
313306add_library (PythonQt SHARED
314307 ${sources}
315308 ${gen_moc_sources}
@@ -327,6 +320,15 @@ target_compile_options(PythonQt PRIVATE
327320 $<$<CXX_COMPILER_ID :MSVC >:/bigobj >
328321 )
329322
323+ target_include_directories (PythonQt
324+ PUBLIC
325+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /src >
326+ $<INSTALL_INTERFACE :${PythonQt_INSTALL_INCLUDE_DIR} >
327+ PRIVATE
328+ # Required for use of "QtCore/private/qmetaobjectbuilder_p.h" in "PythonQt.cpp"
329+ ${Qt5Core_PRIVATE_INCLUDE_DIRS}
330+ )
331+
330332target_link_libraries (PythonQt
331333 ${PYTHON_LIBRARY}
332334 ${QT_LIBRARIES}
@@ -364,8 +366,6 @@ if(BUILD_TESTING)
364366 )
365367
366368 if (PythonQt_Wrap_QtCore)
367- include_directories (generated_cpp${generated_cpp_suffix} )
368-
369369 list (APPEND test_sources
370370 tests/PythonQtTestCleanup.cpp
371371 tests/PythonQtTestCleanup.h
@@ -374,10 +374,16 @@ if(BUILD_TESTING)
374374 tests/PythonQtTestCleanup.h
375375 )
376376
377- set_property (SOURCE tests/PythonQtTestMain.cpp APPEND PROPERTY COMPILE_DEFINITIONS "PythonQt_Wrap_Qtcore " )
377+ set_property (SOURCE tests/PythonQtTestMain.cpp APPEND PROPERTY COMPILE_DEFINITIONS "PythonQt_Wrap_QtCore " )
378378 endif ()
379379
380380 add_executable (PythonQtCppTests ${test_sources} )
381+
382+ target_include_directories (PythonQtCppTests
383+ PRIVATE
384+ $<$<BOOL :${PythonQt_Wrap_QtCore} >:${CMAKE_CURRENT_SOURCE_DIR} /generated_cpp ${generated_cpp_suffix} >
385+ )
386+
381387 target_link_libraries (PythonQtCppTests PythonQt )
382388
383389 target_compile_definitions (PythonQtCppTests
0 commit comments