From ebd7badd50aeea37a2ca121409e9f68370b62855 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sun, 17 Jan 2021 12:51:08 +0100 Subject: cmake: add support to build test-dladdr on unix like os This is used to obtain test result references. --- CMakeLists.txt | 4 +++- 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() add_compile_options(-Wall) endif() -add_subdirectory(src) +if(WIN32) + add_subdirectory(src) +endif() if (BUILD_TESTS) 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 @@ -include_directories(../src) -add_library(testdll SHARED testdll.c) -set_target_properties(testdll PROPERTIES PREFIX "") +if(WIN32) + include_directories(../src) -add_library(testdll2 SHARED testdll2.c) -set_target_properties(testdll2 PROPERTIES PREFIX "") -target_link_libraries(testdll2 dl) + add_library(testdll SHARED testdll.c) + set_target_properties(testdll PROPERTIES PREFIX "") + + add_library(testdll2 SHARED testdll2.c) + set_target_properties(testdll2 PROPERTIES PREFIX "") + target_link_libraries(testdll2 dl) + + add_library(testdll3 SHARED testdll3.c) + set_target_properties(testdll3 PROPERTIES PREFIX "") + + add_executable(t_dlfcn test.c) + target_link_libraries(t_dlfcn dl) + + if(RUN_TESTS) + add_test(NAME t_dlfcn COMMAND ${WRAPPER} $ WORKING_DIRECTORY $) + endif() +endif() -add_library(testdll3 SHARED testdll3.c) -set_target_properties(testdll3 PROPERTIES PREFIX "") add_executable(test-dladdr test-dladdr.c) target_link_libraries(test-dladdr dl) if(UNIX) @@ -17,9 +28,6 @@ endif() install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) -add_executable(t_dlfcn test.c) -target_link_libraries(t_dlfcn dl) if(RUN_TESTS) - add_test(NAME t_dlfcn COMMAND ${WRAPPER} $ WORKING_DIRECTORY $) add_test(NAME test-dladdr COMMAND ${WRAPPER} $ WORKING_DIRECTORY $) endif() -- cgit v1.2.3-55-g6feb