Add ability to share precompiled headers between targets
After !3553 (merged), if I do this:
add_executable(test test.cc)
target_precompile_headers(test PUBLIC ${PROJECT_SOURCE_DIR}/common.hh)
add_executable(test2 test2.cc)
target_precompile_headers(test2 PUBLIC ${PROJECT_SOURCE_DIR}/common.hh)
…it precompiles common.hh twice, even though both targets use the same build settings and thus a single precompiled header could be shared, which would further improve build speed.
On !3553 (comment 606628), @Rogiel suggested:
It should be possible to later add a
target_precompile_headers(<target> REUSE_FROM <reuse-target>)
.