From 793e8734f5752c3cf8ef603ada6d50b49387cf14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nehil=20Dan=C4=B1=C5=9F?= Date: Sat, 12 Aug 2023 17:47:28 +0200 Subject: [PATCH 1/2] ADDED: a check for cmake version --- cpp/kiss_icp/3rdparty/eigen/eigen.cmake | 4 ++++ cpp/kiss_icp/3rdparty/tbb/tbb.cmake | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake index 7de1864b..24e3963c 100644 --- a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake +++ b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake @@ -35,7 +35,11 @@ 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) + if(${CMAKE_VERSION} VERSION_LESS 3.25) + add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} EXCLUDE_FROM_ALL) + else() add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) + endif() endif() if(${CMAKE_VERSION} VERSION_LESS 3.25) diff --git a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake index 576bfc64..8da17f97 100644 --- a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake +++ b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake @@ -31,7 +31,11 @@ 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) + if(${CMAKE_VERSION} VERSION_LESS 3.25) + add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} EXCLUDE_FROM_ALL) + else() + add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) + endif() endif() if(${CMAKE_VERSION} VERSION_LESS 3.25) From 722fae2fe76fa6e20c23ff3d190c079792ee32f1 Mon Sep 17 00:00:00 2001 From: Ignacio Vizzo Date: Thu, 17 Aug 2023 17:10:39 +0200 Subject: [PATCH 2/2] Reuse a bit the code and add a comment --- cpp/kiss_icp/3rdparty/eigen/eigen.cmake | 15 +++++++-------- cpp/kiss_icp/3rdparty/tbb/tbb.cmake | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake index 24e3963c..c17460e7 100644 --- a/cpp/kiss_icp/3rdparty/eigen/eigen.cmake +++ b/cpp/kiss_icp/3rdparty/eigen/eigen.cmake @@ -35,14 +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) - if(${CMAKE_VERSION} VERSION_LESS 3.25) - add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} EXCLUDE_FROM_ALL) + if(${CMAKE_VERSION} GREATER_EQUAL 3.25) + add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) else() - add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} SYSTEM EXCLUDE_FROM_ALL) + # 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() - -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}") -endif() diff --git a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake index 8da17f97..64482ceb 100644 --- a/cpp/kiss_icp/3rdparty/tbb/tbb.cmake +++ b/cpp/kiss_icp/3rdparty/tbb/tbb.cmake @@ -31,14 +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) - if(${CMAKE_VERSION} VERSION_LESS 3.25) - add_subdirectory(${tbb_SOURCE_DIR} ${tbb_BINARY_DIR} EXCLUDE_FROM_ALL) - else() + 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() - -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}") -endif()