aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorSilvio <silvio.traversaro@iit.it>2016-12-27 12:13:39 +0100
committerSilvio <silvio.traversaro@iit.it>2016-12-27 12:13:39 +0100
commitbd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3 (patch)
tree52e799e7aee095cbda307695613c5e9fcf56efd4 /CMakeLists.txt
parente19bf0763a69fef461adc3f133b82eb41ac954de (diff)
downloaddlfcn-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.txt38
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")
5endif () 5endif ()
6 6
7project (dlfcn C) 7project (dlfcn-win32 C)
8 8
9option(BUILD_SHARED_LIBS "shared/static libs" ON) 9option(BUILD_SHARED_LIBS "shared/static libs" ON)
10option(BUILD_TESTS "tests?" OFF) 10option(BUILD_TESTS "tests?" OFF)
@@ -19,12 +19,46 @@ endif (BUILD_SHARED_LIBS)
19add_library(dl ${sources}) 19add_library(dl ${sources})
20target_link_libraries(dl psapi) 20target_link_libraries(dl psapi)
21 21
22install (TARGETS dl RUNTIME DESTINATION bin 22install (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
26install (FILES ${headers} DESTINATION include) 27install (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
32if(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})
60endif()
61
28if (BUILD_TESTS) 62if (BUILD_TESTS)
29 enable_testing() 63 enable_testing()
30 add_library(testdll SHARED testdll.c) 64 add_library(testdll SHARED testdll.c)