Created
May 26, 2022 09:41
-
-
Save ken-matsui/6ddc2c3414520060b0d1084afd93f283 to your computer and use it in GitHub Desktop.
Generate files with detecting changed files in CMake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
: $1 $2 | |
INPUT_FILE_PATH=$1 | |
OUTPUT_FILE_PATH=$2 | |
printf "std::string(R\"(%s\n)\")" "$(cat "$INPUT_FILE_PATH")" > "$OUTPUT_FILE_PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file(GLOB_RECURSE ExpectationInputFiles CONFIGURE_DEPENDS "*.stdout" "*.stderr") | |
foreach(InputFilePath ${ExpectationInputFiles}) | |
get_filename_component(FileBaseDir ${InputFilePath} DIRECTORY) | |
get_filename_component(FileName ${InputFilePath} NAME) | |
set(OutputFilePath "${FileBaseDir}/gen/${FileName}.gen") | |
add_custom_command( | |
OUTPUT ${OutputFilePath} | |
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/generate-expectation-files.sh ${InputFilePath} ${OutputFilePath} | |
DEPENDS ${InputFilePath} | |
) | |
list(APPEND ExpectationOutputFiles ${OutputFilePath}) | |
endforeach() | |
add_custom_target(GenerateExpectationFiles ALL DEPENDS ${ExpectationOutputFiles}) | |
add_dependencies(poac GenerateExpectationFiles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment