Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove apple sdk path from include dirs #1577

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ set(VISP_REVISION "1")

# Try to locate visp-images and, if it exists, its version
vp_find_dataset(VISP_DATASET_FOUND VISP_DATASET_LOCATION
VISP_DATASET_VERSION
VISP_DATASET_VERSION_MAJOR
VISP_DATASET_VERSION_MINOR
VISP_DATASET_VERSION_PATCH)
VISP_DATASET_VERSION
VISP_DATASET_VERSION_MAJOR
VISP_DATASET_VERSION_MINOR
VISP_DATASET_VERSION_PATCH)

#-----------------------------------------------------------------------------
# TO BE CHECKED BEFORE NEXT RELEASE
Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ if(MSVC)
endif()
endif()

visp_add_subdirectory(calibration REQUIRED_DEPS visp_core visp_vision visp_io)
visp_add_subdirectory(calibration REQUIRED_DEPS visp_core visp_gui visp_io visp_robot visp_sensor visp_vision )
22 changes: 1 addition & 21 deletions cmake/VISPGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,10 @@
#
#############################################################################

# Macro that returns the relative path to go from a child folder to the parent folder
# input: path_to_child
# output: path_to_parent, the relative path to go from path_to_child to parent
# example: if input =lib/x86_64-linux-gnu, then output=../..
macro(get_path_to_parent path_to_child path_to_parent)
if(IS_ABSOLUTE ${path_to_child})
file(RELATIVE_PATH _path_to_parent "${path_to_child}" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" ${path_to_parent} "${_path_to_parent}")
else()
set(${path_to_parent} "")
set(input_ "${path_to_child}")
while(input_)
if(input_)
set(${path_to_parent} "${${path_to_parent}}../")
endif()
get_filename_component(input_ "${input_}" PATH)
endwhile(input_)
endif()
endmacro()

# Here we determine the relative path from ./${VISP_LIB_INSTALL_PATH} to its parent folder
# if VISP_LIB_INSTALL_PATH=lib, then VISP_INSTALL_LIBDIR_TO_PARENT=../
# if VISP_LIB_INSTALL_PATH=lib/x86_64-linux-gnu, then VISP_INSTALL_LIBDIR_TO_PARENT=../..
get_path_to_parent(${VISP_LIB_INSTALL_PATH} VISP_INSTALL_LIBDIR_TO_PARENT)
vp_get_path_to_parent(${VISP_LIB_INSTALL_PATH} VISP_INSTALL_LIBDIR_TO_PARENT)

#build list of modules available for the ViSP user
set(VISP_LIB_COMPONENTS "")
Expand Down
19 changes: 11 additions & 8 deletions cmake/VISPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@ endfunction()
macro(vp_target_include_modules target)
set(is_system "")
set(is_private "")
vp_get_apple_sdk_dir(apple_sdk_dir)
foreach(d ${ARGN})

if("${d}" STREQUAL "SYSTEM")
set(is_system "SYSTEM")
elseif("${d}" STREQUAL "PRIVATE")
Expand All @@ -600,13 +602,16 @@ macro(vp_target_include_modules target)
vp_target_include_directories(${target} "${VISP_MODULE_${d}_LOCATION}/include")
endif()
elseif(EXISTS "${d}")
# FS keep external deps inc
if(is_system)
set(VISP_MODULE_${the_module}_SYSTEM_INC_DEPS "${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS};${d}" CACHE INTERNAL "")
elseif(NOT is_private)
set(VISP_MODULE_${the_module}_INC_DEPS "${VISP_MODULE_${the_module}_INC_DEPS};${d}" CACHE INTERNAL "")
vp_string_starts_with(${d} ${apple_sdk_dir} apple_sdk_dir_found)
if (NOT apple_sdk_dir_found)
# FS keep external deps inc
if(is_system)
set(VISP_MODULE_${the_module}_SYSTEM_INC_DEPS "${VISP_MODULE_${the_module}_SYSTEM_INC_DEPS};${d}" CACHE INTERNAL "")
elseif(NOT is_private)
set(VISP_MODULE_${the_module}_INC_DEPS "${VISP_MODULE_${the_module}_INC_DEPS};${d}" CACHE INTERNAL "")
endif()
vp_target_include_directories(${target} "${is_system}" "${d}")
endif()
vp_target_include_directories(${target} "${is_system}" "${d}")
endif()
endforeach()
vp_list_unique(VISP_MODULE_${the_module}_INC_DEPS)
Expand Down Expand Up @@ -901,10 +906,8 @@ macro(_vp_create_module)
endforeach()
endif()
endforeach()

endmacro()


# short command for adding simple ViSP module
# see vp_add_module for argument details
# Usage:
Expand Down
91 changes: 81 additions & 10 deletions cmake/VISPUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,24 @@ function(vp_target_include_directories target)
set(__params "")
set(__system_params "")
set(__var_name __params)
vp_get_apple_sdk_dir(apple_sdk_dir)

foreach(dir ${ARGN})
if("${dir}" STREQUAL "SYSTEM")
set(__var_name __system_params)
set(__var_name __system_params)
else()
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
string(REPLACE "+" "\\+" __VISP_BINARY_DIR_filtered ${VISP_BINARY_DIR})
# if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") # not compatible with cmake 2.8.12.2
if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}")
list(APPEND ${__var_name} "${__abs_dir}")
elseif("${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}")
list(APPEND ${__var_name} "${__abs_dir}")
else()
list(APPEND ${__var_name} "${dir}")
vp_string_starts_with(${dir} ${apple_sdk_dir} apple_sdk_dir_found)
if (NOT apple_sdk_dir_found)
get_filename_component(__abs_dir "${dir}" ABSOLUTE)
string(REPLACE "+" "\\+" __VISP_BINARY_DIR_filtered ${VISP_BINARY_DIR})
# if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}") # not compatible with cmake 2.8.12.2
if("${__abs_dir}" MATCHES "^${VISP_SOURCE_DIR}")
list(APPEND ${__var_name} "${__abs_dir}")
elseif("${__abs_dir}" MATCHES "^${__VISP_BINARY_DIR_filtered}")
list(APPEND ${__var_name} "${__abs_dir}")
else()
list(APPEND ${__var_name} "${dir}")
endif()
endif()
endif()
endforeach()
Expand Down Expand Up @@ -794,11 +798,13 @@ endfunction()
function(_vp_append_target_includes target)
# Only defined for visp_<module> targets
if(DEFINED VP_TARGET_INCLUDE_DIRS_${target})
vp_list_unique(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})
vp_list_unique(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)
endif()
Expand Down Expand Up @@ -2056,3 +2062,68 @@ macro(vp_git_describe var_name path)
set(${var_name} "unknown")
endif()
endmacro()

