Skip to content

Commit

Permalink
fixup! build: Generate share/toolchain.cmake in depends
Browse files Browse the repository at this point in the history
Define depends prefix relatively to the toolchain file location (the
same way it is done for the `config.site` file).

Should fix building on NixOS.
  • Loading branch information
hebasto committed Mar 23, 2024
1 parent a6a746e commit a2ba8f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
1 change: 0 additions & 1 deletion depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))|' \
Expand Down
29 changes: 23 additions & 6 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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.

Expand Down

0 comments on commit a2ba8f3

Please sign in to comment.