Files
CMake/Tests/RunCMake/ExportCompileCommands/Properties.cmake
Shannon Booth a742b5d137 CMAKE_EXPORT_COMPILE_COMMANDS: allow configuration per target
The new target property `EXPORT_COMPILE_COMMANDS` associated with the
existing global variable can be used to optionally configure targets for
their compile commands to be exported.

Fixes: #19462
2021-01-06 11:51:39 +13:00

23 lines
812 B
CMake

enable_language(C)
add_library(Unset STATIC empty.c)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_library(SetOn STATIC empty.c)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
add_library(SetOff STATIC empty.c)
get_property(_set TARGET Unset PROPERTY EXPORT_COMPILE_COMMANDS)
if(_set)
message(SEND_ERROR "EXPORT_COMPILE_COMMANDS property should be unset for Unset target (got \"${_set}\")")
endif()
get_property(_on TARGET SetOn PROPERTY EXPORT_COMPILE_COMMANDS)
if(NOT _on STREQUAL "ON")
message(SEND_ERROR "EXPORT_COMPILE_COMMANDS property should be \"ON\" for SetOn target (got \"${_on}\")")
endif()
get_property(_off TARGET SetOff PROPERTY EXPORT_COMPILE_COMMANDS)
if(NOT _off STREQUAL "OFF")
message(SEND_ERROR "EXPORT_COMPILE_COMMANDS property should be \"OFF\" for SetOff target (got \"${_off}\")")
endif()