source file properties not applied when source and target in different directories
CMakeLists.txt
project(test)
cmake_minimum_required(VERSION 3.18)
add_subdirectory(foo)
add_subdirectory(bar)
foo/CMakeLists.txt:
add_library(lib STATIC a.c)
set_source_files_properties(a.c PROPERTIES COMPILE_DEFINITIONS YES)
bar/CMakeLists.txt:
target_sources(lib PRIVATE b.c)
set_source_files_properties(b.c PROPERTIES COMPILE_DEFINITIONS YES)
when compiling lib
, a.c
is compiled with -DYES
, while b.c
is not. cmake_reproducer.zip attached