Chuck,
I think I didn’t explain the situation well enough. Here is a sample
pseudo-Cmake input fiile:
add_library( FooBar SHARED )
add_library( CHUNK1 OBJECT)
add_library( CHUNK2 OBJECT)
set( COMMON SOME_DEFINE_1 SOME_DEFINE_2 SOME_DEFINE_3 )
if( condition )
list(APPEND COMMON “CONDITION_TRUE”)
endif()
target_compile_definitions( CHUNK1 ${COMMON_DEFINITIONS} CHUNK1_STUFF
CHUNK_NAME=\”One\” )
target_compile_definitions( CHUNK2 ${COMMON_DEFINITIONS} CHUNK2_STUFF
CHUNK_NAME=\”Two\”)
target_compile_definitions( FooBar ${COMMON_DEFINITIONS} )
target_sources( CHUNK1 PRIVATE chunk_one.cpp )
target_sources( CHUNK2 PRIVATE chunk_two.cpp )
target_sources( FooBar PRIVATE foobar.cpp )
Build commands:
$(CXX) -DSOME_DEFINE1 -DSOME_DEFINE_2 -DSOME_DEFINE_3 -DCHUNK1_STUFF
-DCHUNK_NAME=\”One\” -c chunk_one.cpp -o chunk_one.o
$(CXX) -DSOME_DEFINE1 -DSOME_DEFINE_2 -DSOME_DEFINE_3 -DCHUNK2_STUFF
-DCHUNK_NAME=\”Two\” -c chunk_two.cpp -o chunk_two.o
$(CXX) -DSOME_DEFINE1 -DSOME_DEFINE_2 -DSOME_DEFINE_3 -DCHUNK2_STUFF -c
foobar.cpp -o foobar.o
From: Chuck Atkins <[email protected]>
Date: Wednesday, October 10, 2018 at 2:11 PM
To: Rob Boehne <[email protected]>
Cc: CMake Mail List <[email protected]>
Subject: Re: [CMake] Building arguments to target_comple_definitions()
Hi Robb,
Are you adding the appropriate visibility, i.e. PUBLIC, PRIVATE, or INTERFACE?
You should be able to do the following:
# Translates to -DFOODEF1=hello -DFOODEF2=world
target_compile_definitions(fooTarget PRIVATE FOODEF1=hello FOODEF2=world)
# Translates to -DBARDEF1=baz -DBARDEF2
target_compile_definitions(barTarget PRIVATE BARDEF1=baz BARDEF2)
- 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