Re: [CMake] Building arguments to target_comple_definitions()

2018-10-15 Thread Rob Boehne
Ok, Thanks!  I guess I have to get better at reading error messages ☺


From: Chuck Atkins 
Date: Monday, October 15, 2018 at 12:19 PM
To: Rob Boehne 
Cc: CMake Mail List 
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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-15 Thread Chuck Atkins
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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-15 Thread Rob Boehne
How would one set a variable containing multiple definitions to be passed to 
target_compile_definitions()  ?

From: Chuck Atkins 
Date: Friday, October 12, 2018 at 1:45 PM
To: Rob Boehne 
Cc: CMake Mail List 
Subject: Re: [CMake] Building arguments to target_comple_definitions()


So in CMake parlance, what type is the last argument to 
target_compile_definitions?  Is it a list, string or something else?

It's a series of VISIBILITY_SPECIFIER DEF1 DEF2 ... DEFN, so the visibility 
specifier followed by a list of definitions, optionally followed by another 
visibility specifier and list of definitions, etc.

add_library(Foo OBJECT Foo.cxx)
target_compile_definitions(Foo
  PUBLIC
COMMON_DEF_1 COMMON_DEF_2
  PRIVATE
FOO_SPECIFIC_DEF=42
)

will translate to something like:

c++ -DCOMMON_DEF_1 -DCOMMON_DEF_2 -DFOO_SPECIFIC_DEF=4 -o Foo.cxx.o -c Foo.cxx

- Chuck


From: Chuck Atkins mailto:chuck.atk...@kitware.com>>
Date: Thursday, October 11, 2018 at 2:55 PM
To: Rob Boehne mailto:r...@datalogics.com>>
Cc: CMake Mail List mailto:cmake@cmake.org>>
Subject: Re: [CMake] Building arguments to target_comple_definitions()

So, are you suggesting that I make a “dummy” target and fill it with the common 
options in compile_definitions() and include_directories() (et. al.)
Then make my OBJECT libraries (and the shared library) depend on the “dummy” 
target?

If that’s not the suggestion, I’m afraid I don’t see how I can use this to set 
the common flags

That's certainly one way you can solve the problem, i.e. making an interface 
library with the common defs, and a good idea at that, but that's not what I 
was referring to.  I was simply tying to explain that the error your getting 
trying to pass arguments to target_compile_options is because you're missing 
the visibility argument.

- 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-12 Thread Chuck Atkins
> So in CMake parlance, what type is the last argument to
> target_compile_definitions?  Is it a list, string or something else?
>

It's a series of VISIBILITY_SPECIFIER DEF1 DEF2 ... DEFN, so the visibility
specifier followed by a list of definitions, optionally followed by another
visibility specifier and list of definitions, etc.

add_library(Foo OBJECT Foo.cxx)
target_compile_definitions(Foo
  PUBLIC
COMMON_DEF_1 COMMON_DEF_2
  PRIVATE
FOO_SPECIFIC_DEF=42
)

will translate to something like:

c++ -DCOMMON_DEF_1 -DCOMMON_DEF_2 -DFOO_SPECIFIC_DEF=4 -o Foo.cxx.o -c
Foo.cxx

- Chuck


>
> *From: *Chuck Atkins 
> *Date: *Thursday, October 11, 2018 at 2:55 PM
> *To: *Rob Boehne 
> *Cc: *CMake Mail List 
> *Subject: *Re: [CMake] Building arguments to target_comple_definitions()
>
>
>
> So, are you suggesting that I make a “dummy” target and fill it with the
> common options in compile_definitions() and include_directories() (et. al.)
>
> Then make my OBJECT libraries (and the shared library) depend on the
> “dummy” target?
>
>
>
> If that’s not the suggestion, I’m afraid I don’t see how I can use this to
> set the common flags
>
>
>
> That's certainly one way you can solve the problem, i.e. making an
> interface library with the common defs, and a good idea at that, but that's
> not what I was referring to.  I was simply tying to explain that the error
> your getting trying to pass arguments to target_compile_options is because
> you're missing the visibility argument.
>
>
>
> - 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-11 Thread Rob Boehne
They were elided for brevity –

So in CMake parlance, what type is the last argument to 
target_compile_definitions?  Is it a list, string or something else?

From: Chuck Atkins 
Date: Thursday, October 11, 2018 at 2:55 PM
To: Rob Boehne 
Cc: CMake Mail List 
Subject: Re: [CMake] Building arguments to target_comple_definitions()

So, are you suggesting that I make a “dummy” target and fill it with the common 
options in compile_definitions() and include_directories() (et. al.)
Then make my OBJECT libraries (and the shared library) depend on the “dummy” 
target?

If that’s not the suggestion, I’m afraid I don’t see how I can use this to set 
the common flags

That's certainly one way you can solve the problem, i.e. making an interface 
library with the common defs, and a good idea at that, but that's not what I 
was referring to.  I was simply tying to explain that the error your getting 
trying to pass arguments to target_compile_options is because you're missing 
the visibility argument.

- 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-11 Thread Chuck Atkins
>
> So, are you suggesting that I make a “dummy” target and fill it with the
> common options in compile_definitions() and include_directories() (et. al.)
>
> Then make my OBJECT libraries (and the shared library) depend on the
> “dummy” target?
>

>
> If that’s not the suggestion, I’m afraid I don’t see how I can use this to
> set the common flags
>

That's certainly one way you can solve the problem, i.e. making an
interface library with the common defs, and a good idea at that, but that's
not what I was referring to.  I was simply tying to explain that the error
your getting trying to pass arguments to target_compile_options is because
you're missing the visibility argument.

- 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-11 Thread Rob Boehne
So, are you suggesting that I make a “dummy” target and fill it with the common 
options in compile_definitions() and include_directories() (et. al.)
Then make my OBJECT libraries (and the shared library) depend on the “dummy” 
target?

If that’s not the suggestion, I’m afraid I don’t see how I can use this to set 
the common flags


From: Chuck Atkins 
Date: Thursday, October 11, 2018 at 2:12 PM
To: Rob Boehne 
Cc: CMake Mail List 
Subject: Re: [CMake] Building arguments to target_comple_definitions()

Hi Rob,

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}  )

This is what I was referring to.  Adding visibility to 
target_compile_definitions:

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})

All of the target_ commands take the format target_foo(target_name 
USAGE_VISIBILY bar1 bar2 bar3 ...).  target_link_libraries is the exception 
with everythign being PUBLIC by default but only because it pre-dates all the 
other target commands.

- 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-11 Thread Chuck Atkins
Hi Rob,


> 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}  )
>

This is what I was referring to.  Adding visibility to
target_compile_definitions:

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})

All of the target_ commands take the format target_foo(target_name
USAGE_VISIBILY bar1 bar2 bar3 ...).  target_link_libraries is the exception
with everythign being PUBLIC by default but only because it pre-dates all
the other target commands.

- 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


Re: [CMake] Building arguments to target_comple_definitions()

2018-10-10 Thread Rob Boehne
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 
Date: Wednesday, October 10, 2018 at 2:11 PM
To: Rob Boehne 
Cc: CMake Mail List 
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