From 88935336f8f810e3524a5bb9baee30ed07af6c2e Mon Sep 17 00:00:00 2001 From: Slyshyk Oleksiy Date: Mon, 16 Apr 2018 21:54:03 +0300 Subject: [PATCH] fix #700 (#701) * first try to fix #700 Use CMAKE_INSTALL_PREFIX for install paths * check IS_DIRECTORY LIB_INSTALL_DIR * fix incorrect VAR usage in condition * changed debian/rules according to @bluca patch --- CMakeLists.txt | 18 +++++++++++------- debian/rules | 2 +- include/CMakeLists.txt | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7e88b4a6..1d1f6f72b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,18 +4,22 @@ project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics Stlink Tools") set(STLINK_UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "Udev rules directory") set(STLINK_MODPROBED_DIR "/etc/modprobe.d" CACHE PATH "modprobe.d directory") -set(LIB_INSTALL_DIR "lib" CACHE PATH "Main library directory") -if(IS_DIRECTORY CMAKE_LIBRARY_PATH) +if( IS_DIRECTORY ${LIB_INSTALL_DIR}) + set(LIB_INSTALL_DIR ${LIB_INSTALL_DIR} CACHE PATH "Main library directory") + set(STLINK_LIBRARY_PATH "${LIB_INSTALL_DIR}") else() - set(CMAKE_LIBRARY_PATH "lib") + set(LIB_INSTALL_DIR "lib" CACHE PATH "Main library directory") + set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" ) endif() -if (WIN32) - set(STLINK_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE PATH "Target lib directory") +if( IS_DIRECTORY ${INCLUDE_INSTALL_DIR}) + set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR} CACHE PATH "Main include directory") + set(STLINK_INCLUDE_PATH "${INCLUDE_INSTALL_DIR}" ) else() - set(STLINK_LIBRARY_PATH "${LIB_INSTALL_DIR}/${CMAKE_LIBRARY_PATH}" CACHE PATH "Target lib directory") -endif(WIN32) + set(INCLUDE_INSTALL_DIR "include" CACHE PATH "Main include directory") + set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") +endif() option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) diff --git a/debian/rules b/debian/rules index c4e9e2afd..e228a7087 100755 --- a/debian/rules +++ b/debian/rules @@ -15,5 +15,5 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all override_dh_auto_configure: dh_auto_configure -- \ - -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \ + -DLIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \ -DSTLINK_UDEV_RULES_DIR='/lib/udev/rules.d' diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 0b5a443c0..a0c649532 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -7,8 +7,8 @@ file(GLOB STLINK_HEADERS "${CMAKE_BINARY_DIR}/include/stlink/*.h" ) install(FILES ${CMAKE_SOURCE_DIR}/include/stlink.h - DESTINATION include/${CMAKE_LIBRARY_PATH} + DESTINATION ${STLINK_INCLUDE_PATH} ) install(FILES ${STLINK_HEADERS} - DESTINATION include/${CMAKE_LIBRARY_PATH}/stlink + DESTINATION ${STLINK_INCLUDE_PATH}/stlink )