Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 1 | From cbf94fd62ff831879d10f99aa7766d391ae8a9b7 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Victor=20Matar=C3=A9?= <matare@fh-aachen.de> |
| 3 | Date: Tue, 31 Mar 2020 21:30:07 +0200 |
| 4 | Subject: [PATCH] use GNUInstallDirs where possible |
| 5 | |
| 6 | Emulate the CMAKE_INSTALL_FULL_* variables on non-Unix systems and |
| 7 | disable redefining FHS-mandated install locations via user-editable |
| 8 | ASSIMP_*_INSTALL_DIR variables. Instead, if it REALLY proves necessary, |
| 9 | Unix users can edit the advanced, canonical CMAKE_INSTALL_* variables. |
| 10 | --- |
| 11 | CMakeLists.txt | 36 ++++++++++++++++++++++------------ |
| 12 | assimp.pc.in | 6 ++---- |
| 13 | assimpTargets-debug.cmake.in | 20 +++++++++---------- |
| 14 | assimpTargets-release.cmake.in | 18 ++++++++--------- |
| 15 | assimpTargets.cmake.in | 15 +------------- |
| 16 | 5 files changed, 45 insertions(+), 50 deletions(-) |
| 17 | |
| 18 | Upstream-Status: Backport |
| 19 | Comment: Additionally remove setting of ASSIMP_LIBRARY_DIRS, ASSIMP_INCLUDE_DIRS |
| 20 | and INTERFACE_INCLUDE_DIRECTORIES as default cross compile paths are enough |
| 21 | and setting them manually adds non-existing paths to CMake modules |
| 22 | |
| 23 | Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com> |
| 24 | |
| 25 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 26 | index dcafb649f5..c23c0df33e 100644 |
| 27 | --- a/CMakeLists.txt |
| 28 | +++ b/CMakeLists.txt |
| 29 | @@ -230,11 +230,6 @@ SET(LIBASSIMP-DEV_COMPONENT "libassimp${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_M |
| 30 | SET(CPACK_COMPONENTS_ALL assimp-bin ${LIBASSIMP_COMPONENT} ${LIBASSIMP-DEV_COMPONENT} assimp-dev) |
| 31 | SET(ASSIMP_LIBRARY_SUFFIX "" CACHE STRING "Suffix to append to library names") |
| 32 | |
| 33 | -IF( UNIX ) |
| 34 | - # Use GNUInstallDirs for Unix predefined directories |
| 35 | - INCLUDE(GNUInstallDirs) |
| 36 | -ENDIF( UNIX ) |
| 37 | - |
| 38 | # Grouped compiler settings |
| 39 | IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) |
| 40 | IF(NOT HUNTER_ENABLED) |
| 41 | @@ -329,14 +324,6 @@ IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) |
| 42 | SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin" ) |
| 43 | ENDIF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) |
| 44 | |
| 45 | -# Cache these to allow the user to override them manually. |
| 46 | -SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING |
| 47 | - "Path the built library files are installed to." ) |
| 48 | -SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING |
| 49 | - "Path the header files are installed to." ) |
| 50 | -SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING |
| 51 | - "Path the tool executables are installed to." ) |
| 52 | - |
| 53 | get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG) |
| 54 | |
| 55 | IF (INJECT_DEBUG_POSTFIX AND (is_multi_config OR CMAKE_BUILD_TYPE STREQUAL "Debug")) |
| 56 | @@ -391,6 +378,29 @@ IF(HUNTER_ENABLED) |
| 57 | ) |
| 58 | ELSE(HUNTER_ENABLED) |
| 59 | # cmake configuration files |
| 60 | + |
| 61 | + IF( UNIX ) |
| 62 | + # Use GNUInstallDirs for Unix predefined directories |
| 63 | + INCLUDE(GNUInstallDirs) |
| 64 | + |
| 65 | + SET( ASSIMP_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) |
| 66 | + SET( ASSIMP_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) |
| 67 | + SET( ASSIMP_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) |
| 68 | + ELSE( UNIX ) |
| 69 | + # Cache these to allow the user to override them on non-Unix platforms |
| 70 | + SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING |
| 71 | + "Path the built library files are installed to." ) |
| 72 | + SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING |
| 73 | + "Path the header files are installed to." ) |
| 74 | + SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING |
| 75 | + "Path the tool executables are installed to." ) |
| 76 | + |
| 77 | + SET(CMAKE_INSTALL_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_INCLUDE_INSTALL_DIR}) |
| 78 | + SET(CMAKE_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}) |
| 79 | + SET(CMAKE_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${ASSIMP_BIN_INSTALL_DIR}) |
| 80 | + ENDIF( UNIX ) |
| 81 | + |
| 82 | + |
| 83 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" @ONLY IMMEDIATE) |
| 84 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/assimpTargets.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimpTargets.cmake" @ONLY IMMEDIATE) |
| 85 | IF (is_multi_config) |
| 86 | diff --git a/assimp.pc.in b/assimp.pc.in |
| 87 | index c659e19f2c..555a3a1d3b 100644 |
| 88 | --- a/assimp.pc.in |
| 89 | +++ b/assimp.pc.in |
| 90 | @@ -1,7 +1,5 @@ |
| 91 | -prefix=@CMAKE_INSTALL_PREFIX@ |
| 92 | -exec_prefix=@CMAKE_INSTALL_PREFIX@/ |
| 93 | -libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@ |
| 94 | -includedir=@CMAKE_INSTALL_PREFIX@/../include/@ASSIMP_INCLUDE_INSTALL_DIR@ |
| 95 | +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ |
| 96 | +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ |
| 97 | |
| 98 | Name: @CMAKE_PROJECT_NAME@ |
| 99 | Description: Import various well-known 3D model formats in an uniform manner. |
| 100 | diff --git a/assimpTargets-debug.cmake.in b/assimpTargets-debug.cmake.in |
| 101 | index 1ebe2a6081..f5034c9349 100644 |
| 102 | --- a/assimpTargets-debug.cmake.in |
| 103 | +++ b/assimpTargets-debug.cmake.in |
| 104 | @@ -42,22 +42,22 @@ if(MSVC) |
| 105 | # Import target "assimp::assimp" for configuration "Debug" |
| 106 | set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) |
| 107 | set_target_properties(assimp::assimp PROPERTIES |
| 108 | - IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/${importLibraryName}" |
| 109 | - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" |
| 110 | + IMPORTED_IMPLIB_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}" |
| 111 | + IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" |
| 112 | ) |
| 113 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 114 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") |
| 115 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) |
| 116 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}") |
| 117 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" ) |
| 118 | else() |
| 119 | set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") |
| 120 | |
| 121 | # Import target "assimp::assimp" for configuration "Debug" |
| 122 | set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) |
| 123 | set_target_properties(assimp::assimp PROPERTIES |
| 124 | - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" |
| 125 | + IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" |
| 126 | ) |
| 127 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 128 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") |
| 129 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}") |
| 130 | endif() |
| 131 | |
| 132 | else() |
| 133 | @@ -66,17 +66,17 @@ else() |
| 134 | set(sharedLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@.@ASSIMP_VERSION_MAJOR@") |
| 135 | set_target_properties(assimp::assimp PROPERTIES |
| 136 | IMPORTED_SONAME_DEBUG "${sharedLibraryName}" |
| 137 | - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" |
| 138 | + IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" |
| 139 | ) |
| 140 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 141 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) |
| 142 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" ) |
| 143 | else() |
| 144 | set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_DEBUG_POSTFIX@@CMAKE_STATIC_LIBRARY_SUFFIX@") |
| 145 | set_target_properties(assimp::assimp PROPERTIES |
| 146 | - IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/${staticLibraryName}" |
| 147 | + IMPORTED_LOCATION_DEBUG "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" |
| 148 | ) |
| 149 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 150 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) |
| 151 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" ) |
| 152 | endif() |
| 153 | endif() |
| 154 | |
| 155 | diff --git a/assimpTargets-release.cmake.in b/assimpTargets-release.cmake.in |
| 156 | index f3db8f12cd..a416e8899b 100644 |
| 157 | --- a/assimpTargets-release.cmake.in |
| 158 | +++ b/assimpTargets-release.cmake.in |
| 159 | @@ -42,12 +42,12 @@ if(MSVC) |
| 160 | # Import target "assimp::assimp" for configuration "Release" |
| 161 | set_property(TARGET assimp::assimp APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) |
| 162 | set_target_properties(assimp::assimp PROPERTIES |
| 163 | - IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}" |
| 164 | - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" |
| 165 | + IMPORTED_IMPLIB_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}" |
| 166 | + IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" |
| 167 | ) |
| 168 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 169 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${importLibraryName}") |
| 170 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/bin/${sharedLibraryName}" ) |
| 171 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}") |
| 172 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}" ) |
| 173 | else() |
| 174 | set(staticLibraryName "assimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") |
| 175 | |
| 176 | @@ -57,7 +57,7 @@ if(MSVC) |
| 177 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" |
| 178 | ) |
| 179 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 180 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}") |
| 181 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}") |
| 182 | endif() |
| 183 | |
| 184 | else() |
| 185 | @@ -70,17 +70,17 @@ else() |
| 186 | endif() |
| 187 | set_target_properties(assimp::assimp PROPERTIES |
| 188 | IMPORTED_SONAME_RELEASE "${sharedLibraryName}" |
| 189 | - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" |
| 190 | + IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" |
| 191 | ) |
| 192 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 193 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${sharedLibraryName}" ) |
| 194 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${sharedLibraryName}" ) |
| 195 | else() |
| 196 | set(staticLibraryName "libassimp${ASSIMP_LIBRARY_SUFFIX}@CMAKE_STATIC_LIBRARY_SUFFIX@") |
| 197 | set_target_properties(assimp::assimp PROPERTIES |
| 198 | - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/${staticLibraryName}" |
| 199 | + IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" |
| 200 | ) |
| 201 | list(APPEND _IMPORT_CHECK_TARGETS assimp::assimp ) |
| 202 | - list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "${_IMPORT_PREFIX}/lib/${staticLibraryName}" ) |
| 203 | + list(APPEND _IMPORT_CHECK_FILES_FOR_assimp::assimp "@CMAKE_INSTALL_FULL_LIBDIR@/${staticLibraryName}" ) |
| 204 | endif() |
| 205 | endif() |
| 206 | |
| 207 | @@ -91,8 +91,6 @@ get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH) |
| 208 | |
| 209 | set( ASSIMP_CXX_FLAGS ) # dynamically linked library |
| 210 | set( ASSIMP_LINK_FLAGS "" ) |
| 211 | -set( ASSIMP_LIBRARY_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_LIB_INSTALL_DIR@") |
| 212 | -set( ASSIMP_INCLUDE_DIRS "${ASSIMP_ROOT_DIR}/@ASSIMP_INCLUDE_INSTALL_DIR@") |
| 213 | if(ASSIMP_BUILD_SHARED_LIBS) |
| 214 | set( ASSIMP_LIBRARIES ${sharedLibraryName}) |
| 215 | else() |
| 216 | |
| 217 | diff --git a/assimpTargets.cmake.in b/assimpTargets.cmake.in |
| 218 | index ab1a8d2c7b..ef90c834a6 100644 |
| 219 | --- a/assimpTargets.cmake.in |
| 220 | +++ b/assimpTargets.cmake.in |
| 221 | @@ -40,16 +40,6 @@ unset(_targetsDefined) |
| 222 | unset(_targetsNotDefined) |
| 223 | unset(_expectedTargets) |
| 224 | |
| 225 | - |
| 226 | -# Compute the installation prefix relative to this file. |
| 227 | -get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) |
| 228 | -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 229 | -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 230 | -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) |
| 231 | -if(_IMPORT_PREFIX STREQUAL "/") |
| 232 | - set(_IMPORT_PREFIX "") |
| 233 | -endif() |
| 234 | - |
| 235 | # Create imported target assimp::assimp |
| 236 | if(@BUILD_SHARED_LIBS@) |
| 237 | add_library(assimp::assimp SHARED IMPORTED) |
| 238 | @@ -60,7 +50,7 @@ endif() |
| 239 | set_target_properties(assimp::assimp PROPERTIES |
| 240 | COMPATIBLE_INTERFACE_STRING "assimp_MAJOR_VERSION" |
| 241 | INTERFACE_assimp_MAJOR_VERSION "1" |
| 242 | - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include" |
| 243 | + #INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_FULL_INCLUDEDIR@" |
| 244 | #INTERFACE_LINK_LIBRARIES "TxtUtils::TxtUtils;MealyMachine::MealyMachine" |
| 245 | ) |
| 246 | |
| 247 | @@ -75,9 +65,6 @@ foreach(f ${CONFIG_FILES}) |
| 248 | include(${f}) |
| 249 | endforeach() |
| 250 | |
| 251 | -# Cleanup temporary variables. |
| 252 | -set(_IMPORT_PREFIX) |
| 253 | - |
| 254 | # Loop over all imported files and verify that they actually exist |
| 255 | foreach(target ${_IMPORT_CHECK_TARGETS} ) |
| 256 | foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) |
| 257 | |