1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <raphael@freexian.com>
Date: Thu, 20 Mar 2025 21:25:40 +0100
Subject: Hardcode installation prefix in cmake scripts
The upstream cmake scripts rely on analyzing the installation path of
the files and consider that the upstream prefix is the directory 3
layers above. But that's not correct with
/usr/lib/x86_64-linux-gnu/CppUTest/cmake/*.cmake where you need to strip
4 layers.
So it tries to use /usr/lib/include instead of /usr/include and fails.
Instead of this bad guess, we just hardcode the path that we are using
in Debian.
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1099339
Bug: https://github.com/cpputest/cpputest/issues/1563
---
build/cmake_package_files/CppUTestConfig.cmake | 4 +---
build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake | 8 ++++----
build/cmake_package_files/CppUTestTargets.cmake | 10 +++-------
3 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/build/cmake_package_files/CppUTestConfig.cmake b/build/cmake_package_files/CppUTestConfig.cmake
index cce1985..ba54dac 100644
--- a/build/cmake_package_files/CppUTestConfig.cmake
+++ b/build/cmake_package_files/CppUTestConfig.cmake
@@ -3,8 +3,6 @@
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was CppUTestConfig.cmake.install.in ########
-get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
-
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
@@ -24,7 +22,7 @@ endmacro()
####################################################################################
-set_and_check(CppUTest_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
+set_and_check(CppUTest_INCLUDE_DIRS "/usr/include")
include("${CMAKE_CURRENT_LIST_DIR}/CppUTestTargets.cmake")
set(CppUTest_LIBRARIES CppUTest CppUTestExt)
include("${CMAKE_CURRENT_LIST_DIR}/Modules/CppUTestBuildTimeDiscoverTests.cmake")
diff --git a/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake b/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake
index 31ffbf4..e73fb89 100644
--- a/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake
+++ b/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake
@@ -9,21 +9,21 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
set_property(TARGET CppUTest APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
set_target_properties(CppUTest PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "CXX"
- IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/libCppUTest.a"
+ IMPORTED_LOCATION_RELWITHDEBINFO "${_LIB_PREFIX}/libCppUTest.a"
)
list(APPEND _IMPORT_CHECK_TARGETS CppUTest )
-list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTest "${_IMPORT_PREFIX}/lib/libCppUTest.a" )
+list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTest "${_LIB_PREFIX}/libCppUTest.a" )
# Import target "CppUTestExt" for configuration "RelWithDebInfo"
set_property(TARGET CppUTestExt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
set_target_properties(CppUTestExt PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "CXX"
- IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/libCppUTestExt.a"
+ IMPORTED_LOCATION_RELWITHDEBINFO "${_LIB_PREFIX}/libCppUTestExt.a"
)
list(APPEND _IMPORT_CHECK_TARGETS CppUTestExt )
-list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTestExt "${_IMPORT_PREFIX}/lib/libCppUTestExt.a" )
+list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTestExt "${_LIB_PREFIX}/libCppUTestExt.a" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/build/cmake_package_files/CppUTestTargets.cmake b/build/cmake_package_files/CppUTestTargets.cmake
index e1d5876..d00f796 100644
--- a/build/cmake_package_files/CppUTestTargets.cmake
+++ b/build/cmake_package_files/CppUTestTargets.cmake
@@ -42,13 +42,8 @@ unset(_expectedTargets)
# Compute the installation prefix relative to this file.
-get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-if(_IMPORT_PREFIX STREQUAL "/")
- set(_IMPORT_PREFIX "")
-endif()
+set(_IMPORT_PREFIX "/usr")
+get_filename_component(_LIB_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
# Create imported target CppUTest
add_library(CppUTest STATIC IMPORTED)
@@ -73,6 +68,7 @@ endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
+set(_LIB_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
|