Commit 98bd7629 authored by Simon Praetorius's avatar Simon Praetorius

Add backport of FindPkgConfig cmake module

Add Changelog entry reporting about the backported FindPkgConfig
parent f3ab4348
Pipeline #33458 passed with stage
in 8 minutes and 23 seconds
# Master (will become release 2.8)
- Add backport of `FindPkgConfig.cmake` from cmake 3.19.4 since there was a bug in
an older find module leading to problems finding tbb in debian:10.
- Update the FindTBB cmake module to search for the `TBBConfig.cmake` or the `tbb.pc`
file containing the configuration. Add the `AddTBBFlags.cmake` file containing
the macro `add_dune_tbb_flags` that must be called to use TBB.
......
add_subdirectory(FindPkgConfig)
add_subdirectory(FindPython3)
install(FILES
......
......@@ -139,6 +139,11 @@ enable_language(C) # Enable C to skip CXX bindings for some tests.
# find_package(Threads) everywhere
set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE BOOL "Prefer -pthread compiler and linker flag")
# Add a backport of cmakes FindPkgConfig module
if(${CMAKE_VERSION} VERSION_LESS "3.19.4")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/FindPkgConfig")
endif()
include(FeatureSummary)
include(DuneEnableAllPackages)
include(DuneTestMacros)
......
install(FILES
FindPkgConfig.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR}/FindPkgConfig)
\ No newline at end of file
This diff is collapsed.
......@@ -52,7 +52,7 @@ set_package_properties("TBB" PROPERTIES
# first, try to find TBBs cmake configuration
find_package(TBB ${TBB_FIND_VERSION} QUIET CONFIG)
if(TBB_FOUND)
if(TBB_tbb_FOUND)
message(STATUS "Found TBB: using configuration from TBB_DIR=${TBB_DIR} (found version \"${TBB_VERSION}\")")
return()
endif()
......@@ -61,28 +61,28 @@ endif()
find_package(PkgConfig)
if(PkgConfig_FOUND)
if(TBB_FIND_VERSION)
pkg_check_modules(_TBB tbb>=${TBB_FIND_VERSION} QUIET IMPORTED_TARGET)
pkg_check_modules(PkgConfigTBB tbb>=${TBB_FIND_VERSION} QUIET IMPORTED_TARGET GLOBAL)
else()
pkg_check_modules(_TBB tbb QUIET IMPORTED_TARGET)
pkg_check_modules(PkgConfigTBB tbb QUIET IMPORTED_TARGET GLOBAL)
endif()
endif()
# check whether the static library was found
if(_TBB_STATIC_FOUND)
set(_static _STATIC)
if(PkgConfigTBB_STATIC_FOUND)
set(_tbb PkgConfigTBB_STATIC)
else()
set(_tbb PkgConfigTBB)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("TBB"
REQUIRED_VARS
_TBB${_static}_FOUND PkgConfig_FOUND
${_tbb}_LINK_LIBRARIES ${_tbb}_FOUND PkgConfig_FOUND
VERSION_VAR
_TBB${_static}_VERSION
${_tbb}_VERSION
FAIL_MESSAGE "Could NOT find TBB (set TBB_DIR to path containing TBBConfig.cmake or set PKG_CONFIG_PATH to include the location of the tbb.pc file)"
)
# create an alias for the imported target constructed by pkg-config
if(TBB_FOUND AND NOT TARGET TBB::tbb)
message(STATUS "Found TBB: ${_TBB${_static}_LINK_LIBRARIES} (found version \"${_TBB${_static}_VERSION}\")")
add_library(TBB::tbb ALIAS PkgConfig::_TBB)
endif()
if(${_tbb}_FOUND AND NOT TARGET TBB::tbb)
add_library(TBB::tbb ALIAS PkgConfig::PkgConfigTBB)
endif()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment