cmake: Define all targets, but only build ALL_MULTILANG by default

ALL_ENGLISH is mostly intended for debugging purposes
This commit is contained in:
Yuri D'Elia 2022-10-03 17:51:31 +02:00
parent 63605f4c86
commit 7e56a8255b
1 changed files with 13 additions and 13 deletions

View File

@ -306,15 +306,17 @@ endif()
# ".po" "" LANG_VARIANTS "${LANG_VARIANTS}") list(SORT LANG_VARIANTS) # ".po" "" LANG_VARIANTS "${LANG_VARIANTS}") list(SORT LANG_VARIANTS)
# message("Languages found: ${LANG_VARIANTS}") # message("Languages found: ${LANG_VARIANTS}")
# Meta target to build absolutely everything # Meta targets to build absolutely everything
add_custom_target(ALL_FIRMWARE) add_custom_target(ALL_FIRMWARE)
add_custom_target(ALL_ENGLISH) add_custom_target(ALL_ENGLISH)
add_custom_target(ALL_MULTILANG) add_custom_target(ALL_MULTILANG)
add_dependencies(ALL_FIRMWARE ALL_ENGLISH ALL_MULTILANG) add_dependencies(ALL_FIRMWARE ALL_ENGLISH ALL_MULTILANG)
set_target_properties(ALL_MULTILANG PROPERTIES EXCLUDE_FROM_ALL FALSE)
function(add_base_binary variant_name) function(add_base_binary variant_name)
add_executable(${variant_name} ${FW_SOURCES} ${FW_HEADERS} add_executable(${variant_name} ${FW_SOURCES} ${FW_HEADERS}
${VARIANT_CFG_FILE}) ${VARIANT_CFG_FILE})
set_target_properties(${variant_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
target_include_directories( target_include_directories(
${variant_name} ${variant_name}
@ -378,8 +380,9 @@ function(fw_add_variant variant_name)
string(REPLACE "1_75mm_" "" variant_name "${variant_name}") string(REPLACE "1_75mm_" "" variant_name "${variant_name}")
string(REPLACE "-E3Dv6full" "" variant_name "${variant_name}") string(REPLACE "-E3Dv6full" "" variant_name "${variant_name}")
# Single-language build
set(FW_EN "${variant_name}_EN-only") set(FW_EN "${variant_name}_EN-only")
set(FW_MULTI "${variant_name}_Multilang") set(FW_HEX ${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_EN}.hex)
add_base_binary(${FW_EN}) add_base_binary(${FW_EN})
# target_compile_options(${variant_name} PRIVATE) # turn this on for lolz # target_compile_options(${variant_name} PRIVATE) # turn this on for lolz
@ -390,17 +393,14 @@ function(fw_add_variant variant_name)
TARGET ${FW_EN} TARGET ${FW_EN}
POST_BUILD POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O ihex ${CMAKE_CURRENT_BINARY_DIR}/${FW_EN} COMMAND ${CMAKE_OBJCOPY} -O ihex ${CMAKE_CURRENT_BINARY_DIR}/${FW_EN}
${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_EN}.hex ${FW_HEX}
BYPRODUCTS ${CMAKE_BINARY_DIR}/${FN_PREFIX}-${FW_EN}.hex BYPRODUCTS ${FW_HEX}
COMMENT "Generating ${variant_name} hex") COMMENT "Generating ${FW_EN}.hex")
add_dependencies(ALL_ENGLISH "${FW_EN}") add_dependencies(ALL_ENGLISH ${FW_EN})
if(NOT SECONDARY_LANGUAGES) # Multi-language build/s
return() # Done, if no languages there's nothing else to do. add_base_binary(${FW_MULTI})
else() target_compile_definitions(${FW_MULTI} PUBLIC LANG_MODE=1)
add_base_binary(${FW_MULTI})
target_compile_definitions(${FW_MULTI} PUBLIC LANG_MODE=1)
endif()
# Construct language map # Construct language map
set(LANG_TMP_DIR ${CMAKE_BINARY_DIR}/${variant_name}/lang) set(LANG_TMP_DIR ${CMAKE_BINARY_DIR}/${variant_name}/lang)
@ -441,8 +441,8 @@ function(fw_add_variant variant_name)
DEPENDS ${LANG_MAP} DEPENDS ${LANG_MAP}
COMMENT "Generating ${variant_name}_${LANG}.bin from .po") COMMENT "Generating ${variant_name}_${LANG}.bin from .po")
list(APPEND LANG_BINS ${LANG_BIN}) list(APPEND LANG_BINS ${LANG_BIN})
endforeach() endforeach()
string(FIND ${variant_name} "MK3" HAS_XFLASH) string(FIND ${variant_name} "MK3" HAS_XFLASH)
if(${HAS_XFLASH} GREATER_EQUAL 0) if(${HAS_XFLASH} GREATER_EQUAL 0)
add_custom_command( add_custom_command(