I am writing a CMakeLists.txt for a project, and encounter a problem with set_source_files_properties.
The original working expression is:
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
DIR1="/home/xxx/b.i")
Then I try to add more COMPILE_DEFINITIONSs, but get failure.
try 1:
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
DIR1="/home/xxx/b.i" DIR2="/home/xxx/c.i" DIR3="/home/xxx/d.i")
try 2:
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
DIR1="/home/xxx/b.i")
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
DIR2="/home/xxx/c.i")
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
DIR3="/home/xxx/d.i")
result: only last define DIR3 can be recognized in a.cpp when compiling by make, first two are reported undefined in make phase.
Any suggestions?
Thank you!
The set_*_properties()
functions are shorthands for basic usage. For "advanced" cases, it's better to use the full power of set_property()
:
set_property(
SOURCE a.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS
DIR1="/home/xxx/b.i" DIR2="/home/xxx/c.i" DIR3="/home/xxx/d.i"
)
I manage to provide several COMPILE_DEFINITIONS
using set_source_files_properties
with the following command:
set_source_files_properties (a.cpp PROPERTIES COMPILE_DEFINITIONS
"DIR1=\"/home/xxx/b.i\";DIR2=\"/home/xxx/c.i\";DIR3=\"/home/xxx/d.i\")"
source: https://cmake.org/cmake/help/v3.5/prop_sf/COMPILE_DEFINITIONS.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With