Inherited compile option disappears when setting COMPILE_FLAGS property.
Consider the following example with generator "Visual Studio 14 2015" using cmake version 3.9.6 :
cmake_minimum_required (VERSION 3.9.6)
project(CMakeBug)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_library( libFoo INTERFACE )
target_compile_options( libFoo INTERFACE /FIfoo.h )
add_executable( bar main.cpp bar.h)
target_link_libraries( bar PUBLIC libFoo )
# This line triggers the bug
set_property( SOURCE main.cpp PROPERTY COMPILE_FLAGS /FIbar.h ) # remove this line to get the /FIfoo.h option back.
In the example as it is, the compile command for main.cpp
misses the inherited /FIfoo.h
flag from libFoo
and only has the /FIbar.h
flag. When the last line with the set_property()
call is removed, the flag appears in the compile command.
To make the example work, you have to add empty headers bar.h
, foo.h
and a minimal main.cpp
.
Is this an error on my side or on CMake side?
Edited by Knitschi