From 43ebaa4289bcda7af26be49f430f262575e1cfd3 Mon Sep 17 00:00:00 2001 From: msclock Date: Tue, 12 Mar 2024 20:58:33 +0800 Subject: [PATCH] perf: add crosscompiling settings (#43) Signed-off-by: msclock --- cmake/build/Default.cmake | 1 + cmake/configure/Default.cmake | 1 + cmake/install/Default.cmake | 1 + cmake/install/InstallDependency.cmake | 6 ++++++ cmake/test/Default.cmake | 24 ++++++++++++++++++++++++ 5 files changed, 33 insertions(+) diff --git a/cmake/build/Default.cmake b/cmake/build/Default.cmake index 69016e3..99ab4e9 100644 --- a/cmake/build/Default.cmake +++ b/cmake/build/Default.cmake @@ -1,6 +1,7 @@ #[[ Default to build. ]] +include_guard(GLOBAL) # Create the compile command database for clang by default set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/cmake/configure/Default.cmake b/cmake/configure/Default.cmake index c6dacfc..bed5ada 100644 --- a/cmake/configure/Default.cmake +++ b/cmake/configure/Default.cmake @@ -1,6 +1,7 @@ #[[ Default to configuration. ]] +include_guard(GLOBAL) # Put the include dirs which are in the source or build tree before all other # include dirs, so the headers in the sources are preferred over the already diff --git a/cmake/install/Default.cmake b/cmake/install/Default.cmake index 7d93ec6..a2de3f3 100644 --- a/cmake/install/Default.cmake +++ b/cmake/install/Default.cmake @@ -1,3 +1,4 @@ #[[ Default to installation. ]] +include_guard(GLOBAL) diff --git a/cmake/install/InstallDependency.cmake b/cmake/install/InstallDependency.cmake index f155c15..e5245a3 100644 --- a/cmake/install/InstallDependency.cmake +++ b/cmake/install/InstallDependency.cmake @@ -5,6 +5,12 @@ This module provides tools to handle cmake installations painlessly. include_guard(GLOBAL) include(${CMAKE_CURRENT_LIST_DIR}/Runpath.cmake) +if(WIN32 AND NOT ${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") + # We're building for Windows on a different operating system. Set the platform + # for get_runtime_dependencies() to "windows+pe" + set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "windows+pe") +endif() + #[[ A function to enable installation of dependencies as part of the `make install` process. diff --git a/cmake/test/Default.cmake b/cmake/test/Default.cmake index dcbbb90..8cab7b7 100644 --- a/cmake/test/Default.cmake +++ b/cmake/test/Default.cmake @@ -1,3 +1,27 @@ #[[ Default to test ]] + +include_guard(GLOBAL) + +# This variable is only used when ``CMAKE_CROSSCOMPILING`` is on. It should +# point to a command on the host system that can run executable built for the +# target system. +if(WIN32 AND NOT ${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") + # We're building for Windows on a different operating system. + find_program( + WINE + NAMES "wine" "wine64" "wine-development" + DOC "Wine (to run tests)") + + if(WINE) + message( + STATUS "The following Wine binary will be used to run tests: \"${WINE}\"") + set(CMAKE_CROSSCOMPILING_EMULATOR ${WINE}) + else() + message( + WARNING + "You are cross-compiling for Windows but don't have Wine, you will not be able to run tests." + ) + endif() +endif()