Skip to content

Commit

Permalink
Bring back LOCALEDIR
Browse files Browse the repository at this point in the history
* The current infrastructure relies on `LOCALEDIR`
  in places beyond CMake, hence we need to keep
  it for the time being.

Fixes #2211
  • Loading branch information
SoapGentoo authored and GregoryLundberg committed Nov 18, 2017
1 parent d8efb9a commit 0f2b585
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
20 changes: 11 additions & 9 deletions CMakeLists.txt
Expand Up @@ -28,6 +28,7 @@ include(GNUInstallDirs)
#Path options
set(DATADIRNAME "wesnoth" CACHE STRING "change the name of the directory for the read-only architecture-independent game data")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}" CACHE STRING "change the dir where binaries are placed right at compile time")
set(LOCALEDIR "translations" CACHE STRING "change the name of the locale data directory to a non-default name")
set(PREFERENCES_DIR "" CACHE STRING "Use a non-default preferences directory (.wesnoth on unix)")
set(DEFAULT_PREFS_FILE "" CACHE STRING "Set system wide preferences file")

Expand Down Expand Up @@ -483,6 +484,8 @@ if(X11_FOUND)
add_definitions(-D_X11)
endif(X11_FOUND)

add_definitions(-DLOCALEDIR="${LOCALEDIR}")

# -NDEBUG is automatically added to all release build types, so manually remove
# this define from the related variables
MESSAGE ("removing NDEBUG flag from CMAKE_CXX_FLAGS_RELWITHDEBINFO")
Expand Down Expand Up @@ -659,16 +662,15 @@ endif()
# End setting options for Profile build
# #

# On Windows the path used is always relative.
if(WIN32)
add_definitions(-DHAS_RELATIVE_LOCALEDIR=1)
file(RELATIVE_PATH LOCALEDIR "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_FULL_LOCALEDIR}")
else(WIN32)
# When the path starts with a / on a Unix system it's an absolute path.
# This means that on Windows the path used is always relative.
if(IS_ABSOLUTE "${LOCALEDIR}")
add_definitions(-DHAS_RELATIVE_LOCALEDIR=0)
set(LOCALEDIR "${CMAKE_INSTALL_FULL_LOCALEDIR}")
endif(WIN32)

add_definitions(-DLOCALEDIR="${LOCALEDIR}")
set(LOCALE_INSTALL ${LOCALEDIR})
else()
add_definitions(-DHAS_RELATIVE_LOCALEDIR=1)
set(LOCALE_INSTALL ${CMAKE_INSTALL_DATADIR}/${DATADIRNAME}/${LOCALEDIR})
endif()

add_definitions(-DFIFODIR="${FIFO_DIR}")

Expand Down
20 changes: 10 additions & 10 deletions po/CMakeLists.txt
Expand Up @@ -229,32 +229,32 @@ if(ENABLE_NLS)
foreach(DOMAIN ${DOMAINS})

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
COMMENT "mo-update [${LINGUA}]: Creating locale directory."
)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
${GETTEXT_MSGFMT_PARAMETER}
-o ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo ${LINGUA}.po
-o ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo ${LINGUA}.po
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LINGUA}.po
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/po/${DOMAIN}
COMMENT "mo-update [${DOMAIN}-${LINGUA}]: Creating mo file."
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${LINGUA}/LC_MESSAGES)
install(FILES ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
DESTINATION ${LOCALE_INSTALL}/${LINGUA}/LC_MESSAGES)

set(mo-update-SRC ${mo-update-SRC}
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
)
set(mo-update-LINGUA-SRC ${mo-update-LINGUA-SRC}
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
)

endforeach(DOMAIN ${DOMAINS})
Expand All @@ -276,7 +276,7 @@ if(ENABLE_NLS)
)

set_directory_properties(properties
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_SOURCE_DIR}/${LOCALEDIR}
)

endif(ENABLE_NLS)
Expand Down

0 comments on commit 0f2b585

Please sign in to comment.