From a130887781373f5f29552ee6d7139b99a829512d Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 15 Mar 2021 11:26:44 +0100 Subject: cmake: use CROSSCOMPILING_EMULATOR --- CMakeLists.txt | 21 ++++----------------- README.md | 2 ++ tests/CMakeLists.txt | 8 ++------ tools/ci-build.sh | 3 +-- 4 files changed, 9 insertions(+), 25 deletions(-) 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( ${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} $ WORKING_DIRECTORY $) - endif() + add_test(NAME t_dlfcn COMMAND t_dlfcn WORKING_DIRECTORY $ ) 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} $ WORKING_DIRECTORY $) -endif() +add_test(NAME test-dladdr COMMAND test-dladdr WORKING_DIRECTORY $) 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 \ .. ;; -- cgit v1.2.3-55-g6feb