From: Michael Wallner Date: Mon, 2 Nov 2020 11:55:52 +0000 (+0100) Subject: cmake: fix tbb detection X-Git-Tag: 1.1.0-beta1~136 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a08ebebc7f7f2d86eb13151fb230cbfcd17dc090;p=awesomized%2Flibmemcached cmake: fix tbb detection --- diff --git a/CMake/CheckDependency.cmake b/CMake/CheckDependency.cmake index bb6fd7d0..f78390b4 100644 --- a/CMake/CheckDependency.cmake +++ b/CMake/CheckDependency.cmake @@ -3,51 +3,47 @@ find_package(PkgConfig) include(SafeString) include(CheckHeader) -function(check_dependency_basic NAME LIB HEADER) - set(FOUND 1) - message("-- Checking for library '${LIB}' with header '${HEADER}' ...") - find_library(LIB${LIB} NAMES ${LIB}) - if(NOT LIB${LIB}) - set(FOUND 0) - endif() - if(HEADER) - safe_string(${HEADER} HEADER_CONST) - check_header(${HEADER}) - if(NOT HAVE_${HEADER_CONST}) - set(FOUND 0) - else() - find_path(${HEADER_CONST}_ROOT ${HEADER}) - if(NOT ${HEADER_CONST}_ROOT) - set(FOUND 0) - endif() - endif() - endif() - if(FOUND) - message("-- Found library '${LIB${LIB}}'") - message("-- Found include '${${HEADER_CONST}_ROOT}'") - set(${NAME} ${NAME} PARENT_SCOPE) - add_library(${NAME} INTERFACE IMPORTED) - set_target_properties(${NAME} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${${HEADER_CONST}_ROOT} - INTERFACE_LINK_LIBRARIES ${LIB${LIB}}) - else() - message("-- No library '${LIB}' found") - endif() - set(${NAME}_FOUND ${FOUND} PARENT_SCOPE) -endfunction() - function(check_dependency NAME LIB HEADER) if(PKG_CONFIG_FOUND) pkg_check_modules(${NAME} lib${LIB}${ARGN} IMPORTED_TARGET) if(NOT ${NAME}_FOUND) - pkg_check_modules(${NAME} ${LIB}${ARGN}) + pkg_check_modules(${NAME} ${LIB}${ARGN} IMPORTED_TARGET) endif() if(${NAME}_FOUND) set(${NAME} PkgConfig::${NAME} PARENT_SCOPE) endif() endif() if(NOT ${NAME}_FOUND) - check_dependency_basic(${NAME} ${LIB} ${HEADER}) + set(FOUND 1) + message(STATUS "Checking for library '${LIB}' with header '${HEADER}' ...") + find_library(LIB${LIB} NAMES ${LIB}) + if(NOT LIB${LIB}) + set(FOUND 0) + endif() + if(HEADER) + safe_string(${HEADER} HEADER_CONST) + check_header(${HEADER}) + if(NOT HAVE_${HEADER_CONST}) + set(FOUND 0) + else() + find_path(${HEADER_CONST}_ROOT ${HEADER}) + if(NOT ${HEADER_CONST}_ROOT) + set(FOUND 0) + endif() + endif() + endif() + if(FOUND) + message(STATUS " Found library '${LIB${LIB}}'") + message(STATUS " Found include '${${HEADER_CONST}_ROOT}'") + set(${NAME} Imported::${NAME} PARENT_SCOPE) + add_library(Imported::${NAME} INTERFACE IMPORTED) + set_target_properties(Imported::${NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${${HEADER_CONST}_ROOT} + INTERFACE_LINK_LIBRARIES ${LIB${LIB}}) + else() + message("-- No library '${LIB}' found") + endif() + set(${NAME}_FOUND ${FOUND}) endif() set(HAVE_${NAME} ${${NAME}_FOUND} PARENT_SCOPE) diff --git a/CMake/CheckTbb.cmake b/CMake/CheckTbb.cmake index 11abb4ab..31a0de1d 100644 --- a/CMake/CheckTbb.cmake +++ b/CMake/CheckTbb.cmake @@ -1,4 +1,4 @@ -function(CHECK_TBB) +macro(CHECK_TBB) check_header(execution) # TBBConfig only sets TBB_FOUND to FALSE if(HAVE_EXECUTION) @@ -12,9 +12,6 @@ function(CHECK_TBB) set(CMAKE_REQUIRED_FLAGS -std=c++17) check_compiles(HAVE_TBB "std::vector a={1,2,3}; std::all_of(std::execution::par,a.begin(),a.end(),[](char i){return i>0;});" vector algorithm execution) cmake_pop_check_state(RESET) - if(HAVE_TBB) - set(HAVE_LIBTBB 1 PARENT_SCOPE) - endif() endif() endif() -endfunction() +endmacro() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 75fb187b..449223f0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,7 +30,6 @@ target_link_libraries(runtests PRIVATE libhashkit libmemcachedinternal libmemcac check_tbb() if(HAVE_TBB) - message("HAVE TBB") target_link_libraries(runtests PRIVATE ${LIBTBB}) endif()