Debian Codegraph @

debian/patches/Hardcode-installation-prefix-in-cmake-scripts.patch

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