Skip to content

Commit

Permalink
Fix issues related to system include dir
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Sep 20, 2024
1 parent f4c5e13 commit 47c4a2d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cmake/VISPGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ if(UNIX)
set(VISP_INCLUDE_DIRS_CONFIGCMAKE "\${VISP_INSTALL_PATH}/${VISP_INC_INSTALL_PATH}")
foreach(m ${VISP_MODULES_BUILD})
list(APPEND VISP_INCLUDE_DIRS_CONFIGCMAKE ${VISP_MODULE_${m}_INC_DEPS})
list(APPEND VISP_INCLUDE_DIRS_CONFIGCMAKE ${VISP_MODULE_${m}_SYSTEM_INC_DEPS})
endforeach()
vp_list_unique(VISP_INCLUDE_DIRS_CONFIGCMAKE)
endif()
Expand All @@ -164,6 +165,7 @@ if(WIN32)
set(VISP_INCLUDE_DIRS_CONFIGCMAKE "\${VISP_CONFIG_PATH}/${VISP_INC_INSTALL_PATH}")
foreach(m ${VISP_MODULES_BUILD})
list(APPEND VISP_INCLUDE_DIRS_CONFIGCMAKE ${VISP_MODULE_${m}_INC_DEPS})
list(APPEND VISP_INCLUDE_DIRS_CONFIGCMAKE ${VISP_MODULE_${m}_SYSTEM_INC_DEPS})
endforeach()
vp_list_unique(VISP_INCLUDE_DIRS_CONFIGCMAKE)

Expand Down
25 changes: 18 additions & 7 deletions cmake/VISPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ foreach(mod ${VISP_MODULES_BUILD} ${VISP_MODULES_DISABLED_USER} ${VISP_MODULES_D
unset(VISP_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
unset(VISP_MODULE_${mod}_LINK_DEPS CACHE)
unset(VISP_MODULE_${mod}_INC_DEPS CACHE)
unset(VISP_MODULE_${mod}_SYSTEM_INC_DEPS CACHE)
unset(VISP_MODULE_${mod}_WRAPPERS CACHE)
endforeach()

Expand Down Expand Up @@ -179,6 +180,7 @@ macro(vp_add_module _name)

set(VISP_MODULE_${the_module}_LINK_DEPS "" CACHE INTERNAL "")
set(VISP_MODULE_${the_module}_INC_DEPS "" CACHE INTERNAL "")
set(VISP_MODULE_${the_module}_SYSTEM_INC_DEPS "" CACHE INTERNAL "")

# parse list of dependencies
if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
Expand Down Expand Up @@ -606,7 +608,6 @@ macro(vp_target_include_modules target)
endforeach()
vp_list_unique(VISP_MODULE_${the_module}_INC_DEPS)
vp_list_unique(VISP_MODULE_${the_module}_SYSTEM_INC_DEPS)

endmacro()

# setup include paths for the list of passed modules and recursively add dependent modules
Expand Down Expand Up @@ -836,12 +837,22 @@ macro(_vp_create_module)
target_compile_definitions(${the_module} PRIVATE visp_EXPORTS)
endif()

set_property(TARGET ${the_module} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${VISP_MODULE_${the_module}_INC_DEPS}
)
set_property(TARGET ${the_module} APPEND PROPERTY
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS}
)
#set_property(TARGET ${the_module} APPEND PROPERTY
# # Here we need also to add system include dirs, otherwise they are missing
# INTERFACE_INCLUDE_DIRECTORIES ${VISP_MODULE_${the_module}_INC_DEPS} ${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS}
#)
#set_property(TARGET ${the_module} APPEND PROPERTY
# INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS}
#)
set(inc "${VISP_MODULE_${the_module}_INC_DEPS};${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS}")
if(NOT (CMAKE_VERSION VERSION_LESS "3.11.0")) # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1264 : eliminates "Cannot specify compile definitions for imported target" error message
target_include_directories(${the_module} SYSTEM INTERFACE "$<BUILD_INTERFACE:${inc}>")
else()
set_target_properties(${the_module} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${inc}>"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${inc}>"
)
endif()

# For dynamic link numbering convenions
if(NOT ANDROID)
Expand Down
8 changes: 4 additions & 4 deletions cmake/VISPUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,10 @@ function(vp_target_include_directories target)
if(TARGET ${target})
target_include_directories(${target} SYSTEM PRIVATE ${__system_params})
else()
set(__new_inc ${VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}})
list(APPEND __new_inc ${__system_params})
set(__new_inc "${VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}};${__system_params}")
set(VP_TARGET_INCLUDE_SYSTEM_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
endif()
endif()

endfunction()

# clears all passed variables
Expand Down Expand Up @@ -794,10 +792,12 @@ function(vp_target_link_libraries target)
endfunction()

function(_vp_append_target_includes target)
# Only defined for visp_<module> targets
if(DEFINED VP_TARGET_INCLUDE_DIRS_${target})
target_include_directories(${target} PRIVATE ${VP_TARGET_INCLUDE_DIRS_${target}})
unset(VP_TARGET_INCLUDE_DIRS_${target} CACHE)
endif()
# Only defined for visp_<module> targets
if(DEFINED VP_TARGET_INCLUDE_SYSTEM_DIRS_${target})
target_include_directories(${target} SYSTEM PRIVATE ${VP_TARGET_INCLUDE_SYSTEM_DIRS_${target}})
unset(VP_TARGET_INCLUDE_SYSTEM_DIRS_${target} CACHE)
Expand Down Expand Up @@ -1643,7 +1643,7 @@ macro(vp_get_all_includes _includes_modules _includes_extra _system_include_dirs

foreach(m ${VISP_MODULES_BUILD})
list(APPEND ${_includes_extra} ${VISP_MODULE_${m}_INC_DEPS})
list(APPEND ${_system_include_dirs} ${VISP_MODULE_${m}_SYSTEM_INC_DEPS})
list(APPEND ${_includes_extra} ${VISP_MODULE_${m}_SYSTEM_INC_DEPS})

if(EXISTS "${VISP_MODULE_${m}_LOCATION}/include")
list(INSERT ${_includes_modules} 0 "${VISP_MODULE_${m}_LOCATION}/include")
Expand Down

0 comments on commit 47c4a2d

Please sign in to comment.