From 0f70cb649a9cfc0d48734f62ec576b8764de3d09 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Tue, 27 Dec 2022 14:18:44 -0300 Subject: [PATCH] Fix find_package(xsimd) for xtl enabled xsimd, reloaded PR #788 fixes xtl lookup by adding the corresponding find_dependency call. However, there are still two issues remaining: - If xtl is not found, the INTERFACE_LINK_LIBRARIES property will make CMake interpret "xtl" as a .lib, pass it as a -l flag, and cause the build to fail. - If xtl is used, the required definition XSIMD_ENABLE_XTL_COMPLEX=1 is never passsed to downstream consumers. This commit fixes both issues, ensuring that if xtl was required at compile time, the Config module with not load unless xtl is also found. Fixes #869 --- CMakeLists.txt | 2 +- xsimdConfig.cmake.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1eb84c38..7866fc6f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,8 +96,8 @@ OPTION(ENABLE_XTL_COMPLEX "enables support for xcomplex defined in xtl" OFF) OPTION(BUILD_TESTS "xsimd test suite" OFF) if(ENABLE_XTL_COMPLEX) - add_definitions(-DXSIMD_ENABLE_XTL_COMPLEX=1) find_package(xtl 0.7.0 REQUIRED) + target_compile_definitions(xsimd INTERFACE XSIMD_ENABLE_XTL_COMPLEX=1) target_link_libraries(xsimd INTERFACE xtl) endif() diff --git a/xsimdConfig.cmake.in b/xsimdConfig.cmake.in index cba17c83e..1c395450d 100644 --- a/xsimdConfig.cmake.in +++ b/xsimdConfig.cmake.in @@ -21,7 +21,7 @@ if(NOT TARGET @PROJECT_NAME@) set(@PROJECT_NAME@_ENABLE_XTL_COMPLEX @ENABLE_XTL_COMPLEX@) if(@PROJECT_NAME@_ENABLE_XTL_COMPLEX) include(CMakeFindDependencyMacro) - find_dependency(xtl) + find_dependency(xtl REQUIRED) endif() include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")