From 60ad7d2bf26b36bc3762cb5d48a830d6cfb450c7 Mon Sep 17 00:00:00 2001
From: Joris Vaillant <joris.vaillant@inria.fr>
Date: Thu, 19 Sep 2024 15:15:58 +0200
Subject: [PATCH] cmake: Create hpp-fcl-compatibility component to allow to
 only install the compatibility layer

---
 .gitmodules           |  2 +-
 CMakeLists.txt        | 10 ++++++++--
 cmake                 |  2 +-
 hpp-fclConfig.cmake   |  5 ++++-
 python/CMakeLists.txt |  4 ++--
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/.gitmodules b/.gitmodules
index 0226cac4..c209f9f6 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
 [submodule "cmake"]
 	path = cmake
-	url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
+	url = https://github.com/jorisv/jrl-cmakemodules.git
 [submodule "third-parties/qhull"]
 	path = third-parties/qhull
 	url = https://github.com/qhull/qhull.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cbbbe84d..72f69ead 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -317,7 +317,7 @@ SET(${PROJECT_NAME}_HEADERS
   )
 
 if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
-  LIST(APPEND ${PROJECT_NAME}_HEADERS
+  SET(HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS
     include/hpp/fcl/broadphase/broadphase_bruteforce.h
     include/hpp/fcl/broadphase/broadphase_callbacks.h
     include/hpp/fcl/broadphase/broadphase_collision_manager.h
@@ -444,6 +444,8 @@ if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
     include/hpp/fcl/timings.h
     include/hpp/fcl/warning.hh
     )
+  LIST(APPEND ${PROJECT_NAME}_HEADERS ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
+  HEADER_INSTALL(COMPONENT hpp-fcl-compatibility ${HPP_FCL_BACKWARD_COMPATIBILITY_HEADERS})
 endif()
 
 IF(COAL_HAS_OCTOMAP)
@@ -485,7 +487,11 @@ if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
   write_basic_package_version_file(hpp-fclConfigVersion.cmake
       VERSION 3.0.0
       COMPATIBILITY AnyNewerVersion)
-  install(FILES hpp-fclConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/hpp-fclConfigVersion.cmake DESTINATION lib/cmake/hpp-fcl)
+  install(FILES hpp-fclConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/hpp-fclConfigVersion.cmake
+          DESTINATION lib/cmake/hpp-fcl
+          COMPONENT hpp-fcl-compatibility)
+  include("${JRL_CMAKE_MODULES}/install-helpers.cmake")
+  add_install_target(NAME hpp-fcl-compatibility COMPONENT hpp-fcl-compatibility)
 endif()
 
 setup_project_finalize()
diff --git a/cmake b/cmake
index 91b8f5f2..053b36a9 160000
--- a/cmake
+++ b/cmake
@@ -1 +1 @@
-Subproject commit 91b8f5f2168b123a198da079b8e6c09fd1f60285
+Subproject commit 053b36a9a584b5ce8baf363a63bdd494999962c7
diff --git a/hpp-fclConfig.cmake b/hpp-fclConfig.cmake
index c09ecf7f..326135bf 100644
--- a/hpp-fclConfig.cmake
+++ b/hpp-fclConfig.cmake
@@ -11,7 +11,10 @@ if(CMAKE_VERSION VERSION_LESS "3.18.0")
     get_property(_cfg TARGET coal::coal PROPERTY IMPORTED_CONFIGURATIONS)
     get_property(_loc TARGET coal::coal PROPERTY "IMPORTED_LOCATION_${_cfg}")
     set_property(TARGET hpp-fcl::hpp-fcl PROPERTY IMPORTED_LOCATION "${_loc}")
+    target_compile_definitions(hpp-fcl::hpp-fcl PUBLIC COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
   endif()
 else()
-  add_library(hpp-fcl::hpp-fcl ALIAS coal::coal)
+    add_library(hpp-fcl::hpp-fcl INTERFACE)
+    target_link_libraries(hpp-fcl::hpp-fcl INTERFACE coal::coal)
+    target_compile_definitions(hpp-fcl::hpp-fcl INTERFACE COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
 endif()
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index d28714c5..38b98031 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -191,6 +191,6 @@ ENDFOREACH(python)
 
 
 if(COAL_BACKWARD_COMPATIBILITY_WITH_HPP_FCL)
-  python_install_on_site(hppfcl __init__.py)
-  python_install_on_site(hppfcl viewer.py)
+  python_install_on_site(hppfcl __init__.py COMPONENT hpp-fcl-compatibility)
+  python_install_on_site(hppfcl viewer.py COMPONENT hpp-fcl-compatibility)
 endif()
-- 
GitLab