aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt58
1 files changed, 3 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48b5016..17d3fc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,60 +9,8 @@ project (dlfcn-win32 C)
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)
11 11
12set(headers dlfcn.h) 12add_subdirectory(src)
13set(sources dlfcn.c)
14
15if (BUILD_SHARED_LIBS)
16 add_definitions(-DSHARED)
17endif (BUILD_SHARED_LIBS)
18
19add_library(dl ${sources})
20
21install (TARGETS dl EXPORT dlfcn-win32-targets
22 RUNTIME DESTINATION bin
23 LIBRARY DESTINATION lib${LIB_SUFFIX}
24 ARCHIVE DESTINATION lib${LIB_SUFFIX})
25
26install (FILES ${headers} DESTINATION include)
27
28# Correctly export the location of installed includes in the target
29target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>)
30
31# Export the targets (build tree)
32export(EXPORT dlfcn-win32-targets
33 FILE "${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-targets.cmake"
34 NAMESPACE dlfcn-win32::
35)
36
37# Write the CMake config file
38set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32)
39set(INCLUDE_INSTALL_DIR include)
40include(CMakePackageConfigHelpers)
41configure_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)
45
46# Install the targets (install)
47install(EXPORT dlfcn-win32-targets
48 FILE dlfcn-win32-targets.cmake
49 NAMESPACE dlfcn-win32::
50 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
51
52# Install the CMake config file
53install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake
54 DESTINATION ${CMAKE_CONF_INSTALL_DIR})
55 13
56if (BUILD_TESTS) 14if (BUILD_TESTS)
57 enable_testing() 15 add_subdirectory(tests)
58 add_library(testdll SHARED testdll.c) 16endif()
59 set_target_properties(testdll PROPERTIES PREFIX "")
60 add_library(testdll2 SHARED testdll2.c)
61 set_target_properties(testdll2 PROPERTIES PREFIX "")
62 target_link_libraries(testdll2 dl)
63 add_library(testdll3 SHARED testdll3.c)
64 set_target_properties(testdll3 PROPERTIES PREFIX "")
65 add_executable(t_dlfcn test.c)
66 target_link_libraries(t_dlfcn dl)
67 add_test (NAME t_dlfcn COMMAND t_dlfcn)
68endif ()