Among the many things that Cmake does, one of them is generate files. For example, one can generate “.h” files from “.h.in” files. Make sure you get the ordering right though…
Any code to set variables should be done before CONFIGURE_FILE is called, not after . Docs are here
# Set feature file name SET(FEATURE_FILE_NAME sps_config.h) # Generate SPS feature file from the template CONFIGURE_FILE( "${SPS_CONFIG_DIR}/${FEATURE_FILE_NAME}.in" "${CONFIG_HEADER_DIR}/${FEATURE_FILE_NAME}" )
The trick is to have depends on input and output files. Also, to probably not use FILE(GLOB) but instead FILE() or set()
#---------------------------------------------------------------------------------------------------- # Generate String Definitions #---------------------------------------------------------------------------------------------------- set(STRING_DEFS_INPUT_FILES ${ROOT}/DcpmemPkg/common/NvmStatus.uni ${ROOT}/DcpmemPkg/driver/Core/Diagnostics/DiagnosticsMessages.uni ${ROOT}/src/os/os_string_overrides.uni ${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.py ) set(STRING_DEFS_OUTPUT_FILES ${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.h ${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_defs.h ) add_custom_target(stringdefs ALL DEPENDS ${STRING_DEFS_OUTPUT_FILES} ${STRING_DEFS_INPUT_FILES}) add_custom_command(OUTPUT ${STRING_DEFS_OUTPUT_FILES} COMMAND python ${ROOT}/src/os/efi_shim/os_efi_hii_auto_gen_strings.py COMMENT "Generating String Definitions" DEPENDS ${STRING_DEFS_INPUT_FILES} )