From 06f724318a93958d21c7eab413781ebfc45f57cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nehil=20Dan=C4=B1=C5=9F?= Date: Thu, 17 Aug 2023 17:26:46 +0200 Subject: [PATCH] ADDED: a check for cmake version (#203) * ADDED: a check for cmake version * Reuse a bit the code and add a comment --------- Co-authored-by: Ignacio Vizzo --- cpp/kiss_icp/3rdparty/eigen/eigen.cmake | 15 +++++++++------ cpp/kiss_icp/3rdparty/tbb/tbb.cmake | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake index 7de1864b..c17460e7 100644 --- a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake +++ b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake @@ -35,10 +35,13 @@ include(FetchContent) FetchContent_Declare(eigen URL https://github.com/nachovizzo/eigen/archive/refs/tags/3.4.90.tar.gz) if(NOT eigen_POPULATED) FetchContent_Populate(eigen) - add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) -endif() - -if(${CMAKE_VERSION} VERSION_LESS 3.25) - get_target_property(eigen_include_dirs eigen INTERFACE_INCLUDE_DIRECTORIES) - set_target_properties(eigen PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${eigen_include_dirs}") + if(${CMAKE_VERSION} GREATER_EQUAL 3.25) + add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) + else() + # Emulate the SYSTEM flag introduced in CMake 3.25. Withouth this flag the compiler will + # consider this 3rdparty headers as source code and fail due the -Werror flag. + add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} EXCLUDE_FROM_ALL) + get_target_property(eigen_include_dirs eigen INTERFACE_INCLUDE_DIRECTORIES) + set_target_properties(eigen PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${eigen_include_dirs}") + endif() endif() diff --git a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake index 576bfc64..64482ceb 100644 --- a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake +++ b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake @@ -31,10 +31,13 @@ include(FetchContent) FetchContent_Declare(tbb URL https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.8.0.tar.gz) if(NOT tbb_POPULATED) FetchContent_Populate(tbb) - add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) -endif() - -if(${CMAKE_VERSION} VERSION_LESS 3.25) - get_target_property(tbb_include_dirs tbb INTERFACE_INCLUDE_DIRECTORIES) - set_target_properties(tbb PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${tbb_include_dirs}") + if(${CMAKE_VERSION} GREATER_EQUAL 3.25) + add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) + else() + # Emulate the SYSTEM flag introduced in CMake 3.25. Withouth this flag the compiler will + # consider this 3rdparty headers as source code and fail due the -Werror flag. + add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} EXCLUDE_FROM_ALL) + get_target_property(tbb_include_dirs tbb INTERFACE_INCLUDE_DIRECTORIES) + set_target_properties(tbb PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${tbb_include_dirs}") + endif() endif()