forked from CelestiaProject/Celestia
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[win] build DLLs with UI translation
- Loading branch information
Showing
5 changed files
with
168 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function(_WINDRES_GET_UNIQUE_TARGET_NAME _name _unique_name) | ||
set(propertyName "_WINDRES_UNIQUE_COUNTER_${_name}") | ||
get_property(currentCounter GLOBAL PROPERTY "${propertyName}") | ||
if(NOT currentCounter) | ||
set(currentCounter 1) | ||
endif() | ||
set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE) | ||
math(EXPR currentCounter "${currentCounter} + 1") | ||
set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} ) | ||
endfunction() | ||
|
||
macro(WINDRES_CREATE_TRANSLATIONS _rcFile _firstPoFileArg) | ||
# make it a real variable, so we can modify it here | ||
set(_firstPoFile "${_firstPoFileArg}") | ||
|
||
set(_addToAll) | ||
if(${_firstPoFile} STREQUAL "ALL") | ||
set(_addToAll "ALL") | ||
set(_firstPoFile) | ||
endif() | ||
|
||
set(_dllFiles) | ||
foreach(_currentPoFile ${_firstPoFile} ${ARGN}) | ||
get_filename_component(_absFile ${_currentPoFile} ABSOLUTE) | ||
get_filename_component(_lang ${_absFile} NAME_WE) | ||
set(_locRcFile ${CMAKE_CURRENT_BINARY_DIR}/celestia_${_lang}.rc) | ||
set(_dllFile res_${_lang}) | ||
|
||
add_custom_command( | ||
OUTPUT ${_locRcFile} | ||
COMMAND perl ${CMAKE_SOURCE_DIR}/po/translate_resources.pl ${_lang} | ||
DEPENDS ${_absFile} | ||
) | ||
|
||
add_library(${_dllFile} MODULE ${_locRcFile}) | ||
set_target_properties(${_dllFile} PROPERTIES PREFIX "" LINKER_LANGUAGE C) | ||
if(MSVC) | ||
set_target_properties(${_dllFile} PROPERTIES LINK_FLAGS "/MANIFEST:NO /NODEFAULTLIB /NOENTRY") | ||
endif() | ||
|
||
install(TARGETS ${_dllFile} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
set(_dllFiles ${_dllFiles} ${_dllFile}) | ||
endforeach() | ||
|
||
if(NOT TARGET resources) | ||
add_custom_target(resources) | ||
endif() | ||
|
||
_WINDRES_GET_UNIQUE_TARGET_NAME(resources uniqueTargetName) | ||
add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_dllFiles}) | ||
add_dependencies(resources ${uniqueTargetName}) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
if(NOT ENABLE_NLS) | ||
return() | ||
endif() | ||
|
||
include(windres) | ||
|
||
file(GLOB PO_FILES2 "${CMAKE_SOURCE_DIR}/po/*.po") | ||
WINDRES_CREATE_TRANSLATIONS(celestia.rc ALL ${PO_FILES2}) |