| 1 |
From: Juhani Numminen <[email protected]> |
| 2 |
Date: Fri, 17 Jan 2020 17:45:45 +0200 |
| 3 |
Subject: Avoid-buildpath-in-installed-files |
| 4 |
|
| 5 |
Workaround to avoid build paths in exported cmake targets. |
| 6 |
--- |
| 7 |
dynamicEDT3D/CMakeLists.txt | 20 +++----------------- |
| 8 |
dynamicEDT3D/dynamicEDT3DConfig.cmake.in | 3 +++ |
| 9 |
dynamicEDT3D/src/CMakeLists.txt | 6 ++++-- |
| 10 |
octomap/CMakeLists.txt | 5 ----- |
| 11 |
octomap/src/CMakeLists.txt | 4 +++- |
| 12 |
octomap/src/math/CMakeLists.txt | 2 ++ |
| 13 |
octovis/CMakeLists.txt | 2 -- |
| 14 |
octovis/CMakeLists_src.txt | 6 ++++-- |
| 15 |
octovis/octovis-config.cmake.in | 3 +++ |
| 16 |
9 files changed, 22 insertions(+), 29 deletions(-) |
| 17 |
|
| 18 |
diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt |
| 19 |
index 7edfdde..8354de6 100644 |
| 20 |
--- a/dynamicEDT3D/CMakeLists.txt |
| 21 |
+++ b/dynamicEDT3D/CMakeLists.txt |
| 22 |
@@ -38,28 +38,14 @@ foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) |
| 23 |
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) |
| 24 |
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) |
| 25 |
|
| 26 |
-set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") |
| 27 |
-INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) |
| 28 |
- |
| 29 |
-LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) |
| 30 |
- |
| 31 |
# Installation |
| 32 |
|
| 33 |
set(INSTALL_TARGETS_DEFAULT_ARGS |
| 34 |
- RUNTIME DESTINATION bin |
| 35 |
- LIBRARY DESTINATION lib |
| 36 |
- ARCHIVE DESTINATION lib |
| 37 |
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 38 |
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 39 |
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 40 |
) |
| 41 |
|
| 42 |
-find_package(octomap REQUIRED |
| 43 |
- HINTS ${CMAKE_SOURCE_DIR}/lib/cmake/octomap |
| 44 |
- ${CMAKE_SOURCE_DIR}/../octomap/lib/cmake/octomap |
| 45 |
-) |
| 46 |
-MESSAGE(STATUS "Found octomap version: " ${octomap_VERSION}) |
| 47 |
-MESSAGE(STATUS "octomap libraries: ${OCTOMAP_LIBRARIES}") |
| 48 |
- |
| 49 |
-INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OCTOMAP_INCLUDE_DIRS}) |
| 50 |
- |
| 51 |
ADD_SUBDIRECTORY(src) |
| 52 |
|
| 53 |
|
| 54 |
diff --git a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in |
| 55 |
index c8ffd88..89269ad 100644 |
| 56 |
--- a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in |
| 57 |
+++ b/dynamicEDT3D/dynamicEDT3DConfig.cmake.in |
| 58 |
@@ -18,6 +18,9 @@ |
| 59 |
|
| 60 |
@PACKAGE_INIT@ |
| 61 |
|
| 62 |
+include(CMakeFindDependencyMacro) |
| 63 |
+find_dependency(octomap @OCTOMAP_VERSION@) |
| 64 |
+ |
| 65 |
set(DYNAMICEDT3D_MAJOR_VERSION "@DYNAMICEDT3D_MAJOR_VERSION@") |
| 66 |
set(DYNAMICEDT3D_MINOR_VERSION "@DYNAMICEDT3D_MINOR_VERSION@") |
| 67 |
set(DYNAMICEDT3D_PATCH_VERSION "@DYNAMICEDT3D_PATCH_VERSION@") |
| 68 |
diff --git a/dynamicEDT3D/src/CMakeLists.txt b/dynamicEDT3D/src/CMakeLists.txt |
| 69 |
index 0b9357c..83b5e99 100644 |
| 70 |
--- a/dynamicEDT3D/src/CMakeLists.txt |
| 71 |
+++ b/dynamicEDT3D/src/CMakeLists.txt |
| 72 |
@@ -3,14 +3,16 @@ SET( dynamicEDT3D_SRCS |
| 73 |
) |
| 74 |
|
| 75 |
add_library(dynamicedt3d SHARED ${dynamicEDT3D_SRCS}) |
| 76 |
+target_include_directories(dynamicedt3d PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 77 |
set_target_properties(dynamicedt3d PROPERTIES |
| 78 |
VERSION ${DYNAMICEDT3D_VERSION} |
| 79 |
SOVERSION ${DYNAMICEDT3D_SOVERSION} |
| 80 |
) |
| 81 |
-target_link_libraries(dynamicedt3d ${OCTOMAP_LIBRARIES}) |
| 82 |
+target_link_libraries(dynamicedt3d octomap) |
| 83 |
|
| 84 |
add_library(dynamicedt3d-static STATIC ${dynamicEDT3D_SRCS}) |
| 85 |
-target_link_libraries(dynamicedt3d-static ${OCTOMAP_LIBRARIES}) |
| 86 |
+target_include_directories(dynamicedt3d-static PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 87 |
+target_link_libraries(dynamicedt3d-static octomap-static) |
| 88 |
|
| 89 |
SET_TARGET_PROPERTIES(dynamicedt3d-static PROPERTIES OUTPUT_NAME "dynamicedt3d") |
| 90 |
|
| 91 |
diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt |
| 92 |
index 87a78e9..63f1501 100644 |
| 93 |
--- a/octomap/CMakeLists.txt |
| 94 |
+++ b/octomap/CMakeLists.txt |
| 95 |
@@ -48,11 +48,6 @@ foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) |
| 96 |
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BASE_DIR}/bin ) |
| 97 |
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) |
| 98 |
|
| 99 |
-set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include") |
| 100 |
-INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) |
| 101 |
- |
| 102 |
-LINK_DIRECTORIES(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) |
| 103 |
- |
| 104 |
# Installation |
| 105 |
|
| 106 |
set(INSTALL_TARGETS_DEFAULT_ARGS |
| 107 |
diff --git a/octomap/src/CMakeLists.txt b/octomap/src/CMakeLists.txt |
| 108 |
index 45b384f..3ffca58 100644 |
| 109 |
--- a/octomap/src/CMakeLists.txt |
| 110 |
+++ b/octomap/src/CMakeLists.txt |
| 111 |
@@ -12,13 +12,15 @@ SET (octomap_SRCS |
| 112 |
|
| 113 |
# dynamic and static libs, see CMake FAQ: |
| 114 |
ADD_LIBRARY( octomap SHARED ${octomap_SRCS}) |
| 115 |
+target_include_directories(octomap PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE_DIR}>) |
| 116 |
set_target_properties( octomap PROPERTIES |
| 117 |
VERSION ${OCTOMAP_VERSION} |
| 118 |
SOVERSION ${OCTOMAP_SOVERSION} |
| 119 |
) |
| 120 |
ADD_LIBRARY( octomap-static STATIC ${octomap_SRCS}) |
| 121 |
+target_include_directories(octomap-static PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE_DIR}>) |
| 122 |
SET_TARGET_PROPERTIES(octomap-static PROPERTIES OUTPUT_NAME "octomap") |
| 123 |
-add_dependencies(octomap-static octomath-static) |
| 124 |
+TARGET_LINK_LIBRARIES(octomap-static octomath-static) |
| 125 |
|
| 126 |
TARGET_LINK_LIBRARIES(octomap octomath) |
| 127 |
|
| 128 |
diff --git a/octomap/src/math/CMakeLists.txt b/octomap/src/math/CMakeLists.txt |
| 129 |
index 3b47ec4..3edddf8 100644 |
| 130 |
--- a/octomap/src/math/CMakeLists.txt |
| 131 |
+++ b/octomap/src/math/CMakeLists.txt |
| 132 |
@@ -6,6 +6,7 @@ SET (octomath_SRCS |
| 133 |
|
| 134 |
|
| 135 |
ADD_LIBRARY( octomath SHARED ${octomath_SRCS}) |
| 136 |
+target_include_directories(octomath PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 137 |
|
| 138 |
SET_TARGET_PROPERTIES( octomath PROPERTIES |
| 139 |
VERSION ${OCTOMAP_VERSION} |
| 140 |
@@ -13,6 +14,7 @@ SET_TARGET_PROPERTIES( octomath PROPERTIES |
| 141 |
) |
| 142 |
|
| 143 |
ADD_LIBRARY( octomath-static STATIC ${octomath_SRCS}) |
| 144 |
+target_include_directories(octomath-static PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 145 |
SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath") |
| 146 |
|
| 147 |
if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap") |
| 148 |
diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt |
| 149 |
index 84fa367..ebddde2 100644 |
| 150 |
--- a/octovis/CMakeLists.txt |
| 151 |
+++ b/octovis/CMakeLists.txt |
| 152 |
@@ -49,8 +49,6 @@ ${CMAKE_SOURCE_DIR}/../octomap/lib/cmake/octomap |
| 153 |
) |
| 154 |
MESSAGE(STATUS "Found octomap version: " ${octomap_VERSION}) |
| 155 |
|
| 156 |
-INCLUDE_DIRECTORIES(BEFORE SYSTEM ${OCTOMAP_INCLUDE_DIRS}) |
| 157 |
- |
| 158 |
# Export the package for use from the build-tree |
| 159 |
# (this registers the build-tree with a global CMake-registry) |
| 160 |
export(PACKAGE octovis) |
| 161 |
diff --git a/octovis/CMakeLists_src.txt b/octovis/CMakeLists_src.txt |
| 162 |
index 35bc1f2..364ca95 100644 |
| 163 |
--- a/octovis/CMakeLists_src.txt |
| 164 |
+++ b/octovis/CMakeLists_src.txt |
| 165 |
@@ -100,19 +100,21 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}) |
| 166 |
|
| 167 |
# Library target |
| 168 |
add_library(octovis-static STATIC ${viewerlib_SRCS}) |
| 169 |
+target_include_directories(octovis-static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 170 |
target_link_libraries(octovis-static |
| 171 |
${OPENGL_gl_LIBRARY} |
| 172 |
${OPENGL_glu_LIBRARY} |
| 173 |
- ${OCTOMAP_LIBRARIES} |
| 174 |
+ octomap-static |
| 175 |
${QGLViewer_LIBRARIES} |
| 176 |
) |
| 177 |
set_target_properties(octovis-static PROPERTIES OUTPUT_NAME octovis) |
| 178 |
|
| 179 |
add_library(octovis-shared SHARED ${viewerlib_SRCS}) |
| 180 |
+target_include_directories(octovis-shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 181 |
target_link_libraries(octovis-shared |
| 182 |
${OPENGL_gl_LIBRARY} |
| 183 |
${OPENGL_glu_LIBRARY} |
| 184 |
- ${OCTOMAP_LIBRARIES} |
| 185 |
+ octomap |
| 186 |
${QGLViewer_LIBRARIES} |
| 187 |
) |
| 188 |
set_target_properties(octovis-shared PROPERTIES |
| 189 |
diff --git a/octovis/octovis-config.cmake.in b/octovis/octovis-config.cmake.in |
| 190 |
index 3add82e..8fced5a 100644 |
| 191 |
--- a/octovis/octovis-config.cmake.in |
| 192 |
+++ b/octovis/octovis-config.cmake.in |
| 193 |
@@ -9,6 +9,9 @@ |
| 194 |
|
| 195 |
@PACKAGE_INIT@ |
| 196 |
|
| 197 |
+include(CMakeFindDependencyMacro) |
| 198 |
+find_dependency(octomap @OCTOMAP_VERSION@) |
| 199 |
+ |
| 200 |
set(OCTOVIS_MAJOR_VERSION "@OCTOVIS_MAJOR_VERSION@") |
| 201 |
set(OCTOVIS_MINOR_VERSION "@OCTOVIS_MINOR_VERSION@") |
| 202 |
set(OCTOVIS_PATCH_VERSION "@OCTOVIS_PATCH_VERSION@") |