diff options
author | Silvio Traversaro <silvio@traversaro.it> | 2021-04-29 09:44:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 09:44:52 +0200 |
commit | 010969070719fe14435f4b146ecef5e65df0098f (patch) | |
tree | f3f5e43983a89ff9d886c64342f977a324931ca4 | |
parent | 020e3142953ce9d044b6144bc7a55629341bb715 (diff) | |
parent | a130887781373f5f29552ee6d7139b99a829512d (diff) | |
download | dlfcn-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.txt | 21 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | tools/ci-build.sh | 3 |
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) | |||
12 | option(BUILD_SHARED_LIBS "shared/static libs" ON) | 12 | option(BUILD_SHARED_LIBS "shared/static libs" ON) |
13 | option(BUILD_TESTS "tests?" OFF) | 13 | option(BUILD_TESTS "tests?" OFF) |
14 | 14 | ||
15 | if(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() | ||
24 | elseif(BUILD_TESTS) | ||
25 | set(RUN_TESTS 1) | ||
26 | endif() | ||
27 | |||
28 | if(RUN_TESTS) | ||
29 | enable_testing() | ||
30 | endif() | ||
31 | |||
32 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | 15 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
33 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | 16 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
34 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | 17 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
@@ -44,5 +27,9 @@ if(WIN32) | |||
44 | endif() | 27 | endif() |
45 | 28 | ||
46 | if (BUILD_TESTS) | 29 | if (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) |
48 | endif() | 35 | endif() |
@@ -43,6 +43,8 @@ target_link_libraries(<target> ${CMAKE_DL_LIBS}) | |||
43 | ... | 43 | ... |
44 | ~~~ | 44 | ~~~ |
45 | 45 | ||
46 | When cross-compiling you might want to set CMAKE_CROSSCOMPILING_EMULATOR to the path of wine to run tests. | ||
47 | |||
46 | Author | 48 | Author |
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() | ||
21 | endif() | 19 | endif() |
22 | 20 | ||
23 | add_executable(test-dladdr test-dladdr.c) | 21 | add_executable(test-dladdr test-dladdr.c) |
@@ -35,6 +33,4 @@ endif() | |||
35 | 33 | ||
36 | install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) | 34 | install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin) |
37 | 35 | ||
38 | if(RUN_TESTS) | 36 | add_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>) | ||
40 | endif() | ||
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 | ;; |