Support cmake version < 3.12 on the OBJECT type library cafCommandFeatures

This commit is contained in:
Jacob Støren
2019-09-02 13:39:48 +02:00
parent 4a50e5f4c6
commit 236b0cb3d4
3 changed files with 20 additions and 7 deletions
+3
View File
@@ -428,6 +428,9 @@ if (RESINSIGHT_INCLUDE_APPFWK_TESTS)
set_property(TARGET cafPdmXml_UnitTests PROPERTY FOLDER "AppFwkTests")
# Executables
add_subdirectory(Fwk/AppFwk/cafCommandFeatures)
set_property(TARGET cafCommandFeatures PROPERTY FOLDER "AppFwk")
add_subdirectory(Fwk/AppFwk/cafTests/cafTestApplication)
set_property(TARGET cafTestApplication PROPERTY FOLDER "AppFwkTests")
endif()
+15 -6
View File
@@ -74,14 +74,23 @@ add_library( ${PROJECT_NAME} OBJECT
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
$<TARGET_PROPERTY:cafCommand,INCLUDE_DIRECTORIES> # Needed for cmake version < 3.12. Remove when we can use target_link_libraries
$<TARGET_PROPERTY:cafUserInterface,INCLUDE_DIRECTORIES> # Needed for cmake version < 3.12. Remove when we can use target_link_libraries
)
target_link_libraries ( ${PROJECT_NAME}
cafCommand
cafUserInterface
${QT_LIBRARIES}
)
# Before cmake 3.12 OBJECT libraries could not use the target_link_libraries command,
# So we need to set the POSITION_INDEPENDENT_CODE option manually
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
# Not to be used until we can use cmake 3.12 or above
#target_link_libraries ( ${PROJECT_NAME}
# cafCommand
# cafUserInterface
# ${QT_LIBRARIES}
#)
if (MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127")
@@ -67,6 +67,7 @@ add_executable ( ${PROJECT_NAME}
${PROJECT_FILES}
${MOC_SOURCE_FILES}
${QRC_FILES_CPP}
$<TARGET_OBJECTS:cafCommandFeatures> # Needed for cmake version < 3.12. Remove when we can use target_link_libraries with OBJECT libraries
)
set (TAP_LINK_LIBRARIES
@@ -77,7 +78,7 @@ if (USE_COMMAND_FRAMEWORK)
set (TAP_LINK_LIBRARIES
${TAP_LINK_LIBRARIES}
cafCommand
cafCommandFeatures
#cafCommandFeatures # Not possible using cmake version < 3.12. Use when we can use target_link_libraries with OBJECT libraries
)
endif(USE_COMMAND_FRAMEWORK)