Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 2650bb3bd3644784359be373252b0436873ca8cb Mon Sep 17 00:00:00 2001 |
| 2 | From: Pascal Bach <pascal.bach@siemens.com> |
| 3 | Date: Fri, 28 Sep 2018 16:44:37 +0200 |
| 4 | Subject: [PATCH] Make resulting cmake config relocatable |
| 5 | |
| 6 | This change avoids hardcoded install prefix in the p8-platform-config.cmake. |
| 7 | Especially important when doing cross compilation with Yocto for example. |
| 8 | |
| 9 | Upstream-Status: Submitted [https://github.com/Pulse-Eight/platform/pull/38] |
| 10 | |
| 11 | --- |
| 12 | CMakeLists.txt | 4 ---- |
| 13 | p8-platform-config.cmake.in | 13 +++++++++---- |
| 14 | 2 files changed, 9 insertions(+), 8 deletions(-) |
| 15 | |
| 16 | diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 17 | index 7144b0b..f2db66e 100644 |
| 18 | --- a/CMakeLists.txt |
| 19 | +++ b/CMakeLists.txt |
| 20 | @@ -22,10 +22,6 @@ if(WIN32) |
| 21 | src/windows/os-threads.cpp) |
| 22 | endif() |
| 23 | |
| 24 | -set(p8-platform_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/p8-platform") |
| 25 | -IF(WIN32) |
| 26 | - LIST(APPEND p8-platform_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/p8-platform/windows") |
| 27 | -ENDIF(WIN32) |
| 28 | set(p8-platform_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) |
| 29 | |
| 30 | if(NOT ${CORE_SYSTEM_NAME} STREQUAL "") |
| 31 | diff --git a/p8-platform-config.cmake.in b/p8-platform-config.cmake.in |
| 32 | index 47f30f1..b08e96c 100644 |
| 33 | --- a/p8-platform-config.cmake.in |
| 34 | +++ b/p8-platform-config.cmake.in |
| 35 | @@ -9,17 +9,22 @@ |
| 36 | # p8-platform_LIBRARY_DIRS - directories in which the libraries are situated |
| 37 | # |
| 38 | # propagate these properties from one build system to the other |
| 39 | +get_filename_component(_p8-platform_rootdir ${CMAKE_CURRENT_LIST_DIR}/../ ABSOLUTE) |
| 40 | + |
| 41 | set (p8-platform_VERSION "@p8-platform_VERSION_MAJOR@.@p8-platform_VERSION_MINOR@") |
| 42 | -set (p8-platform_INCLUDE_DIRS @p8-platform_INCLUDE_DIRS@ @CMAKE_INSTALL_PREFIX@/include) |
| 43 | -set (p8-platform_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@") |
| 44 | +set (p8-platform_INCLUDE_DIRS "${_p8-platform_rootdir}/include" "${_p8-platform_rootdir}/include/p8-platform") |
| 45 | +if(WIN32) |
| 46 | + list(APPEND p8-platform_INCLUDE_DIRS "${_p8-platform_rootdir}/include/p8-platform/windows") |
| 47 | +endif(WIN32) |
| 48 | +set (p8-platform_LIBRARY_DIRS "${_p8-platform_rootdir}") |
| 49 | set (p8-platform_LINKER_FLAGS "@p8-platform_LINKER_FLAGS@") |
| 50 | set (p8-platform_CONFIG_VARS "@p8-platform_CONFIG_VARS@") |
| 51 | |
| 52 | # libraries come from the build tree where this file was generated |
| 53 | if(WIN32) |
| 54 | - set (p8-platform_LIBRARY "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/p8-platform.lib") |
| 55 | + set (p8-platform_LIBRARY "${_p8-platform_rootdir}/p8-platform.lib") |
| 56 | else(WIN32) |
| 57 | - set (p8-platform_LIBRARY "-L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ -lp8-platform") |
| 58 | + set (p8-platform_LIBRARY "-L${_p8-platform_rootdir} -lp8-platform") |
| 59 | endif(WIN32) |
| 60 | set (p8-platform_LIBRARIES ${p8-platform_LIBRARY} "@p8-platform_LIBRARIES@") |
| 61 | mark_as_advanced (p8-platform_LIBRARY) |
| 62 | -- |
| 63 | 2.11.0 |
| 64 | |