Skip to content

Commit

Permalink
Merge bitcoin#29706: depends: set two CMake options globally
Browse files Browse the repository at this point in the history
76045bb depends: always set CMAKE_POSITION_INDEPENDENT_CODE=ON (fanquake)
d046236 depends: always set CMAKE_INSTALL_LIBDIR=lib/ (fanquake)

Pull request description:

  Set `CMAKE_INSTALL_LIBDIR=lib/` and `CMAKE_POSITION_INDEPENDENT_CODE=ON` globally in depends, rather than per-package. `CMAKE_INSTALL_LIBDIR=lib/` is needed to override the annoying [`GNUInstallDirs`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html) `lib` vs `lib64` behaviour, and we always want PIC code. The PIC commit is the counterpart to the same Autotools change in bitcoin#29488. I'm PRing these commits as I have a CMake branch building on top, and want to avoid adding the same workarounds to every package we are going to touch, but these can go in separately as the build should be tested for existing packages (i.e multiprocess).

ACKs for top commit:
  hebasto:
    re-ACK 76045bb.
  theuni:
    utACK 76045bb. Both changes make sense to me, and both can be overridden if needed, though I can't imagine we'd need to.

Tree-SHA512: 655a0b6b7ee5a5820f52e8e919ef03fc216d29f13f3904f72b64ce57436510e073c903039488d5740535c56e1f6221267229238c5231de5f8467d238fd562578
  • Loading branch information
fanquake committed Mar 25, 2024
2 parents 220487b + 76045bb commit 2102c97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
9 changes: 8 additions & 1 deletion depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,19 @@ 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/ \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
$$($(1)_config_opts)
ifeq ($($(1)_type),build)
$(1)_cmake += -DCMAKE_INSTALL_RPATH:PATH="$$($($(1)_type)_prefix)/lib"
else
Expand Down
2 changes: 1 addition & 1 deletion depends/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 0 additions & 5 deletions depends/packages/capnp.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions depends/packages/libmultiprocess.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +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"
$(package)_config_opts += -DCAPNPC_CXX_EXECUTABLE="$$(native_capnp_prefixbin)/capnpc-c++"
Expand Down

0 comments on commit 2102c97

Please sign in to comment.