# Macro that returns the relative path to go from a child folder to the parent folder
# input: path_to_child
# output: path_to_parent, the relative path to go from path_to_child to parent
# example: if input =lib/x86_64-linux-gnu, then output=../..
macro(vp_get_path_to_parent path_to_child path_to_parent)
if(IS_ABSOLUTE ${path_to_child})
file(RELATIVE_PATH _path_to_parent "${path_to_child}" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" ${path_to_parent} "${_path_to_parent}")
else()
set(${path_to_parent} "")
set(input_ "${path_to_child}")
while(input_)
if(input_)
set(${path_to_parent} "${${path_to_parent}}../")
endif()
get_filename_component(input_ "${input_}" PATH)
endwhile(input_)
endif()
endmacro()

# Compares two strings.
# Set "found" to TRUE when "str" string starts with "search" string.
# - str [in]: Input string to analyze
# - search [in]: Input string to search at the beginning or "str"
# - found [output]: TRUE if "str" starts with "search" string
function(vp_string_starts_with str search found)
set(_found FALSE)
string(FIND "${str}" "${search}" out)
if("${out}" EQUAL 0)
set(_found TRUE)
endif()
set(${found} "${_found}" CACHE INTERNAL "")
endfunction()

# Get the value of the command "xcrun --show-sdk-path".
# Useful only on APPLE arch
# - sdk_dir [out]: value of "xcrun --show-sdk-path"
macro(vp_get_apple_sdk_dir sdk_dir)
if(APPLE)
execute_process(COMMAND xcrun --show-sdk-path
OUTPUT_VARIABLE SDK_PLATFORM_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(${sdk_dir} "${SDK_PLATFORM_PATH}" REALPATH)
else()
set(${sdk_dir} "NotApple")
endif()
endmacro()

# Remove BUILD_INTERFACE from __include_dirs
# IN/OUT: __include_dirs
#
# If __include_dirs contains "$<BUILD_INTERFACE:/home/VTK/install/include/vtk-9.3>" as input,
# it will be filtered as output to /home/VTK/install/include/vtk-9.3
macro(vp_filter_build_interface __include_dirs)
if(${__include_dirs})
set(__include_dirs_filtered)
foreach(inc_ ${${__include_dirs}})
string(REGEX REPLACE "\\$<BUILD_INTERFACE:" "" inc_ ${inc_})
string(REGEX REPLACE ">" "" inc_ ${inc_})
list(APPEND __include_dirs_filtered ${inc_})
endforeach()

set(${__include_dirs} ${__include_dirs_filtered})
endif()
endmacro()
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ visp_add_subdirectory(homography REQUIRED_DEPS visp_core visp_visi
visp_add_subdirectory(image REQUIRED_DEPS visp_core visp_io)
visp_add_subdirectory(kalman REQUIRED_DEPS visp_core visp_gui)
visp_add_subdirectory(manual REQUIRED_DEPS visp_core visp_sensor visp_vs visp_robot visp_ar visp_vision visp_io visp_gui)
visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_io)
visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_gui visp_io)
visp_add_subdirectory(moments/image REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
visp_add_subdirectory(moments/points REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
visp_add_subdirectory(moments/polygon REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
Expand Down
Loading