diff options
| author | Ralf Habacker <ralf.habacker@freenet.de> | 2020-08-25 23:34:19 +0200 |
|---|---|---|
| committer | Ralf Habacker <ralf.habacker@freenet.de> | 2020-09-14 12:26:07 +0200 |
| commit | f0ac8495872ee078f18bd349e3db6883ed4106e2 (patch) | |
| tree | 0f9b609aa80b924f6b391e1c4b687c0f73eaa7b9 | |
| parent | 5ead6f2d2c515d3d85c31fffebea55168c1bc1b4 (diff) | |
| download | dlfcn-win32-f0ac8495872ee078f18bd349e3db6883ed4106e2.tar.gz dlfcn-win32-f0ac8495872ee078f18bd349e3db6883ed4106e2.tar.bz2 dlfcn-win32-f0ac8495872ee078f18bd349e3db6883ed4106e2.zip | |
Move cmake targets into sub directories
| -rw-r--r-- | CMakeLists.txt | 58 | ||||
| -rw-r--r-- | cmake-test/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 43 | ||||
| -rw-r--r-- | src/dlfcn.c (renamed from dlfcn.c) | 0 | ||||
| -rw-r--r-- | src/dlfcn.h (renamed from dlfcn.h) | 0 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | tests/test.c (renamed from test.c) | 0 | ||||
| -rw-r--r-- | tests/testdll.c (renamed from testdll.c) | 0 | ||||
| -rw-r--r-- | tests/testdll2.c (renamed from testdll2.c) | 0 | ||||
| -rw-r--r-- | tests/testdll3.c (renamed from testdll3.c) | 0 |
10 files changed, 62 insertions, 59 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) | |||
| 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) |
| 11 | 11 | ||
| 12 | set(headers dlfcn.h) | 12 | add_subdirectory(src) |
| 13 | set(sources dlfcn.c) | ||
| 14 | |||
| 15 | if (BUILD_SHARED_LIBS) | ||
| 16 | add_definitions(-DSHARED) | ||
| 17 | endif (BUILD_SHARED_LIBS) | ||
| 18 | |||
| 19 | add_library(dl ${sources}) | ||
| 20 | |||
| 21 | install (TARGETS dl EXPORT dlfcn-win32-targets | ||
| 22 | RUNTIME DESTINATION bin | ||
| 23 | LIBRARY DESTINATION lib${LIB_SUFFIX} | ||
| 24 | ARCHIVE DESTINATION lib${LIB_SUFFIX}) | ||
| 25 | |||
| 26 | install (FILES ${headers} DESTINATION include) | ||
| 27 | |||
| 28 | # Correctly export the location of installed includes in the target | ||
| 29 | target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>) | ||
| 30 | |||
| 31 | # Export the targets (build tree) | ||
| 32 | export(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 | ||
| 38 | set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32) | ||
| 39 | set(INCLUDE_INSTALL_DIR include) | ||
| 40 | include(CMakePackageConfigHelpers) | ||
| 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) | ||
| 45 | |||
| 46 | # Install the targets (install) | ||
| 47 | install(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 | ||
| 53 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dlfcn-win32-config.cmake | ||
| 54 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
| 55 | 13 | ||
| 56 | if (BUILD_TESTS) | 14 | if (BUILD_TESTS) |
| 57 | enable_testing() | 15 | add_subdirectory(tests) |
| 58 | add_library(testdll SHARED testdll.c) | 16 | endif() |
| 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) | ||
| 68 | endif () | ||
diff --git a/cmake-test/CMakeLists.txt b/cmake-test/CMakeLists.txt index 659a79a..815d127 100644 --- a/cmake-test/CMakeLists.txt +++ b/cmake-test/CMakeLists.txt | |||
| @@ -6,14 +6,14 @@ cmake_minimum_required(VERSION 3.0) | |||
| 6 | 6 | ||
| 7 | find_package(dlfcn-win32 REQUIRED) | 7 | find_package(dlfcn-win32 REQUIRED) |
| 8 | 8 | ||
| 9 | add_library(testdll SHARED ../testdll.c) | 9 | add_library(testdll SHARED ../tests/testdll.c) |
| 10 | set_target_properties(testdll PROPERTIES PREFIX "") | 10 | set_target_properties(testdll PROPERTIES PREFIX "") |
| 11 | add_library(testdll2 SHARED ../testdll2.c) | 11 | add_library(testdll2 SHARED ../tests/testdll2.c) |
| 12 | set_target_properties(testdll2 PROPERTIES PREFIX "") | 12 | set_target_properties(testdll2 PROPERTIES PREFIX "") |
| 13 | target_link_libraries(testdll2 dlfcn-win32::dl) | 13 | target_link_libraries(testdll2 dlfcn-win32::dl) |
| 14 | add_library(testdll3 SHARED ../testdll3.c) | 14 | add_library(testdll3 SHARED ../tests/testdll3.c) |
| 15 | set_target_properties(testdll3 PROPERTIES PREFIX "") | 15 | set_target_properties(testdll3 PROPERTIES PREFIX "") |
| 16 | add_executable(t_dlfcn ../test.c) | 16 | add_executable(t_dlfcn ../tests/test.c) |
| 17 | target_link_libraries(t_dlfcn dlfcn-win32::dl) | 17 | target_link_libraries(t_dlfcn dlfcn-win32::dl) |
| 18 | enable_testing() | 18 | enable_testing() |
| 19 | add_test(NAME t_dlfcn COMMAND t_dlfcn) | 19 | add_test(NAME t_dlfcn COMMAND t_dlfcn) |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..d5296b1 --- /dev/null +++ b/src/CMakeLists.txt | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | set(headers dlfcn.h) | ||
| 2 | set(sources dlfcn.c) | ||
| 3 | |||
| 4 | if (BUILD_SHARED_LIBS) | ||
| 5 | add_definitions(-DSHARED) | ||
| 6 | endif (BUILD_SHARED_LIBS) | ||
| 7 | |||
| 8 | add_library(dl ${sources}) | ||
| 9 | |||
| 10 | # Correctly export the location of installed includes in the target | ||
| 11 | target_include_directories(dl INTERFACE $<INSTALL_INTERFACE:include>) | ||
| 12 | |||
| 13 | install (TARGETS dl EXPORT dlfcn-win32-targets | ||
| 14 | RUNTIME DESTINATION bin | ||
| 15 | LIBRARY DESTINATION lib${LIB_SUFFIX} | ||
| 16 | ARCHIVE DESTINATION lib${LIB_SUFFIX}) | ||
| 17 | |||
| 18 | install (FILES ${headers} DESTINATION include) | ||
| 19 | |||
| 20 | # Export the targets (build tree) | ||
| 21 | export(EXPORT dlfcn-win32-targets | ||
| 22 | FILE "${CMAKE_BINARY_DIR}/dlfcn-win32-targets.cmake" | ||
| 23 | NAMESPACE dlfcn-win32:: | ||
| 24 | ) | ||
| 25 | |||
| 26 | # Write the CMake config file | ||
| 27 | set(CMAKE_CONF_INSTALL_DIR share/dlfcn-win32) | ||
| 28 | set(INCLUDE_INSTALL_DIR include) | ||
| 29 | include(CMakePackageConfigHelpers) | ||
| 30 | configure_package_config_file(../dlfcn-win32-config.cmake.in ${CMAKE_BINARY_DIR}/dlfcn-win32-config.cmake | ||
| 31 | INSTALL_DESTINATION ${CMAKE_CONF_INSTALL_DIR} | ||
| 32 | PATH_VARS INCLUDE_INSTALL_DIR | ||
| 33 | NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
| 34 | |||
| 35 | # Install the targets (install) | ||
| 36 | install(EXPORT dlfcn-win32-targets | ||
| 37 | FILE dlfcn-win32-targets.cmake | ||
| 38 | NAMESPACE dlfcn-win32:: | ||
| 39 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
| 40 | |||
| 41 | # Install the CMake config file | ||
| 42 | install(FILES ${CMAKE_BINARY_DIR}/dlfcn-win32-config.cmake | ||
| 43 | DESTINATION ${CMAKE_CONF_INSTALL_DIR}) | ||
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..64f85f7 --- /dev/null +++ b/tests/CMakeLists.txt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | enable_testing() | ||
| 2 | include_directories(../src) | ||
| 3 | add_library(testdll SHARED testdll.c) | ||
| 4 | set_target_properties(testdll PROPERTIES PREFIX "") | ||
| 5 | add_library(testdll2 SHARED testdll2.c) | ||
| 6 | set_target_properties(testdll2 PROPERTIES PREFIX "") | ||
| 7 | target_link_libraries(testdll2 dl) | ||
| 8 | add_library(testdll3 SHARED testdll3.c) | ||
| 9 | set_target_properties(testdll3 PROPERTIES PREFIX "") | ||
| 10 | add_executable(t_dlfcn test.c) | ||
| 11 | target_link_libraries(t_dlfcn dl) | ||
| 12 | add_test (NAME t_dlfcn COMMAND t_dlfcn) | ||
diff --git a/testdll.c b/tests/testdll.c index 5bb0f43..5bb0f43 100644 --- a/testdll.c +++ b/tests/testdll.c | |||
diff --git a/testdll2.c b/tests/testdll2.c index 1560738..1560738 100644 --- a/testdll2.c +++ b/tests/testdll2.c | |||
diff --git a/testdll3.c b/tests/testdll3.c index b6f4f5b..b6f4f5b 100644 --- a/testdll3.c +++ b/tests/testdll3.c | |||
