diff options
| author | Ralf Habacker <ralf.habacker@freenet.de> | 2021-01-17 12:51:08 +0100 |
|---|---|---|
| committer | Ralf Habacker <ralf.habacker@freenet.de> | 2021-01-17 12:51:39 +0100 |
| commit | ebd7badd50aeea37a2ca121409e9f68370b62855 (patch) | |
| tree | a5e7bd420e4199f2bb98836a2b97f6f0e8e3d97d | |
| parent | 0ea2334d46ca84c1a27bd086700f620a06401f94 (diff) | |
| download | dlfcn-win32-ebd7badd50aeea37a2ca121409e9f68370b62855.tar.gz dlfcn-win32-ebd7badd50aeea37a2ca121409e9f68370b62855.tar.bz2 dlfcn-win32-ebd7badd50aeea37a2ca121409e9f68370b62855.zip | |
cmake: add support to build test-dladdr on unix like os
This is used to obtain test result references.
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 30 |
2 files changed, 22 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2202c93..df53be1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -39,7 +39,9 @@ else() | |||
| 39 | add_compile_options(-Wall) | 39 | add_compile_options(-Wall) |
| 40 | endif() | 40 | endif() |
| 41 | 41 | ||
| 42 | add_subdirectory(src) | 42 | if(WIN32) |
| 43 | add_subdirectory(src) | ||
| 44 | endif() | ||
| 43 | 45 | ||
| 44 | if (BUILD_TESTS) | 46 | if (BUILD_TESTS) |
| 45 | add_subdirectory(tests) | 47 | add_subdirectory(tests) |
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f0871e5..00b6647 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
| @@ -1,14 +1,25 @@ | |||
| 1 | include_directories(../src) | ||
| 2 | 1 | ||
| 3 | add_library(testdll SHARED testdll.c) | 2 | if(WIN32) |
| 4 | set_target_properties(testdll PROPERTIES PREFIX "") | 3 | include_directories(../src) |
| 5 | 4 | ||
| 6 | add_library(testdll2 SHARED testdll2.c) | 5 | add_library(testdll SHARED testdll.c) |
| 7 | set_target_properties(testdll2 PROPERTIES PREFIX "") | 6 | set_target_properties(testdll PROPERTIES PREFIX "") |
| 8 | target_link_libraries(testdll2 dl) | 7 | |
| 8 | add_library(testdll2 SHARED testdll2.c) | ||
| 9 | set_target_properties(testdll2 PROPERTIES PREFIX "") | ||
| 10 | target_link_libraries(testdll2 dl) | ||
| 11 | |||
| 12 | add_library(testdll3 SHARED testdll3.c) | ||
| 13 | set_target_properties(testdll3 PROPERTIES PREFIX "") | ||
| 14 | |||
| 15 | add_executable(t_dlfcn test.c) | ||
| 16 | target_link_libraries(t_dlfcn dl) | ||
| 17 | |||
| 18 | if(RUN_TESTS) | ||
| 19 | add_test(NAME t_dlfcn COMMAND ${WRAPPER} $<TARGET_FILE:t_dlfcn> WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn>) | ||
| 20 | endif() | ||
| 21 | endif() | ||
| 9 | 22 | ||
| 10 | add_library(testdll3 SHARED testdll3.c) | ||
| 11 | set_target_properties(testdll3 PROPERTIES PREFIX "") | ||
| 12 | add_executable(test-dladdr test-dladdr.c) | 23 | add_executable(test-dladdr test-dladdr.c) |
| 13 | target_link_libraries(test-dladdr dl) | 24 | target_link_libraries(test-dladdr dl) |
| 14 | if(UNIX) | 25 | if(UNIX) |
| @@ -17,9 +28,6 @@ endif() | |||
| 17 | 28 | ||
| 18 | install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) | 29 | install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) |
| 19 | 30 | ||
| 20 | add_executable(t_dlfcn test.c) | ||
| 21 | target_link_libraries(t_dlfcn dl) | ||
| 22 | if(RUN_TESTS) | 31 | if(RUN_TESTS) |
| 23 | add_test(NAME t_dlfcn COMMAND ${WRAPPER} $<TARGET_FILE:t_dlfcn> WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn>) | ||
| 24 | add_test(NAME test-dladdr COMMAND ${WRAPPER} $<TARGET_FILE:test-dladdr> WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>) | 32 | add_test(NAME test-dladdr COMMAND ${WRAPPER} $<TARGET_FILE:test-dladdr> WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>) |
| 25 | endif() | 33 | endif() |
