1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

CMake: Add LOCALEDIR to the windres workaround.

LOCALEDIR may contain spaces like in "C:\Program Files".
This commit is contained in:
Lasse Collin 2024-02-22 19:16:35 +02:00
parent de4337fd89
commit 4c81c9611f

View file

@ -158,6 +158,10 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
# On Apple OSes, don't build executables as bundles: # On Apple OSes, don't build executables as bundles:
set(CMAKE_MACOSX_BUNDLE OFF) set(CMAKE_MACOSX_BUNDLE OFF)
# Set CMAKE_INSTALL_LIBDIR and friends. This needs to be done before
# the LOCALEDIR_DEFINITION workaround below.
include(GNUInstallDirs)
# windres from GNU binutils can be tricky with command line arguments # windres from GNU binutils can be tricky with command line arguments
# that contain spaces or other funny characters. Unfortunately we need # that contain spaces or other funny characters. Unfortunately we need
# a space in PACKAGE_NAME. Using \x20 to encode the US-ASCII space seems # a space in PACKAGE_NAME. Using \x20 to encode the US-ASCII space seems
@ -185,10 +189,15 @@ if((MINGW OR CYGWIN OR MSYS) AND (
# Keep the original PACKAGE_NAME intact for generation of liblzma.pc. # Keep the original PACKAGE_NAME intact for generation of liblzma.pc.
string(APPEND CMAKE_RC_FLAGS " --use-temp-file") string(APPEND CMAKE_RC_FLAGS " --use-temp-file")
string(REPLACE " " "\\x20" PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}") string(REPLACE " " "\\x20" PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}")
# Use octal because "Program Files" would become \x20F.
string(REPLACE " " "\\040" LOCALEDIR_DEFINITION
"${CMAKE_INSTALL_FULL_LOCALEDIR}")
else() else()
# Elsewhere a space is safe. This also keeps things compatible with # Elsewhere a space is safe. This also keeps things compatible with
# EBCDIC in case CMake-based build is ever done on such a system. # EBCDIC in case CMake-based build is ever done on such a system.
set(PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}") set(PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}")
set(LOCALEDIR_DEFINITION "${CMAKE_INSTALL_FULL_LOCALEDIR}")
endif() endif()
# Definitions common to all targets: # Definitions common to all targets:
@ -1306,9 +1315,6 @@ endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/liblzma-config.cmake" file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/liblzma-config.cmake"
"${LZMA_CONFIG_CONTENTS}") "${LZMA_CONFIG_CONTENTS}")
# Set CMAKE_INSTALL_LIBDIR and friends.
include(GNUInstallDirs)
# Create liblzma.pc. # Create liblzma.pc.
set(prefix "${CMAKE_INSTALL_PREFIX}") set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
@ -1596,7 +1602,7 @@ if(HAVE_DECODERS AND (NOT MSVC OR MSVC_VERSION GREATER_EQUAL 1900))
target_compile_definitions(lzmainfo PRIVATE target_compile_definitions(lzmainfo PRIVATE
ENABLE_NLS ENABLE_NLS
PACKAGE="${TRANSLATION_DOMAIN}" PACKAGE="${TRANSLATION_DOMAIN}"
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}" LOCALEDIR="${LOCALEDIR_DEFINITION}"
) )
endif() endif()
@ -1750,7 +1756,7 @@ if(NOT MSVC OR MSVC_VERSION GREATER_EQUAL 1900)
target_compile_definitions(xz PRIVATE target_compile_definitions(xz PRIVATE
ENABLE_NLS ENABLE_NLS
PACKAGE="${TRANSLATION_DOMAIN}" PACKAGE="${TRANSLATION_DOMAIN}"
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}" LOCALEDIR="${LOCALEDIR_DEFINITION}"
) )
file(STRINGS po/LINGUAS LINGUAS) file(STRINGS po/LINGUAS LINGUAS)