From: Azat Khuzhin Date: Mon, 13 Mar 2017 00:18:02 +0000 (+0300) Subject: cmake: fix export absolute path and relative path and cleanup a bit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd5a3fc0363bc2dea46b5221d11d21b945f891f3;p=libevent cmake: fix export absolute path and relative path and cleanup a bit 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". --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ddd1f6d6..d92d38da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "") diff --git a/README.md b/README.md index 83761ecc..9134e298 100644 --- 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 diff --git a/cmake/AddEventLibrary.cmake b/cmake/AddEventLibrary.cmake index 261d77d9..8cf72d24 100644 --- a/cmake/AddEventLibrary.cmake +++ b/cmake/AddEventLibrary.cmake @@ -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 )