Skip to content

Commit

Permalink
[FIXUP] cmake: Add workaround for https://gitlab.kitware.com/cmake/cm…
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed May 1, 2023
1 parent b2bea9f commit 5fc2cee
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cmake/module/CrossPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@

find_package(PkgConfig REQUIRED)

macro(cross_pkg_check_modules)
function(remove_isystem_from_include_directories_internal target)
get_target_property(include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES)
if(include_directories)
list(REMOVE_ITEM include_directories -isystem)
set_target_properties(${target} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_directories}")
endif()
endfunction()

macro(cross_pkg_check_modules prefix)
if(CMAKE_CROSSCOMPILING)
set(pkg_config_path_saved "$ENV{PKG_CONFIG_PATH}")
set(pkg_config_libdir_saved "$ENV{PKG_CONFIG_LIBDIR}")
set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_PATH})
set(ENV{PKG_CONFIG_LIBDIR} ${PKG_CONFIG_LIBDIR})
pkg_check_modules(${ARGV})
pkg_check_modules(${prefix} ${ARGN})
set(ENV{PKG_CONFIG_PATH} ${pkg_config_path_saved})
set(ENV{PKG_CONFIG_LIBDIR} ${pkg_config_libdir_saved})
else()
pkg_check_modules(${ARGV})
pkg_check_modules(${prefix} ${ARGN})
endif()

# A workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/20652.
if(CMAKE_VERSION VERSION_LESS 3.17.3 AND TARGET PkgConfig::${prefix})
remove_isystem_from_include_directories_internal(PkgConfig::${prefix})
endif()
endmacro()

0 comments on commit 5fc2cee

Please sign in to comment.