diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2020-11-02 13:06:55 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2020-11-09 09:45:38 +0100 |
commit | 2821345eacb71222ed9acf31f193eda81daeec3f (patch) | |
tree | 27a74ed092adde7cf07aecbbcdd096a7db443cdd /CMakeLists.txt | |
parent | 53b1d71abe1c9d7c43eb68b91a0e94a27b948cdf (diff) | |
download | dlfcn-win32-2821345eacb71222ed9acf31f193eda81daeec3f.tar.gz dlfcn-win32-2821345eacb71222ed9acf31f193eda81daeec3f.tar.bz2 dlfcn-win32-2821345eacb71222ed9acf31f193eda81daeec3f.zip |
cmake: add option ENABLE_WINE to enable support for running cross compiled tests with wine
For details about the ENABLE_WINE option, which support three modes
AUTO|ON|OFF see the documentation of cmake macro check_auto_option().
A custom path for the wine executable can be specified by adding
-DWINE_EXECUTABLE=<path> to the cmake command line.
The cmake related macros were copied from
https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/cmake/modules/Macros.cmake
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ab20340..1c6fe4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -6,9 +6,29 @@ endif () | |||
6 | 6 | ||
7 | project (dlfcn-win32 C) | 7 | project (dlfcn-win32 C) |
8 | 8 | ||
9 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") | ||
10 | include(Macros) | ||
11 | |||
9 | option(BUILD_SHARED_LIBS "shared/static libs" ON) | 12 | option(BUILD_SHARED_LIBS "shared/static libs" ON) |
10 | option(BUILD_TESTS "tests?" OFF) | 13 | option(BUILD_TESTS "tests?" OFF) |
11 | 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 | |||
12 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | 32 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) | 33 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
14 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | 34 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
@@ -16,6 +36,5 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |||
16 | add_subdirectory(src) | 36 | add_subdirectory(src) |
17 | 37 | ||
18 | if (BUILD_TESTS) | 38 | if (BUILD_TESTS) |
19 | enable_testing() | ||
20 | add_subdirectory(tests) | 39 | add_subdirectory(tests) |
21 | endif() | 40 | endif() |