From f8a3a599ac2afaeaf408847b189404f65691251d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 1 Dec 2014 23:44:08 +0100 Subject: [PATCH 1/2] Adapt libdir for 64bit RPM-based distros RPM-based distros such as Fedora or Mageia put 64bit libraries in /usr/lib64 while 32bit libraries go to /usr/lib. This is usually taken into account in CMake projects using a LIB_SUFFIX parameter that can be set to "" or "64". --- CMakeLists.txt | 10 ++++++---- pkg-config/jsoncpp.pc.in | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2def6ca..3e8f96e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,15 +17,17 @@ IF(NOT WIN32) ENDIF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT WIN32) +SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory") + SET(RUNTIME_INSTALL_DIR bin CACHE PATH "Install dir for executables and dlls") -SET(ARCHIVE_INSTALL_DIR lib +SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX} CACHE PATH "Install dir for static libraries") -SET(LIBRARY_INSTALL_DIR lib +SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX} CACHE PATH "Install dir for shared libraries") SET(INCLUDE_INSTALL_DIR include CACHE PATH "Install dir for headers") -SET(PACKAGE_INSTALL_DIR lib/cmake +SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake CACHE PATH "Install dir for cmake package config files") MARK_AS_ADVANCED( RUNTIME_INSTALL_DIR ARCHIVE_INSTALL_DIR INCLUDE_INSTALL_DIR PACKAGE_INSTALL_DIR ) @@ -101,7 +103,7 @@ IF(JSONCPP_WITH_PKGCONFIG_SUPPORT) "pkg-config/jsoncpp.pc" @ONLY) INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT) IF(JSONCPP_WITH_CMAKE_PACKAGE) diff --git a/pkg-config/jsoncpp.pc.in b/pkg-config/jsoncpp.pc.in index 5de8105..9613181 100644 --- a/pkg-config/jsoncpp.pc.in +++ b/pkg-config/jsoncpp.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib +libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@ includedir=${prefix}/@INCLUDE_INSTALL_DIR@ Name: jsoncpp From 27639ce57823a9dcdfec1602fb4cc55b361f42e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 1 Dec 2014 23:47:21 +0100 Subject: [PATCH 2/2] Add support for BUILD_SHARED_LIBS argument BUILD_SHARED_LIBS is a standard CMake argument that serves the purpose of the custom JSONCPP_LIB_BUILD_SHARED. For now we force JSONCPP_LIB_BUILD_SHARED to true if BUILD_SHARED_LIBS was defined. Workaround for #51. --- src/lib_json/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index 418044d..e126d30 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -1,4 +1,8 @@ OPTION(JSONCPP_LIB_BUILD_SHARED "Build jsoncpp_lib as a shared library." OFF) +IF(BUILD_SHARED_LIBS) + SET(JSONCPP_LIB_BUILD_SHARED ON) +ENDIF(BUILD_SHARED_LIBS) + IF(JSONCPP_LIB_BUILD_SHARED) SET(JSONCPP_LIB_TYPE SHARED) ADD_DEFINITIONS( -DJSON_DLL_BUILD )