Help to run cmake before embed_file

User avatar
urbanze
Posts: 301
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: Help to run cmake before embed_file

Postby urbanze » Fri Oct 04, 2024 12:38 pm


This video bring me an idea with POST_BUILD. I used POST_BUILD to delete zip folder after build proccess and worked! Since compiling from scratch or recompiling are working correctly because system are forced to re-zip all files.

Code: Select all

add_custom_command(
OUTPUT ${WEB_DIR}/zip/index.html.gz
OUTPUT ${WEB_DIR}/zip/style.css.gz
COMMAND ${CMAKE_COMMAND} -E remove_directory ${WEB_DIR}/zip
COMMAND ${CMAKE_COMMAND} -E make_directory ${WEB_DIR}/zip
COMMAND gzip -krf -9 ${WEB_DIR}/
COMMAND find ${WEB_DIR} -maxdepth 1 -name "*.gz" -exec mv -t ${WEB_DIR}/zip {} +
)

add_custom_command(TARGET ${COMPONENT_LIB} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${WEB_DIR}/zip
)

add_custom_target(gzip_files DEPENDS ${WEB_DIR}/zip/index.html.gz)
add_dependencies(${COMPONENT_LIB} gzip_files)

target_add_binary_data(${COMPONENT_LIB} "${WEB_DIR}/zip/index.html.gz" BINARY)
target_add_binary_data(${COMPONENT_LIB} "${WEB_DIR}/zip/style.css.gz" BINARY)

chegewara
Posts: 2332
Joined: Wed Jun 14, 2017 9:00 pm

Re: Help to run cmake before embed_file

Postby chegewara » Fri Oct 04, 2024 1:36 pm

Glad you solved problem and shared with us solution.
Also its nice to see that devcon video is useful not only to me.

Who is online

Users browsing this forum: No registered users and 61 guests