2022-12-07 09:30:22 +08:00
|
|
|
# CMake does not automatically add --whole-archive when building shared objects from
|
|
|
|
# a list of convenience libraries. This can lead to missing symbols in the final output.
|
|
|
|
# We add --whole-archive to all libraries manually to prevent the linker from trimming
|
|
|
|
# symbols that we actually need later.
|
|
|
|
macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
|
|
|
|
foreach (library IN LISTS ${_list_name})
|
|
|
|
list(APPEND ${_list_name}_TMP -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
|
|
|
|
endforeach ()
|
|
|
|
set(${_list_name} "${${_list_name}_TMP}")
|
|
|
|
endmacro()
|
2021-06-24 10:12:55 +08:00
|
|
|
|
2022-01-23 15:57:09 +08:00
|
|
|
function(CreatePAK project ResourceDIR PakPath rhpath)
|
2022-02-14 14:49:34 +08:00
|
|
|
add_custom_target(${project}_assets
|
2022-01-25 09:46:58 +08:00
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/scripts/idgen.py ${ResourceDIR} ${rhpath}
|
2022-02-08 14:48:57 +08:00
|
|
|
COMMAND zip -r -D -0 ${PakPath} ./
|
2022-01-23 22:30:57 +08:00
|
|
|
WORKING_DIRECTORY ${ResourceDIR}
|
|
|
|
COMMENT "Pckage Assets from ${ResourceDIR} to:${PakPath}")
|
2022-02-14 14:49:34 +08:00
|
|
|
add_dependencies(${project} ${project}_assets)
|
2022-01-14 16:49:02 +08:00
|
|
|
install(FILES ${PakPath} DESTINATION data)
|
2021-06-24 10:12:55 +08:00
|
|
|
endfunction()
|
|
|
|
|
2022-01-24 19:07:23 +08:00
|
|
|
function(CreatePO SourceDIR POPath projectname)
|
|
|
|
file(GLOB_RECURSE ${projectname}_POSRCS "*.c" "*.cc" "*.cpp" "*.h" "*.hpp")
|
2021-12-17 16:59:10 +08:00
|
|
|
add_custom_target(${projectname}_po
|
2022-01-24 19:07:23 +08:00
|
|
|
COMMAND touch ${POPath}/${projectname}.po
|
|
|
|
COMMAND xgettext -d ${projectname} -j -c -p${POPath} -kTEXT ${${projectname}_POSRCS}
|
2021-06-24 10:12:55 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
)
|
2021-12-29 10:13:02 +08:00
|
|
|
add_dependencies( ${projectname} ${projectname}_po)
|
2021-06-24 10:12:55 +08:00
|
|
|
endfunction()
|
|
|
|
|
2022-01-14 16:49:02 +08:00
|
|
|
function(Translate pofile transtopath)
|
|
|
|
add_custom_target(translate
|
2022-01-24 19:07:23 +08:00
|
|
|
#po2json translate pofile to string_xx.json
|
|
|
|
COMMAND python ${CMAKE_SOURCE_DIR}/scripts/po2json.py ${pofile}
|
|
|
|
# convert xls (after your custom finished translate) to string_xx.json for pak
|
|
|
|
#COMMAND python ${CMAKE_SOURCE_DIR}/src/tools/po2json.py ${CMAKE_CURRENT_BINARY_DIR}/newglee.po.xls
|
2022-01-14 16:49:02 +08:00
|
|
|
COMMAND cp ${PROJECT_BINARY_DIR}/string*.json ${PROJECT_SOURCE_DIR}/assets/strings
|
|
|
|
BYPRODUCTS ntvplus
|
|
|
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
|
|
|
COMMENT "Translate strings resource...${PROJECT_BINARY_DIR}"
|
|
|
|
)
|
|
|
|
endfunction()
|
2022-02-21 16:30:34 +08:00
|
|
|
|