diff --git a/depends/Makefile b/depends/Makefile index ab91b5b72a317..fa952324c1704 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -272,7 +272,6 @@ $(host_prefix)/share/toolchain.cmake : toolchain.cmake.in $(host_prefix)/.stamp_ -e 's|@OBJCOPY@|$(host_OBJCOPY)|' \ -e 's|@INSTALL_NAME_TOOL@|$(host_INSTALL_NAME_TOOL)|' \ -e 's|@OTOOL@|$(host_OTOOL)|' \ - -e 's|@depends_prefix@|$(host_prefix)|' \ -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index 55c04ec48dff8..ca918ede4d871 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -59,18 +59,31 @@ set(CMAKE_OBJCOPY "@OBJCOPY@") set(CMAKE_INSTALL_NAME_TOOL "@INSTALL_NAME_TOOL@") set(OTOOL "@OTOOL@") -# Using our own built dependencies should not be -# affected by a potentially random environment. -set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF) -set(CMAKE_FIND_ROOT_PATH "@depends_prefix@") +# Path settings +# ============= + +# Point CMake to search in the ${CMAKE_FIND_ROOT_PATH}/${CMAKE_PREFIX_PATH} +# directory when using find_library(), find_file(), find_path(), and +# find_package() commands. +cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH CMAKE_FIND_ROOT_PATH) +cmake_path(SET CMAKE_PREFIX_PATH "/") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -set(PKG_CONFIG_PATH "@depends_prefix@/lib/pkgconfig") +# Using our own built dependencies should not be affected by a potentially +# random environment. +set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH NO) +set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH NO) + +cmake_path(APPEND CMAKE_FIND_ROOT_PATH "lib" "pkgconfig" OUTPUT_VARIABLE PKG_CONFIG_PATH) set(PKG_CONFIG_LIBDIR "${PKG_CONFIG_PATH}") -set(QT_TRANSLATIONS_DIR "@depends_prefix@/translations") +# Defining the prefix variable explicitly makes depends relocatable, which +# simplifies, for example, building on NixOS. +set(PKG_CONFIG_ARGN "--define-variable=prefix=${CMAKE_FIND_ROOT_PATH}") + +cmake_path(APPEND CMAKE_FIND_ROOT_PATH "translations" OUTPUT_VARIABLE QT_TRANSLATIONS_DIR) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) # The find_package(Qt ...) function internally uses find_library() @@ -80,6 +93,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) set(CMAKE_FRAMEWORK_PATH "@OSX_SDK@/System/Library/Frameworks") endif() + +# Build options +# ============= + # Ensure that the docstrings in the following `set(... CACHE ...)` # commands match those in the root CMakeLists.txt file.