KeyWorksRW / wxUiEditor

RAD tool used to create and maintain wxWidgets UI elements.
Apache License 2.0
62 stars 5 forks source link

Support data list in .cmake file #1442

Closed Randalphwa closed 3 months ago

Randalphwa commented 3 months ago

See PR description for more details

This PR adds the list of data files in any gen_Data node to an additional macro in any generated .cmake file. It takes the variable name the dev specified for the main source file list, appends _data and generates the list from that.

Sample usage:

# Custom command to generate UI code
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/ui/wxue_data.cc
    COMMAND wxUiEditor --gen_cpp ../src/ui/MyProject.wxui
    COMMAND type ..\\src\\ui\\MyProject.log
    DEPENDS ${wxue_generated_code_data}
    COMMENT "Generating UI code..."
)

# Add a custom target to ensure the command is run before the main target
add_custom_target(GenerateUiCode DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/ui/wxue_data.cc)

add_executable(MyProgram
    ${srcfile_list}
    ${wxue_generated_code}
)

add_dependencies(MyProgram GenerateUiCode)

The above will result in wxUiEditor being called to regenerate wxue_data.cc if any of the data files have changed since the last time the code was generated.