From 3afa40c6ba2d1547682be27e291493e9b2f6c303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= Date: Mon, 10 Jun 2024 15:23:50 +0200 Subject: [PATCH 1/2] Use CMAKE_INSTALL_FULL_LIBDIR, CMAKE_INSTALL_FULL_INCLUDEDIR Do not roll our own path contatenation, let's use GNUInstallDirs macros to do the work. --- CMakeLists.txt | 21 --------------------- msgpack-c.pc.in | 9 ++------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d76d8b8..1f10da336 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,19 +28,6 @@ SET (VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}) LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/") include(GNUInstallDirs) -SET (prefix ${CMAKE_INSTALL_PREFIX}) -SET (exec_prefix ${CMAKE_INSTALL_PREFIX}) -IF (IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) - SET (libdir ${CMAKE_INSTALL_LIBDIR}) -ELSE () - SET (libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}") -ENDIF () -IF (IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) - SET (includedir ${CMAKE_INSTALL_INCLUDEDIR}) -ELSE () - SET (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") -ENDIF () - OPTION (MSGPACK_32BIT "32bit compile" OFF) INCLUDE(TestBigEndian) @@ -245,14 +232,6 @@ IF ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "sparc") SET (CMAKE_C_FLAGS "-DMSGPACK_ZONE_ALIGN=8 ${CMAKE_C_FLAGS}") ENDIF () -IF (NOT DEFINED CMAKE_INSTALL_BINDIR) - SET(CMAKE_INSTALL_BINDIR bin) -ENDIF () - -IF (NOT DEFINED CMAKE_INSTALL_LIBDIR) - SET(CMAKE_INSTALL_LIBDIR lib) -ENDIF () - IF (MSGPACK_BUILD_EXAMPLES) ADD_SUBDIRECTORY (example) ENDIF () diff --git a/msgpack-c.pc.in b/msgpack-c.pc.in index 208066252..1f4e1db06 100644 --- a/msgpack-c.pc.in +++ b/msgpack-c.pc.in @@ -1,10 +1,5 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - Name: MessagePack Description: Binary-based efficient object serialization library Version: @VERSION@ -Libs: -L${libdir} -lmsgpack-c -Cflags: -I${includedir} +Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lmsgpack-c +Cflags: -I@CMAKE-INSTALL_FULL_INCLUDEDIR@ From 794f3cb8bc59276eab62b3e6f2fe5f7c040cbea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= Date: Mon, 10 Jun 2024 15:42:01 +0200 Subject: [PATCH 2/2] cmake: enable CMP0042 to use @rpath --- CMakeLists.txt | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f10da336..cb21a37de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.4") CMAKE_MINIMUM_REQUIRED (VERSION 3.5) else() CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12) + CMAKE_POLICY(SET CMP0042 NEW) IF ((CMAKE_VERSION VERSION_GREATER 3.1) OR (CMAKE_VERSION VERSION_EQUAL 3.1)) CMAKE_POLICY(SET CMP0054 NEW) @@ -52,18 +53,6 @@ CONFIGURE_FILE ( @ONLY ) -IF (APPLE) - SET(CMAKE_MACOSX_RPATH ON) - SET(CMAKE_SKIP_BUILD_RPATH FALSE) - SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) - IF ("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - ENDIF () -ENDIF () - IF (MSGPACK_32BIT) IF ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") SET (CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")