cmake: Include GNUInstallDirs earlier for BINDIR etc to take effect

GNUInstallDirs is what defines CMAKE_INSTALL_FULL_BINDIR and such, so
the setting in Rust.cmake didn't work.

This also makes build.rs error out if any of these aren't defined
This commit is contained in:
Fabian Boehm 2024-01-10 17:41:34 +01:00
parent 2aee930659
commit cb51b236f3
3 changed files with 7 additions and 21 deletions

View file

@ -24,6 +24,10 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
endif()
# Set up standard directories.
include(GNUInstallDirs)
add_definitions(-D_UNICODE=1)
include(cmake/ConfigureChecks.cmake)
include(cmake/gettext.cmake)
@ -110,18 +114,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Pull in our src directory for headers searches, but only quoted ones.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR}/src")
# Set up standard directories.
include(GNUInstallDirs)
add_definitions(-D_UNICODE=1
-DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
-DPREFIX=L"${CMAKE_INSTALL_PREFIX}"
-DDATADIR=L"${CMAKE_INSTALL_FULL_DATADIR}"
-DSYSCONFDIR=L"${CMAKE_INSTALL_FULL_SYSCONFDIR}"
-DBINDIR=L"${CMAKE_INSTALL_FULL_BINDIR}"
-DDOCDIR=L"${CMAKE_INSTALL_FULL_DOCDIR}")
# Set up the machinery around FISH-BUILD-VERSION-FILE
# This defines the FBVF variable.
include(Version)

View file

@ -41,15 +41,6 @@ set(extra_confdir
CACHE STRING "Path for extra configuration")
corrosion_set_env_vars(${fish_rust_target}
"PREFIX=${prefix}"
# Temporary hack to propogate CMake flags/options to build.rs.
"CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}"
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
"BINDIR=${CMAKE_INSTALL_FULL_BINDIR}"
)
# These are the man pages that go in system manpath; all manpages go in the fish-specific manpath.
set(MANUALS ${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish.1
${CMAKE_CURRENT_BINARY_DIR}/user_doc/man/man1/fish_indent.1

View file

@ -8,6 +8,9 @@ fn main() {
for key in ["DOCDIR", "DATADIR", "SYSCONFDIR", "BINDIR", "LOCALEDIR"] {
if let Ok(val) = env::var(key) {
// Forward some CMake config
if val.is_empty() {
panic!("{} is empty!", key);
}
println!("cargo:rustc-env={key}={val}");
}
}