cmake: fix export absolute path and relative path and cleanup a bit
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 13 Mar 2017 00:18:02 +0000 (03:18 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Mon, 13 Mar 2017 13:20:40 +0000 (16:20 +0300)
Remove next vars, since I don't think that somebody want to change it:
- bin
- lib
- include

And fix exports problem:
  CMake Error: INSTALL(EXPORT "LibeventTargets") given absolute DESTINATION "/usr/lib/cmake/libevent" but the export references an installation of target "event_core_static" which has relative DESTINATION "lib".

CMakeLists.txt
README.md
cmake/AddEventLibrary.cmake

index ddd1f6d628369e156fa9defa36c5cf2ba2426d02..d92d38da522226ae0d4444b13f98a64a1f5a7cdf 100644 (file)
@@ -792,12 +792,6 @@ configure_file(
 #
 # Create the libraries.
 #
-
-# Allow the user to override installation directories.
-set(EVENT_INSTALL_LIB_DIR       lib CACHE PATH "Installation directory for libraries")
-set(EVENT_INSTALL_BIN_DIR       bin CACHE PATH "Installation directory for executables")
-set(EVENT_INSTALL_INCLUDE_DIR   include CACHE PATH "Installation directory for header files")
-
 include(AddEventLibrary)
 add_event_library(event_core SOURCES ${SRC_CORE})
 add_event_library(event_extra SOURCES ${SRC_EXTRA})
@@ -1303,15 +1297,9 @@ else()
   set(DEF_INSTALL_CMAKE_DIR lib/cmake/libevent)
 endif()
 
-set(EVENT_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
-
-# Make sure the paths are absolute.
-foreach(p LIB BIN INCLUDE CMAKE)
-    set(var EVENT_INSTALL_${p}_DIR)
-    if(NOT IS_ABSOLUTE "${${var}}")
-        set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
-    endif()
-endforeach()
+set(EVENT_INSTALL_CMAKE_DIR
+    "${CMAKE_INSTALL_PREFIX}/${DEF_INSTALL_CMAKE_DIR}"
+    CACHE PATH "Installation directory for CMake files")
 
 export(PACKAGE libevent)
 
@@ -1325,34 +1313,34 @@ set(LIBEVENT_INCLUDE_DIRS
     CACHE PATH "Libevent include directories")
 
 configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigBuildTree.cmake.in
-                ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
-                @ONLY)
+               ${PROJECT_BINARY_DIR}/LibeventConfig.cmake
+               @ONLY)
 
 # Generate the config file for the installation tree.
+# Calculate the relative directory from the Cmake dir.
 file(RELATIVE_PATH
-    REL_INCLUDE_DIR
-    "${EVENT_INSTALL_CMAKE_DIR}"
-    "${EVENT_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir.
+     REL_INCLUDE_DIR
+     "${EVENT_INSTALL_CMAKE_DIR}"
+     "${CMAKE_INSTALL_PREFIX}/include")
 
 # Note the EVENT_CMAKE_DIR is defined in LibeventConfig.cmake.in,
 # we escape it here so it's evaluated when it is included instead
 # so that the include dirs are givenrelative to where the
 # config file is located.
-set(EVENT__INCLUDE_DIRS
-    "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
+set(EVENT__INCLUDE_DIRS "\${EVENT_CMAKE_DIR}/${REL_INCLUDE_DIR}")
 
 configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfig.cmake.in
-                ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
-                @ONLY)
+               ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/LibeventConfig.cmake
+               @ONLY)
 
 # Generate version info for both build-tree and install-tree.
 configure_file(${PROJECT_SOURCE_DIR}/cmake/LibeventConfigVersion.cmake.in
-                ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
-                @ONLY)
+               ${PROJECT_BINARY_DIR}/LibeventConfigVersion.cmake
+               @ONLY)
 
 # Install compat headers
 install(FILES ${HDR_COMPAT}
-        DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}"
+        DESTINATION "include"
         COMPONENT dev)
 
 # Install the configs.
@@ -1364,7 +1352,7 @@ install(FILES
 
 # Install exports for the install-tree.
 install(EXPORT LibeventTargets
-        DESTINATION "${EVENT_INSTALL_CMAKE_DIR}"
+        DESTINATION "${DEF_INSTALL_CMAKE_DIR}"
         COMPONENT dev)
 
 message(STATUS "")
index 83761ecc9520d40afdaac1a48021ac0f806ce843..9134e298dfadc929cb92ad1db38a2339dc300c29 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,18 +26,9 @@ The following Libevent specific Cmake variables are as follows (the values being
 the default).
 
 ```
-# Installation directory for executables
-EVENT_INSTALL_BIN_DIR:PATH=bin
-
 # Installation directory for CMake files
 EVENT_INSTALL_CMAKE_DIR:PATH=lib/cmake/libevent
 
-## Installation directory for header files
-EVENT_INSTALL_INCLUDE_DIR:PATH=include
-
-## Installation directory for libraries
-EVENT_INSTALL_LIB_DIR:PATH=lib
-
 # Enable running gcov to get a test coverage report (only works with
 # GCC/CLang). Make sure to enable -DCMAKE_BUILD_TYPE=Debug as well.
 EVENT__COVERAGE:BOOL=OFF
index 261d77d91520806847592b2791ad67f896b62d45..8cf72d2467967cf7f8871d1d1b10f15af58fb347 100644 (file)
@@ -46,8 +46,6 @@ endmacro()
 # - CMAKE_THREAD_LIBS_INIT LIB_PLATFORM
 # - OPENSSL_LIBRARIES
 # - HDR_PUBLIC
-# - EVENT_INSTALL_BIN_DIR
-# - EVENT_INSTALL_LIB_DIR
 # - EVENT_INSTALL_INCLUDE_DIR
 # - EVENT_SHARED_FLAGS
 #
@@ -97,10 +95,9 @@ macro(add_event_library LIB_NAME)
 
     install(TARGETS "${LIB_NAME}_static" "${LIB_NAME}_shared"
         EXPORT LibeventTargets
-        RUNTIME DESTINATION "${EVENT_INSTALL_BIN_DIR}" COMPONENT bin
-        LIBRARY DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
-        ARCHIVE DESTINATION "${EVENT_INSTALL_LIB_DIR}" COMPONENT lib
-        PUBLIC_HEADER DESTINATION "${EVENT_INSTALL_INCLUDE_DIR}/event2"
+        LIBRARY DESTINATION "lib" COMPONENT lib
+        ARCHIVE DESTINATION "lib" COMPONENT lib
+        PUBLIC_HEADER DESTINATION "include/event2"
         COMPONENT dev
     )