From d22f7719cb6a610be6cc20cbfbb79698177360cd Mon Sep 17 00:00:00 2001 From: Silvio Date: Sun, 5 Mar 2017 16:48:00 +0100 Subject: Add testing of CMake exported targets --- .appveyor.yml | 13 ++++++++++++- cmake-test/CMakeLists.txt | 14 ++++++++++++++ test.c | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 cmake-test/CMakeLists.txt diff --git a/.appveyor.yml b/.appveyor.yml index fd488ba..d97a44e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -52,7 +52,7 @@ build_script: - ps: if($env:PLATFORM -eq "x64") { $env:CMAKE_GEN_SUFFIX=" Win64" } - md build - cd build - - cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -DBUILD_TESTS=ON .. + - cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX="./install" .. - cmake --build . --config "%CONFIGURATION%" test_script: @@ -60,4 +60,15 @@ test_script: after_test: - cmake --build . --config "%CONFIGURATION%" --target INSTALL + # Test also the use of dlfcn-win32 from an external CMake project + # Append the instllation directory of dlfcn-win32 to CMAKE_PREFIX_PATH to make sure that the CMake project is found + - set CMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%/build/install + # Append the bin installation directory of dlfcn-win32 to the path to make sure that .dll are found + - set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%/build/install/bin + - cd ../cmake-test + - md build + - cd build + - cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -DBUILD_TESTS=ON .. + - cmake --build . --config "%CONFIGURATION%" + - ctest --output-on-failure --build-config "%CONFIGURATION%" diff --git a/cmake-test/CMakeLists.txt b/cmake-test/CMakeLists.txt new file mode 100644 index 0000000..532f2b8 --- /dev/null +++ b/cmake-test/CMakeLists.txt @@ -0,0 +1,14 @@ +# Simple CMake project to test the use of dlfcn-win32 +# imported target. The test compiled is the same compiled +# as part of the main dlfcn-win32 project + +cmake_minimum_required(VERSION 3.0) + +find_package(dlfcn-win32 REQUIRED) + +add_library(testdll SHARED ../testdll.c) +set_target_properties(testdll PROPERTIES PREFIX "") +add_executable(t_dlfcn ../test.c) +target_link_libraries(t_dlfcn dlfcn-win32::dl) +enable_testing() +add_test(NAME t_dlfcn COMMAND t_dlfcn) diff --git a/test.c b/test.c index e7124ae..14523ad 100644 --- a/test.c +++ b/test.c @@ -24,6 +24,7 @@ #include #endif #include +#include #include "dlfcn.h" /* If these dlclose's fails, we don't care as the handles are going to be -- cgit v1.2.3-55-g6feb