aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Traversaro <pegua1@gmail.com>2017-03-05 09:50:55 +0100
committerGitHub <noreply@github.com>2017-03-05 09:50:55 +0100
commitad70f0eba0b3029d896d4ffbdf06a5e1793ee3dc (patch)
tree52e799e7aee095cbda307695613c5e9fcf56efd4
parente19bf0763a69fef461adc3f133b82eb41ac954de (diff)
parentbd4eebdb36e7a4d1fa3df20ceb44afc24594dfa3 (diff)
downloaddlfcn-win32-ad70f0eba0b3029d896d4ffbdf06a5e1793ee3dc.tar.gz
dlfcn-win32-ad70f0eba0b3029d896d4ffbdf06a5e1793ee3dc.tar.bz2
dlfcn-win32-ad70f0eba0b3029d896d4ffbdf06a5e1793ee3dc.zip
Merge pull request #27 from traversaro/add-cmake-config-file
Add CMake code to export a CMake config file
-rw-r--r--CMakeLists.txt38
-rw-r--r--dlfcn-win32-config.cmake.in10
2 files changed, 46 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)
diff --git a/dlfcn-win32-config.cmake.in b/dlfcn-win32-config.cmake.in
new file mode 100644
index 0000000..f1ddeb0
--- /dev/null
+++ b/dlfcn-win32-config.cmake.in
@@ -0,0 +1,10 @@
1@PACKAGE_INIT@
2
3set_and_check(dlfcn-win32_INCLUDEDIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
4
5if(NOT TARGET dlfcn-win32::dl)
6 include(${CMAKE_CURRENT_LIST_DIR}/dlfcn-win32-targets.cmake)
7endif()
8
9set(dlfcn-win32_LIBRARIES dlfcn-win32::dl)
10set(dlfcn-win32_INCLUDE_DIRS ${dlfcn-win32_INCLUDEDIR}) \ No newline at end of file