cmake: use CROSSCOMPILING_EMULATOR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/CMakeLists.txt b/CMakeLists.txt
index df53be1..24d6bbe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,23 +12,6 @@ include(Macros)
option(BUILD_SHARED_LIBS "shared/static libs" ON)
option(BUILD_TESTS "tests?" OFF)
-if(WIN32 AND NOT CMAKE_HOST_WIN32 AND CMAKE_CROSSCOMPILING AND BUILD_TESTS)
- add_auto_option(ENABLE_WINE "Enable running tests with wine" AUTO)
- find_program(WINE_EXECUTABLE wine)
- check_auto_option(ENABLE_WINE "wine support" WINE_EXECUTABLE "wine executable")
- if(ENABLE_WINE AND WINE_EXECUTABLE)
- set(WRAPPER ${WINE_EXECUTABLE})
- set(RUN_TESTS 1)
- message(STATUS "Support to run cross compiled tests - enabled")
- endif()
-elseif(BUILD_TESTS)
- set(RUN_TESTS 1)
-endif()
-
-if(RUN_TESTS)
- enable_testing()
-endif()
-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -44,5 +27,9 @@ if(WIN32)
endif()
if (BUILD_TESTS)
+ if (CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
+ message(WARNING "You might want to set CMAKE_CROSSCOMPILING_EMULATOR to wine path in order to run tests")
+ endif ()
+ enable_testing()
add_subdirectory(tests)
endif()
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})
...
~~~
+When cross-compiling you might want to set CMAKE_CROSSCOMPILING_EMULATOR to the path of wine to run tests.
+
Author
------
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)
add_executable(t_dlfcn test.c)
target_link_libraries(t_dlfcn dl)
- if(RUN_TESTS)
- add_test(NAME t_dlfcn COMMAND ${WRAPPER} $<TARGET_FILE:t_dlfcn> WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn>)
- endif()
+ add_test(NAME t_dlfcn COMMAND t_dlfcn WORKING_DIRECTORY $<TARGET_FILE_DIR:t_dlfcn> )
endif()
add_executable(test-dladdr test-dladdr.c)
@@ -35,6 +33,4 @@ endif()
install(TARGETS test-dladdr EXPORT dlfcn-win32-targets RUNTIME DESTINATION bin)
-if(RUN_TESTS)
- add_test(NAME test-dladdr COMMAND ${WRAPPER} $<TARGET_FILE:test-dladdr> WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>)
-endif()
+add_test(NAME test-dladdr COMMAND test-dladdr WORKING_DIRECTORY $<TARGET_FILE_DIR:test-dladdr>)
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
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_SYSTEM_NAME=Windows \
- -DENABLE_WINE=ON \
- -DWINE_EXECUTABLE=/usr/bin/wine \
+ -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/wine \
$cmake_options \
..
;;