Skip to content

Commit

Permalink
CMake: Add LOCALEDIR to the windres workaround.
Browse files Browse the repository at this point in the history
LOCALEDIR may contain spaces like in "C:\Program Files".
  • Loading branch information
Larhzu committed Feb 22, 2024
1 parent de4337f commit 4c81c96
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
# On Apple OSes, don't build executables as bundles:
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
# that contain spaces or other funny characters. Unfortunately we need
# a space in PACKAGE_NAME. Using \x20 to encode the US-ASCII space seems
Expand Down Expand Up @@ -185,10 +189,15 @@ if((MINGW OR CYGWIN OR MSYS) AND (
# Keep the original PACKAGE_NAME intact for generation of liblzma.pc.
string(APPEND CMAKE_RC_FLAGS " --use-temp-file")
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()
# Elsewhere a space is safe. This also keeps things compatible with
# EBCDIC in case CMake-based build is ever done on such a system.
set(PACKAGE_NAME_DEFINITION "${PACKAGE_NAME}")
set(LOCALEDIR_DEFINITION "${CMAKE_INSTALL_FULL_LOCALEDIR}")
endif()

# Definitions common to all targets:
Expand Down Expand Up @@ -1306,9 +1315,6 @@ endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/liblzma-config.cmake"
"${LZMA_CONFIG_CONTENTS}")

# Set CMAKE_INSTALL_LIBDIR and friends.
include(GNUInstallDirs)

# Create liblzma.pc.
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
Expand Down Expand Up @@ -1596,7 +1602,7 @@ if(HAVE_DECODERS AND (NOT MSVC OR MSVC_VERSION GREATER_EQUAL 1900))
target_compile_definitions(lzmainfo PRIVATE
ENABLE_NLS
PACKAGE="${TRANSLATION_DOMAIN}"
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
LOCALEDIR="${LOCALEDIR_DEFINITION}"
)
endif()

Expand Down Expand Up @@ -1750,7 +1756,7 @@ if(NOT MSVC OR MSVC_VERSION GREATER_EQUAL 1900)
target_compile_definitions(xz PRIVATE
ENABLE_NLS
PACKAGE="${TRANSLATION_DOMAIN}"
LOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
LOCALEDIR="${LOCALEDIR_DEFINITION}"
)

file(STRINGS po/LINGUAS LINGUAS)
Expand Down

0 comments on commit 4c81c96

Please sign in to comment.