Ok, Thanks!  I guess I have to get better at reading error messages ☺

From: Chuck Atkins <chuck.atk...@kitware.com>
Date: Monday, October 15, 2018 at 12:19 PM
To: Rob Boehne <r...@datalogics.com>
Cc: CMake Mail List <cmake@cmake.org>
Subject: Re: [CMake] Building arguments to target_comple_definitions()

Hi Rob,
How would one set a variable containing multiple definitions to be passed to 
target_compile_definitions()  ?

The example you gave works (adjusting for typos, PIC, and adding visibility 
specifier):
...
set(COMMON_DEFINITIONS SOME_DEFINE_1 SOME_DEFINE_2 SOME_DEFINE_3)
...
target_compile_definitions(CHUNK1 PRIVATE ${COMMON_DEFINITIONS} CHUNK1_STUFF 
CHUNK_NAME=\"One\")
target_compile_definitions(CHUNK2 PRIVATE ${COMMON_DEFINITIONS} CHUNK2_STUFF 
CHUNK_NAME=\"Two\")
target_compile_definitions(FooBar PRIVATE ${COMMON_DEFINITIONS})
...
results in the following:
...
/usr/bin/c++  -DCHUNK1_STUFF -DCHUNK_NAME=\"One\" -DSOME_DEFINE_1 
-DSOME_DEFINE_2 -DSOME_DEFINE_3  -fPIC   -o 
CMakeFiles/CHUNK1.dir/chunk_one.cpp.o -c 
/home/chuck/Code/tmp/source/chunk_one.cpp
...
/usr/bin/c++  -DCHUNK2_STUFF -DCHUNK_NAME=\"Two\" -DSOME_DEFINE_1 
-DSOME_DEFINE_2 -DSOME_DEFINE_3  -fPIC   -o 
CMakeFiles/CHUNK2.dir/chunk_two.cpp.o -c 
/home/chuck/Code/tmp/source/chunk_two.cpp
...
/usr/bin/c++  -DFooBar_EXPORTS -DSOME_DEFINE_1 -DSOME_DEFINE_2 -DSOME_DEFINE_3  
-fPIC   -o CMakeFiles/FooBar.dir/foobar.cpp.o -c 
/home/chuck/Code/tmp/source/foobar.cpp
...

Here you can see the common definitions make it to all targets.

- Chuck
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to