aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Traversaro <silvio@traversaro.it>2021-04-29 09:44:52 +0200
committerGitHub <noreply@github.com>2021-04-29 09:44:52 +0200
commit010969070719fe14435f4b146ecef5e65df0098f (patch)
treef3f5e43983a89ff9d886c64342f977a324931ca4
parent020e3142953ce9d044b6144bc7a55629341bb715 (diff)
parenta130887781373f5f29552ee6d7139b99a829512d (diff)
downloaddlfcn-win32-010969070719fe14435f4b146ecef5e65df0098f.tar.gz
dlfcn-win32-010969070719fe14435f4b146ecef5e65df0098f.tar.bz2
dlfcn-win32-010969070719fe14435f4b146ecef5e65df0098f.zip
Merge pull request #99 from xantares/wine
cmake: use CROSSCOMPILING_EMULATOR
-rw-r--r--CMakeLists.txt21
-rw-r--r--README.md2
-rw-r--r--tests/CMakeLists.txt8
-rwxr-xr-xtools/ci-build.sh3
4 files changed, 9 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e52b25b..160d787 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,23 +12,6 @@ include(Macros)
12option(BUILD_SHARED_LIBS "shared/static libs" ON) 12option(BUILD_SHARED_LIBS "shared/static libs" ON)
13option(BUILD_TESTS "tests?" OFF) 13option(BUILD_TESTS "tests?" OFF)
14 14
15if(WIN32 AND NOT CMAKE_HOST_WIN32 AND CMAKE_CROSSCOMPILING AND BUILD_TESTS)
16 add_auto_option(ENABLE_WINE "Enable running tests with wine" AUTO)
17 find_program(WINE_EXECUTABLE wine)
18 check_auto_option(ENABLE_WINE "wine support" WINE_EXECUTABLE "wine executable")
19 if(ENABLE_WINE AND WINE_EXECUTABLE)
20 set(WRAPPER ${WINE_EXECUTABLE})
21 set(RUN_TESTS 1)
22 message(STATUS "Support to run cross compiled tests - enabled")
23 endif()
24elseif(BUILD_TESTS)
25 set(RUN_TESTS 1)
26endif()
27
28if(RUN_TESTS)
29 enable_testing()
30endif()
31
32set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 15set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
33set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 16set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
34set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 17set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -44,5 +27,9 @@ if(WIN32)
44endif() 27endif()
45 28
46if (BUILD_TESTS) 29if (BUILD_TESTS)
30 if (CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
31 message(WARNING "You might want to set CMAKE_CROSSCOMPILING_EMULATOR to wine path in order to run tests")
32 endif ()
33 enable_testing()
47 add_subdirectory(tests) 34 add_subdirectory(tests)
48endif() 35endif()
diff --git a/README.md b/README.md
index 9424e3c..c4ea414 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,8 @@ target_link_libraries(<target> ${CMAKE_DL_LIBS})
43... 43...
44~~~ 44~~~
45 45
46When cross-compiling you might want to set CMAKE_CROSSCOMPILING_EMULATOR to the path of wine to run tests.
47
46Author 48Author
47------ 49------
48 50
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 47fef38..cd321f2 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,9 +15,7 @@ if(WIN32)
15 add_executable(t_dlfcn test.c) 15 add_executable(t_dlfcn test.c)
16 target_link_libraries(t_dlfcn dl) 16 target_link_libraries(t_dlfcn dl)
17 17
18 if(RUN_TESTS) 18 add_test(NAME t_dlfcn COMMAND t_dlfcn WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn> )
19 add_test(NAME t_dlfcn COMMAND ${WRAPPER} $<TARGET_FILE:t_dlfcn> WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn>)
20 endif()
21endif() 19endif()
22 20
23add_executable(test-dladdr test-dladdr.c) 21add_executable(test-dladdr test-dladdr.c)
@@ -35,6 +33,4 @@ endif()
35 33
36install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) 34install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin)
37 35
38if(RUN_TESTS) 36add_test(NAME test-dladdr COMMAND test-dladdr WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>)
39 add_test(NAME test-dladdr COMMAND ${WRAPPER} $<TARGET_FILE:test-dladdr> WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>)
40endif()
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
index 196fd92..a8cb880 100755
--- a/tools/ci-build.sh
+++ b/tools/ci-build.sh
@@ -63,8 +63,7 @@ case "$ci_buildsys" in
63 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ 63 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
64 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ 64 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
65 -DCMAKE_SYSTEM_NAME=Windows \ 65 -DCMAKE_SYSTEM_NAME=Windows \
66 -DENABLE_WINE=ON \ 66 -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/wine \
67 -DWINE_EXECUTABLE=/usr/bin/wine \
68 $cmake_options \ 67 $cmake_options \
69 .. 68 ..
70 ;; 69 ;;