diff options
-rw-r--r-- | CMakeLists.txt | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e44343d..48b5016 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | cmake_minimum_required(VERSION 2.8) | 1 | cmake_minimum_required(VERSION 2.8.11) |
2 | 2 | ||
3 | if (NOT DEFINED CMAKE_BUILD_TYPE) | 3 | if (NOT DEFINED CMAKE_BUILD_TYPE) |
4 | set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") | 4 | set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") |
@@ -25,38 +25,33 @@ install (TARGETS dl EXPORT dlfcn-win32-targets | |||
25 | 25 | ||
26 | install (FILES ${headers} DESTINATION include) | 26 | install (FILES ${headers} DESTINATION include) |
27 | 27 | ||
28 | # If CMake version is greater than or equal to 2.8.11 | 28 | # Correctly export the location of installed includes in the target |
29 | # also install the cmake configuration files to simplify | 29 | target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>) |
30 | # the use of dlfcn-win32 in CMake | ||
31 | if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11") | ||
32 | # Correctly export the location of installed includes in the target | ||
33 | target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>) | ||
34 | 30 | ||
35 | # Export the targets (build tree) | 31 | # Export the targets (build tree) |
36 | export(EXPORT dlfcn-win32-targets | 32 | export(EXPORT dlfcn-win32-targets |
37 | FILE "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-targets.cmake" | 33 | FILE "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-targets.cmake" |
38 | NAMESPACE dlfcn-win32:: | 34 | NAMESPACE dlfcn-win32:: |
39 | ) | 35 | ) |
40 | |||
41 | # Write the CMake config file | ||
42 | set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32) | ||
43 | set(INCLUDE_INSTALL_DIR include) | ||
44 | include(CMakePackageConfigHelpers) | ||
45 | configure_package_config_file(dlfcn-win32-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | ||
46 | INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR} | ||
47 | PATH_VARS INCLUDE_INSTALL_DIR | ||
48 | NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
49 | 36 | ||
50 | # Install the targets (install) | 37 | # Write the CMake config file |
51 | install(EXPORT dlfcn-win32-targets | 38 | set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32) |
52 | FILE dlfcn-win32-targets.cmake | 39 | set(INCLUDE_INSTALL_DIR include) |
53 | NAMESPACE dlfcn-win32:: | 40 | include(CMakePackageConfigHelpers) |
54 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | 41 | configure_package_config_file(dlfcn-win32-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake |
42 | INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR} | ||
43 | PATH_VARS INCLUDE_INSTALL_DIR | ||
44 | NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
55 | 45 | ||
56 | # Install the CMake config file | 46 | # Install the targets (install) |
57 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | 47 | install(EXPORT dlfcn-win32-targets |
58 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | 48 | FILE dlfcn-win32-targets.cmake |
59 | endif() | 49 | NAMESPACE dlfcn-win32:: |
50 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
51 | |||
52 | # Install the CMake config file | ||
53 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | ||
54 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
60 | 55 | ||
61 | if (BUILD_TESTS) | 56 | if (BUILD_TESTS) |
62 | enable_testing() | 57 | enable_testing() |