Skip to content

Commit

Permalink
Merge pull request #585 from elbeno/more-gen-str-args
Browse files Browse the repository at this point in the history
✨ Plumb extra arguments to `gen_str_catalog`
  • Loading branch information
lukevalenty authored Jul 19, 2024
2 parents a7a8034 + 239930b commit a4c596e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
27 changes: 24 additions & 3 deletions cmake/string_catalog.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
function(gen_str_catalog)
set(options FORGET_OLD_IDS)
set(oneValueArgs OUTPUT_CPP OUTPUT_XML OUTPUT_JSON GEN_STR_CATALOG
OUTPUT_LIB)
set(oneValueArgs
OUTPUT_CPP
OUTPUT_XML
OUTPUT_JSON
GEN_STR_CATALOG
OUTPUT_LIB
CLIENT_NAME
VERSION
GUID_ID
GUID_MASK)
set(multiValueArgs INPUT_JSON INPUT_LIBS INPUT_HEADERS STABLE_JSON)
cmake_parse_arguments(SC "${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN})
Expand Down Expand Up @@ -34,6 +42,18 @@ function(gen_str_catalog)
if(SC_FORGET_OLD_IDS)
set(FORGET_ARG "--forget_old_ids")
endif()
if(SC_CLIENT_NAME)
set(CLIENT_NAME_ARG --client_name ${SC_CLIENT_NAME})
endif()
if(SC_VERSION)
set(VERSION_ARG --version ${SC_VERSION})
endif()
if(SC_GUID_ID)
set(GUID_ID_ARG --guid_id ${SC_GUID_ID})
endif()
if(SC_GUID_MASK)
set(GUID_MASK_ARG --guid_mask ${SC_GUID_MASK})
endif()

add_custom_command(
OUTPUT ${SC_OUTPUT_CPP} ${SC_OUTPUT_JSON} ${SC_OUTPUT_XML}
Expand All @@ -42,7 +62,8 @@ function(gen_str_catalog)
--json_input ${SC_INPUT_JSON} --cpp_headers ${SC_INPUT_HEADERS}
--cpp_output ${SC_OUTPUT_CPP} --json_output ${SC_OUTPUT_JSON}
--xml_output ${SC_OUTPUT_XML} --stable_json ${SC_STABLE_JSON}
${FORGET_ARG}
${FORGET_ARG} ${CLIENT_NAME_ARG} ${VERSION_ARG} ${GUID_ID_ARG}
${GUID_MASK_ARG}
DEPENDS ${UNDEFS} ${INPUT_JSON} ${SC_GEN_STR_CATALOG} ${SC_STABLE_JSON}
COMMAND_EXPAND_LISTS)
if(SC_OUTPUT_LIB)
Expand Down
10 changes: 9 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ gen_str_catalog(
STABLE_JSON
log/stable_strings.json
INPUT_HEADERS
log/catalog_enums.hpp)
log/catalog_enums.hpp
CLIENT_NAME
"test"
VERSION
"test version"
GUID_ID
"01234567-89ab-cdef-0123-456789abcdef"
GUID_MASK
"ffffffff-ffff-ffff-ffff-ffffffffffff")

add_library(catalog_strings STATIC ${CMAKE_CURRENT_BINARY_DIR}/strings.cpp)
target_link_libraries(catalog_strings PUBLIC cib)
Expand Down

0 comments on commit a4c596e

Please sign in to comment.