mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 13:27:09 +00:00
Extend the `install_prep/<component>` and `install_prep/all` targets to the Makefile generators. Some differences compared to the implementation for Ninja: * A Makefile rule name cannot contain `:`, so components whose names contain one get no preparation target. * A top-level rule cannot build an individual custom command output, so a generated file to be installed is prepared by building the target that owns its custom command. * When a target must be relinked before installation, its `preinstall` rule is built after its `all` rule. * Where the make tool matches target names case-insensitively, components whose names differ only in case share a preparation target, as done for `test_prep/`. Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com> Issue: #27643
23 lines
797 B
CMake
23 lines
797 B
CMake
enable_language(C)
|
|
|
|
# Generators that can depend on individual files prepare a generated file by
|
|
# running only the custom command that produces it.
|
|
#
|
|
# The Makefile generators build the whole target instead, so its sources must
|
|
# compile there.
|
|
if(CMAKE_GENERATOR MATCHES "Make")
|
|
set(generated_target_source "${CMAKE_CURRENT_LIST_DIR}/lib.c")
|
|
else()
|
|
set(generated_target_source "${CMAKE_CURRENT_LIST_DIR}/neverbuild.c")
|
|
endif()
|
|
|
|
# Add a custom command that generates the named file in the current binary
|
|
# directory and store its full path in the given variable.
|
|
function(add_generated_file var name)
|
|
set(file "${CMAKE_CURRENT_BINARY_DIR}/${name}")
|
|
add_custom_command(OUTPUT "${file}"
|
|
COMMAND ${CMAKE_COMMAND} -E touch "${file}"
|
|
)
|
|
set(${var} "${file}" PARENT_SCOPE)
|
|
endfunction()
|