diff options
author | Silvio <silvio.traversaro@iit.it> | 2016-12-27 12:13:39 +0100 |
---|---|---|
committer | Silvio <silvio.traversaro@iit.it> | 2016-12-27 12:13:39 +0100 |
commit | bd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3 (patch) | |
tree | 52e799e7aee095cbda307695613c5e9fcf56efd4 /CMakeLists.txt | |
parent | e19bf0763a69fef461adc3f133b82eb41ac954de (diff) | |
download | dlfcn-win32-bd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3.tar.gz dlfcn-win32-bd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3.tar.bz2 dlfcn-win32-bd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3.zip |
Add CMake code to export a CMake config file
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cf8c60a..48945b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -4,7 +4,7 @@ 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") |
5 | endif () | 5 | endif () |
6 | 6 | ||
7 | project (dlfcn C) | 7 | project (dlfcn-win32 C) |
8 | 8 | ||
9 | option(BUILD_SHARED_LIBS "shared/static libs" ON) | 9 | option(BUILD_SHARED_LIBS "shared/static libs" ON) |
10 | option(BUILD_TESTS "tests?" OFF) | 10 | option(BUILD_TESTS "tests?" OFF) |
@@ -19,12 +19,46 @@ endif (BUILD_SHARED_LIBS) | |||
19 | add_library(dl ${sources}) | 19 | add_library(dl ${sources}) |
20 | target_link_libraries(dl psapi) | 20 | target_link_libraries(dl psapi) |
21 | 21 | ||
22 | install (TARGETS dl RUNTIME DESTINATION bin | 22 | install (TARGETS dl EXPORT dlfcn-win32-targets |
23 | RUNTIME DESTINATION bin | ||
23 | LIBRARY DESTINATION lib${LIB_SUFFIX} | 24 | LIBRARY DESTINATION lib${LIB_SUFFIX} |
24 | ARCHIVE DESTINATION lib${LIB_SUFFIX}) | 25 | ARCHIVE DESTINATION lib${LIB_SUFFIX}) |
25 | 26 | ||
26 | install (FILES ${headers} DESTINATION include) | 27 | install (FILES ${headers} DESTINATION include) |
27 | 28 | ||
29 | # If CMake version is greater than or equal to 2.8.11 | ||
30 | # also install the cmake configuration files to simplify | ||
31 | # the use of dlfcn-win32 in CMake | ||
32 | if(NOT ${CMAKE_VERSION} VERSION_LESS "2.8.11") | ||
33 | # Correctly export the location of installed includes in the target | ||
34 | target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>) | ||
35 | |||
36 | # Export the targets (build tree) | ||
37 | export(EXPORT dlfcn-win32-targets | ||
38 | FILE "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-targets.cmake" | ||
39 | NAMESPACE dlfcn-win32:: | ||
40 | ) | ||
41 | |||
42 | # Write the CMake config file | ||
43 | set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32) | ||
44 | set(INCLUDE_INSTALL_DIR include) | ||
45 | include(CMakePackageConfigHelpers) | ||
46 | configure_package_config_file(dlfcn-win32-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | ||
47 | INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR} | ||
48 | PATH_VARS INCLUDE_INSTALL_DIR | ||
49 | NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
50 | |||
51 | # Install the targets (install) | ||
52 | install(EXPORT dlfcn-win32-targets | ||
53 | FILE dlfcn-win32-targets.cmake | ||
54 | NAMESPACE dlfcn-win32:: | ||
55 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
56 | |||
57 | # Install the CMake config file | ||
58 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | ||
59 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
60 | endif() | ||
61 | |||
28 | if (BUILD_TESTS) | 62 | if (BUILD_TESTS) |
29 | enable_testing() | 63 | enable_testing() |
30 | add_library(testdll SHARED testdll.c) | 64 | add_library(testdll SHARED testdll.c) |