]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Add LOCALEDIR to the windres workaround.
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 22 Feb 2024 17:16:35 +0000 (19:16 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 22 Feb 2024 17:16:35 +0000 (19:16 +0200)
LOCALEDIR may contain spaces like in "C:\Program Files".

CMakeLists.txt

index b7047dc0582a755395019e31abbb33ee5d594407..06282b4d6257ea241e7a2ca51d5dbe52f37c2cef 100644 (file)
@@ -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
@@ -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:
@@ -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}")
@@ -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()
 
@@ -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)