From 3c03e668c3ad24a337bb10fca68bf39da3ac7fda Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Sun, 14 May 2023 12:30:43 +0200
Subject: [PATCH] use CMake for EXAMPLE_ROBOT_DATA_MODEL_DIR

---
 CMakeLists.txt                            | 5 +++++
 include/example-robot-data/CMakeLists.txt | 1 -
 include/example-robot-data/path.hpp       | 9 +++++++++
 include/example-robot-data/path.hpp.in    | 6 ------
 4 files changed, 14 insertions(+), 7 deletions(-)
 create mode 100644 include/example-robot-data/path.hpp
 delete mode 100644 include/example-robot-data/path.hpp.in

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e10c0ea..c84b1b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,11 @@ if(NOT INSTALL_PYTHON_INTERFACE_ONLY)
   add_library(${PROJECT_NAME} INTERFACE)
   target_include_directories(${PROJECT_NAME}
                              INTERFACE $<INSTALL_INTERFACE:include>)
+  target_compile_definitions(
+    ${PROJECT_NAME}
+    INTERFACE
+      EXAMPLE_ROBOT_DATA_MODEL_DIR="$<INSTALL_PREFIX>/share/${PROJECT_NAME}/robots"
+  )
   install(
     TARGETS ${PROJECT_NAME}
     EXPORT ${TARGETS_EXPORT_NAME}
diff --git a/include/example-robot-data/CMakeLists.txt b/include/example-robot-data/CMakeLists.txt
index c5c4185..aec0656 100644
--- a/include/example-robot-data/CMakeLists.txt
+++ b/include/example-robot-data/CMakeLists.txt
@@ -1,3 +1,2 @@
-configure_file(path.hpp.in path.hpp)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/path.hpp
         DESTINATION include/${CUSTOM_HEADER_DIR})
diff --git a/include/example-robot-data/path.hpp b/include/example-robot-data/path.hpp
new file mode 100644
index 0000000..14c0b31
--- /dev/null
+++ b/include/example-robot-data/path.hpp
@@ -0,0 +1,9 @@
+#ifndef EXAMPLE_ROBOT_DATA_PATH_HPP
+#define EXAMPLE_ROBOT_DATA_PATH_HPP
+
+#include <example-robot-data/warning.hh>
+
+#pragma message EXAMPLE_ROBOT_DATA_WARN( \
+        "Header `example-robot-data/path.hpp` is deprecated and useless!")
+
+#endif
diff --git a/include/example-robot-data/path.hpp.in b/include/example-robot-data/path.hpp.in
deleted file mode 100644
index 4788304..0000000
--- a/include/example-robot-data/path.hpp.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef EXAMPLE_ROBOT_DATA_PATH_HPP
-#define EXAMPLE_ROBOT_DATA_PATH_HPP
-
-#define EXAMPLE_ROBOT_DATA_MODEL_DIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/robots"
-
-#endif
-- 
GitLab