Skip to content

Commit

Permalink
Properly ensure that all header files are passed through moc and that…
Browse files Browse the repository at this point in the history
… moc_sources are added to each compilation target.
  • Loading branch information
s-daveb committed May 2, 2024
1 parent 95b76b3 commit f43c729
Show file tree
Hide file tree
Showing 4 changed files with 659 additions and 739 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ set(QJsonModel_PUBLIC_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)

add_custom_target(QJsonModel_include_files COMMAND ${CMAKE_COMMAND} -E copy_directory ${QJsonModel_TOP_SOURCE_DIR}/include ${QJsonModel_PUBLIC_INCLUDE_DIR}
DEPENDS ${QJsonModel_TOP_SOURCE_DIR}/include
COMMENT "Copying include files to ${IOCore_PUBLIC_INCLUDE_DIR}"
COMMENT "Copying include files to ${QJsonModel_PUBLIC_INCLUDE_DIR}"
)

target_include_directories(QJsonModel
Expand All @@ -87,13 +87,15 @@ PUBLIC ${QJsonModel_PUBLIC_INCLUDE_DIR}
add_dependencies(QJsonModel QJsonModel_include_files)

# Manually call moc on all header files
file(GLOB Qt6JsonModel_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)
qt_wrap_cpp(Qt6JsonModel_MOC_SOURCES ${Qt6JsonModel_HEADER_FILES}
file(GLOB_RECURSE QJsonModel_HEADER_FILES
${QJsonModel_TOP_SOURCE_DIR}/include/**.hpp)

qt_wrap_cpp(QJsonModel_MOC_SOURCES ${QJsonModel_HEADER_FILES}
TARGET QJsonModel
)

# Append the MOC files to the source list
target_sources(QJsonModel PRIVATE ${Qt6JsonModel_MOC_SOURCES})
target_sources(QJsonModel PUBLIC ${QJsonModel_MOC_SOURCES})

add_library(QJsonModelStatic STATIC)
add_library(Qt6::QJsonModelStatic ALIAS QJsonModelStatic )
Expand Down
Loading

0 comments on commit f43c729

Please sign in to comment.