Errors from DIRECTORY keyword parsing for source property commands not fatal
Consider the following minimal example:
cmake_minimum_required(VERSION 3.18)
project(proptest)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp "int main() {}")
add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
get_property(result1 SOURCE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp DIRECTORY iDoNotExist PROPERTY GENERATED)
get_source_file_property(result2 ${CMAKE_CURRENT_BINARY_DIR}/main.cpp DIRECTORY iDoNotExist GENERATED)
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp DIRECTORY iDoNotExist PROPERTY GENERATED YES)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/main.cpp DIRECTORY iDoNotExist PROPERTIES GENERATED YES)
message("results = ${result1}, ${result2}")
Each of the four property-related commands should generate a fatal error, but execution continues. If you run cmake on the above project, the message from the last message()
command is shown, but processing should not reach that line:
CMake Error at CMakeLists.txt:7 (get_property):
get_property given non-existent DIRECTORY iDoNotExist
CMake Error at CMakeLists.txt:8 (get_source_file_property):
get_source_file_property given non-existent DIRECTORY iDoNotExist
CMake Error at CMakeLists.txt:9 (set_property):
set_property given non-existent DIRECTORY iDoNotExist
CMake Error at CMakeLists.txt:10 (set_source_files_properties):
set_source_files_properties given non-existent DIRECTORY iDoNotExist
results = ,
-- Configuring incomplete, errors occurred!
I presume you have the same situation for the TARGET_DIRECTORY
option since it is handled by the same code paths.
Edited by Craig Scott