Skip to content

Commit 2650bb3

Browse files
committed
Make resulting cmake config relocatable
This change avoids hardcoded install prefix in the p8-platform-config.cmake. Especially important when doing cross compilation with Yocto for example.
1 parent a822e19 commit 2650bb3

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ if(WIN32)
2222
src/windows/os-threads.cpp)
2323
endif()
2424

25-
set(p8-platform_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/p8-platform")
26-
IF(WIN32)
27-
LIST(APPEND p8-platform_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/p8-platform/windows")
28-
ENDIF(WIN32)
2925
set(p8-platform_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
3026

3127
if(NOT ${CORE_SYSTEM_NAME} STREQUAL "")

p8-platform-config.cmake.in

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
# p8-platform_LIBRARY_DIRS - directories in which the libraries are situated
1010
#
1111
# propagate these properties from one build system to the other
12+
get_filename_component(_p8-platform_rootdir ${CMAKE_CURRENT_LIST_DIR}/../ ABSOLUTE)
13+
1214
set (p8-platform_VERSION "@p8-platform_VERSION_MAJOR@.@p8-platform_VERSION_MINOR@")
13-
set (p8-platform_INCLUDE_DIRS @p8-platform_INCLUDE_DIRS@ @CMAKE_INSTALL_PREFIX@/include)
14-
set (p8-platform_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
15+
set (p8-platform_INCLUDE_DIRS "${_p8-platform_rootdir}/include" "${_p8-platform_rootdir}/include/p8-platform")
16+
if(WIN32)
17+
list(APPEND p8-platform_INCLUDE_DIRS "${_p8-platform_rootdir}/include/p8-platform/windows")
18+
endif(WIN32)
19+
set (p8-platform_LIBRARY_DIRS "${_p8-platform_rootdir}")
1520
set (p8-platform_LINKER_FLAGS "@p8-platform_LINKER_FLAGS@")
1621
set (p8-platform_CONFIG_VARS "@p8-platform_CONFIG_VARS@")
1722

1823
# libraries come from the build tree where this file was generated
1924
if(WIN32)
20-
set (p8-platform_LIBRARY "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/p8-platform.lib")
25+
set (p8-platform_LIBRARY "${_p8-platform_rootdir}/p8-platform.lib")
2126
else(WIN32)
22-
set (p8-platform_LIBRARY "-L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ -lp8-platform")
27+
set (p8-platform_LIBRARY "-L${_p8-platform_rootdir} -lp8-platform")
2328
endif(WIN32)
2429
set (p8-platform_LIBRARIES ${p8-platform_LIBRARY} "@p8-platform_LIBRARIES@")
2530
mark_as_advanced (p8-platform_LIBRARY)

0 commit comments

Comments
 (0)