GHS: custom_command with multiple outputs executes multiple times
Background
- Using CMake with the `Green Hills MULTI" generator
With the following configuration:
cmake_minimum_required(VERSION 3.27)
project(Example LANGUAGES CXX)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/one.cpp ${CMAKE_CURRENT_BINARY_DIR}/two.cpp
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/one.cpp ${CMAKE_CURRENT_BINARY_DIR}/two.cpp
COMMENT "GENERATING one.cpp and two.cpp"
)
add_library(SomeLib ${CMAKE_CURRENT_BINARY_DIR}/one.cpp ${CMAKE_CURRENT_BINARY_DIR}/two.cpp)
The generation output is similar to the following
Building ALL_BUILD.tgt.gpj
Processing Custom Rule SomeLib_cc0_one.cpp.rule.sh because one.cpp does not exist
GENERATING one.cpp and two.cpp
Processing Custom Rule SomeLib_cc0_one.cpp.rule.sh because two.cpp does not exist
GENERATING one.cpp and two.cpp
Compiling one.cpp because it has changed
Compiling two.cpp because it has changed
Archiving libSomeLib.a because two.o has changed
Done