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)
-function(CHECK_TBB)
+macro(CHECK_TBB)
check_header(execution)
# TBBConfig only sets TBB_FOUND to FALSE
if(HAVE_EXECUTION)
set(CMAKE_REQUIRED_FLAGS -std=c++17)
check_compiles(HAVE_TBB "std::vector<char> 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()