From d04623678c70ff58a20fb5c35d33cb8f483f1efb Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 22 Mar 2024 16:48:18 +0000 Subject: [PATCH 1/2] depends: always set CMAKE_INSTALL_LIBDIR=lib/ Rather than setting this per package, set it globally, as this is always what we want. Without doing this, later commit will have to add the same doc + change to more packages. --- depends/funcs.mk | 8 +++++++- depends/packages/capnp.mk | 5 ----- depends/packages/libmultiprocess.mk | 5 ----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/depends/funcs.mk b/depends/funcs.mk index 0251b913005..0d3bc2c5261 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -170,12 +170,18 @@ ifneq ($($(1)_ldflags),) $(1)_autoconf += LDFLAGS="$$($(1)_ldflags)" endif +# We hardcode the library install path to "lib" to match the PKG_CONFIG_PATH +# setting in depends/config.site.in, which also hardcodes "lib". +# Without this setting, CMake by default would use the OS library +# directory, which might be "lib64" or something else, not "lib", on multiarch systems. $(1)_cmake=env CC="$$($(1)_cc)" \ CFLAGS="$$($(1)_cppflags) $$($(1)_cflags)" \ CXX="$$($(1)_cxx)" \ CXXFLAGS="$$($(1)_cppflags) $$($(1)_cxxflags)" \ LDFLAGS="$$($(1)_ldflags)" \ - cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" $$($(1)_config_opts) + cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" \ + -DCMAKE_INSTALL_LIBDIR=lib/ \ + $$($(1)_config_opts) ifeq ($($(1)_type),build) $(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib" else diff --git a/depends/packages/capnp.mk b/depends/packages/capnp.mk index 2465c8091bb..6d792db7113 100644 --- a/depends/packages/capnp.mk +++ b/depends/packages/capnp.mk @@ -5,15 +5,10 @@ $(package)_download_file=$(native_$(package)_download_file) $(package)_file_name=$(native_$(package)_file_name) $(package)_sha256_hash=$(native_$(package)_sha256_hash) -# Hardcode library install path to "lib" to match the PKG_CONFIG_PATH -# setting in depends/config.site.in, which also hardcodes "lib". -# Without this setting, cmake by default would use the OS library -# directory, which might be "lib64" or something else, not "lib", on multiarch systems. define $(package)_set_vars := $(package)_config_opts := -DBUILD_TESTING=OFF $(package)_config_opts += -DWITH_OPENSSL=OFF $(package)_config_opts += -DWITH_ZLIB=OFF - $(package)_config_opts += -DCMAKE_INSTALL_LIBDIR=lib/ endef define $(package)_config_cmds diff --git a/depends/packages/libmultiprocess.mk b/depends/packages/libmultiprocess.mk index d237f52dbb2..03527100d42 100644 --- a/depends/packages/libmultiprocess.mk +++ b/depends/packages/libmultiprocess.mk @@ -8,12 +8,7 @@ ifneq ($(host),$(build)) $(package)_dependencies += native_capnp endif -# Hardcode library install path to "lib" to match the PKG_CONFIG_PATH -# setting in depends/config.site.in, which also hardcodes "lib". -# Without this setting, cmake by default would use the OS library -# directory, which might be "lib64" or something else, not "lib", on multiarch systems. define $(package)_set_vars := -$(package)_config_opts += -DCMAKE_INSTALL_LIBDIR=lib/ $(package)_config_opts += -DCMAKE_POSITION_INDEPENDENT_CODE=ON ifneq ($(host),$(build)) $(package)_config_opts := -DCAPNP_EXECUTABLE="$$(native_capnp_prefixbin)/capnp" From 76045bb9d6808931cd0f2933203b5b611e032ec8 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 22 Mar 2024 16:50:40 +0000 Subject: [PATCH 2/2] depends: always set CMAKE_POSITION_INDEPENDENT_CODE=ON Rather than potentially having to set this per-package, set it globally, as this should always be what we want. Without doing this, changes in later commits will have to add this per-package. Similar to https://github.com/bitcoin/bitcoin/pull/29488, which is the Autotools equivalent. --- depends/funcs.mk | 1 + depends/packages.md | 2 +- depends/packages/libmultiprocess.mk | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/funcs.mk b/depends/funcs.mk index 0d3bc2c5261..494ed5d3245 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -181,6 +181,7 @@ $(1)_cmake=env CC="$$($(1)_cc)" \ LDFLAGS="$$($(1)_ldflags)" \ cmake -DCMAKE_INSTALL_PREFIX:PATH="$$($($(1)_type)_prefix)" \ -DCMAKE_INSTALL_LIBDIR=lib/ \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ $$($(1)_config_opts) ifeq ($($(1)_type),build) $(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib" diff --git a/depends/packages.md b/depends/packages.md index c288032766d..0ffdc66d488 100644 --- a/depends/packages.md +++ b/depends/packages.md @@ -163,7 +163,7 @@ From the [Gentoo Wiki entry](https://wiki.gentoo.org/wiki/Project:Quality_Assura > ecosystem, as it leads to a massive number of unnecessary rebuilds. Where possible, packages are built with Position Independant Code. Either using -the autotools `--with-pic` flag, or `DCMAKE_POSITION_INDEPENDENT_CODE` with CMake. +the Autotools `--with-pic` flag, or `CMAKE_POSITION_INDEPENDENT_CODE` with CMake. ## Secondary dependencies: diff --git a/depends/packages/libmultiprocess.mk b/depends/packages/libmultiprocess.mk index 03527100d42..765d6493776 100644 --- a/depends/packages/libmultiprocess.mk +++ b/depends/packages/libmultiprocess.mk @@ -9,7 +9,6 @@ $(package)_dependencies += native_capnp endif define $(package)_set_vars := -$(package)_config_opts += -DCMAKE_POSITION_INDEPENDENT_CODE=ON ifneq ($(host),$(build)) $(package)_config_opts := -DCAPNP_EXECUTABLE="$$(native_capnp_prefixbin)/capnp" $(package)_config_opts += -DCAPNPC_CXX_EXECUTABLE="$$(native_capnp_prefixbin)/capnpc-c++"