Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-08-11 Thread Petr Kmoch
On 24 July 2017 at 04:32, Florian Lindner  wrote:

>
>
> [snip]
>
> Still, I don't undertand what is wrong with:
>
> set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
> $<$:-FOO>)
>
> ?
>

What's wrong is that there is no such global property. See the list of
global properties:
https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-of-global-scope

COMPILE_DEFINITIONS is not among them.

You're therefore effectively creating a new user-defined global property,
which of course has no effect on CMake's behaviour.

Petr
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-24 Thread Craig Scott
On Mon, Jul 24, 2017 at 12:32 PM, Florian Lindner 
wrote:

>
>
> Am 22.07.2017 um 15:36 schrieb Craig Scott:
> >
> > On Tue, Jul 18, 2017 at 8:50 PM, Florian Lindner  > wrote:
> >
> > #Works, but I would prefer to have it just once for all targets and
> at the top of the file
> > set_property(TARGET testprecice APPEND
> >   PROPERTY COMPILE_DEFINITIONS "FOO")
> >
> > > BTW, you don't include the -D when adding to COMPILE_DEFINITIONS,
> just put FOO, not -DFOO. Have a read of the docs, they may give you other
> clues for this property (e.g. using the ..._CONFIG variant of it).
> >
> > Yeah, I found out that I don't have to add -D. The docs say that
> generator expressions are preferable to using _CONFIG
> > variant.
> >
> >
> > So just to be crystal clear, this is what I would have expected to work
> if you wanted the symbol FOO to be defined for
> > Debug builds for all targets in the current directory and below:
> >
> > set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
> $<$:FOO>)
>
> Put that in my CMakeLists.txt. Works, but only when I build in the same
> directory where the CMakeLists.txt file is
> located, i.e. in source builds. That way:
>
> set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY
> COMPILE_DEFINITIONS  $<$:FOO>)
>
> it works also out of tree.
>

Not sure why you had to do that, but at least you found a way to get it to
work. There's probably something in your directory structure or something
else I'm not seeing which is causing the appearance of this directory
property to only work if you set it for the top of your source tree.




>
> Still, I don't undertand what is wrong with:
>
> set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
> $<$:-FOO>)
>

Properties can be defined with an INHERITED option
. If a
directory property is defined with that option, then if you try to get the
directory property's value but it is not set, then CMake will look for a
global property with the same name instead and return that value. In this
case though, the COMPILE_DEFINITIONS directory property does not behave as
though it was defined with the INHERITED option, so you don't get that
fallback behaviour. I'm not sure if any of CMake's predefined properties
behave as though they supported INHERITED, but doing a quick test just now
confirms that it isn't supported for COMPILE_DEFINITIONS at least. Note
that properties like COMPILE_DEFINITIONS are set up internally within
CMake's C++ code, not via modules where the define_property() command would
be relevant. I mention it here just so you get the full picture in case you
see the fallback behaviour somewhere else and wonder why it doesn't apply
here.



>
> > Note that this directory property is NOT used to initialise the
> corresponding target property. Rather, BOTH are combined
> > to give the final set of command line compile definitions. It does not
> matter whether this directory property is set
> > before or after you call add_executable() within the same CMakeLists.txt
> file (or more accurately, within the same
> > directory scope).
> >
> >
> >
> > >
> > >
> > > On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner <
> mailingli...@xgm.de   mailingli...@xgm.de >> wrote:
> > >
> > > Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > > > You appear to be setting a GLOBAL property where you
> probably meant DIRECTORY. You could also consider setting the
> > > > target property instead rather than applying it to all
> targets (unless that's what you want).
> > >
> > > I tried to set the property on all targets, therefore I
> thought GLOBAL is the right thing.
> > >
> > > However,
> > >
> > > set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
> > >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> > >
> > > hasn't had any effect either.
> > >
> > > set_property(TARGET testprecice APPEND
> > >   PROPERTY COMPILE_DEFINITIONS "FOO")
> > >
> > > works. But setting it on all targets is exactly what I want.
> How can I do that?
> > >
> > > Best,
> > > Florian
> > >
> > > >
> > > >
> > > > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner <
> mailingli...@xgm.de   mailingli...@xgm.de >
> > > 
>  > > >
> > > > Hello,
> > > >
> > > > I want to add compile definitions. Since I want to use
> generator expressions, I can't use add_definitions, but
> > > have to
> > > > use the COMPILE_DEFINITIONS property, but neither:
> > > 

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-23 Thread Florian Lindner


Am 22.07.2017 um 15:36 schrieb Craig Scott:
> 
> On Tue, Jul 18, 2017 at 8:50 PM, Florian Lindner  > wrote:
> 
> #Works, but I would prefer to have it just once for all targets and at 
> the top of the file
> set_property(TARGET testprecice APPEND
>   PROPERTY COMPILE_DEFINITIONS "FOO")
> 
> > BTW, you don't include the -D when adding to COMPILE_DEFINITIONS, just 
> put FOO, not -DFOO. Have a read of the docs, they may give you other clues 
> for this property (e.g. using the ..._CONFIG variant of it).
> 
> Yeah, I found out that I don't have to add -D. The docs say that 
> generator expressions are preferable to using _CONFIG
> variant.
> 
> 
> So just to be crystal clear, this is what I would have expected to work if 
> you wanted the symbol FOO to be defined for
> Debug builds for all targets in the current directory and below:
> 
> set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS 
> $<$:FOO>)

Put that in my CMakeLists.txt. Works, but only when I build in the same 
directory where the CMakeLists.txt file is
located, i.e. in source builds. That way:

set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS  
$<$:FOO>)

it works also out of tree.

Still, I don't undertand what is wrong with:

set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS $<$:-FOO>)

?

Best,
Florian


> 
> Note that this directory property is NOT used to initialise the corresponding 
> target property. Rather, BOTH are combined
> to give the final set of command line compile definitions. It does not matter 
> whether this directory property is set
> before or after you call add_executable() within the same CMakeLists.txt file 
> (or more accurately, within the same
> directory scope).
> 
> 
> 
> >
> >
> > On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner    >> wrote:
> >
> > Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > > You appear to be setting a GLOBAL property where you probably 
> meant DIRECTORY. You could also consider setting the
> > > target property instead rather than applying it to all targets 
> (unless that's what you want).
> >
> > I tried to set the property on all targets, therefore I thought 
> GLOBAL is the right thing.
> >
> > However,
> >
> > set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
> >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> >
> > hasn't had any effect either.
> >
> > set_property(TARGET testprecice APPEND
> >   PROPERTY COMPILE_DEFINITIONS "FOO")
> >
> > works. But setting it on all targets is exactly what I want. How 
> can I do that?
> >
> > Best,
> > Florian
> >
> > >
> > >
> > > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner 
>   >
> >  
>  > >
> > > Hello,
> > >
> > > I want to add compile definitions. Since I want to use 
> generator expressions, I can't use add_definitions, but
> > have to
> > > use the COMPILE_DEFINITIONS property, but neither:
> > >
> > > set_property(GLOBAL APPEND
> > >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> > >
> > > for testing
> > >
> > > or
> > >
> > > set_property(GLOBAL APPEND
> > >   PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)
> > >
> > > which should be final result, produces any -DFOO compiler 
> switches.
> > >
> > > I also tried placing it before and after the add_executable 
> call.
> > >
> > > What is wrong with that call?
> > >
> > > Thanks,
> > > Florian
> 
>  
> -- 
> Craig Scott
> Melbourne, Australia
> https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-22 Thread Craig Scott
On Tue, Jul 18, 2017 at 8:50 PM, Florian Lindner 
wrote:

> #Works, but I would prefer to have it just once for all targets and at the
> top of the file
> set_property(TARGET testprecice APPEND
>   PROPERTY COMPILE_DEFINITIONS "FOO")
>
> > BTW, you don't include the -D when adding to COMPILE_DEFINITIONS, just
> put FOO, not -DFOO. Have a read of the docs, they may give you other clues
> for this property (e.g. using the ..._CONFIG variant of it).
>
> Yeah, I found out that I don't have to add -D. The docs say that generator
> expressions are preferable to using _CONFIG
> variant.
>

So just to be crystal clear, this is what I would have expected to work if
you wanted the symbol FOO to be defined for Debug builds for all targets in
the current directory and below:

set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$:FOO>)

Note that this directory property is NOT used to initialise the
corresponding target property. Rather, BOTH are combined to give the final
set of command line compile definitions. It does not matter whether this
directory property is set before or after you call add_executable() within
the same CMakeLists.txt file (or more accurately, within the same directory
scope).



>
> >
> > On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner  > wrote:
> >
> > Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > > You appear to be setting a GLOBAL property where you probably
> meant DIRECTORY. You could also consider setting the
> > > target property instead rather than applying it to all targets
> (unless that's what you want).
> >
> > I tried to set the property on all targets, therefore I thought
> GLOBAL is the right thing.
> >
> > However,
> >
> > set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
> >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> >
> > hasn't had any effect either.
> >
> > set_property(TARGET testprecice APPEND
> >   PROPERTY COMPILE_DEFINITIONS "FOO")
> >
> > works. But setting it on all targets is exactly what I want. How can
> I do that?
> >
> > Best,
> > Florian
> >
> > >
> > >
> > > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner <
> mailingli...@xgm.de 
> > >> wrote:
> > >
> > > Hello,
> > >
> > > I want to add compile definitions. Since I want to use
> generator expressions, I can't use add_definitions, but
> > have to
> > > use the COMPILE_DEFINITIONS property, but neither:
> > >
> > > set_property(GLOBAL APPEND
> > >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> > >
> > > for testing
> > >
> > > or
> > >
> > > set_property(GLOBAL APPEND
> > >   PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)
> > >
> > > which should be final result, produces any -DFOO compiler
> switches.
> > >
> > > I also tried placing it before and after the add_executable
> call.
> > >
> > > What is wrong with that call?
> > >
> > > Thanks,
> > > Florian
>

-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-18 Thread Florian Lindner
Am 18.07.2017 um 18:08 schrieb Craig Scott:
> It might be easier if you showed the whole CMakeLists.txt file so we can see 
> the full picture. Is it available somewhere
> you can link to, or even better if it's small enough, just post it inline 
> here.

Sure! It's not too long, so I'll paste it here


cmake_minimum_required (VERSION 3.1)
project(preCICE)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR/CMake})

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" 
STREQUAL "Clang")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

# set_property(GLOBAL APPEND
  # PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)


option(PETSC "Enable use of the PETSc linear algebra library." ON)
if (PETSC)
  find_library(petsc petsc
PATHS $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib)
  if(NOT petsc)
message(FATAL_ERROR "PETSc was not found")
  else()
message(STATUS "Using PETSc: $ENV{PETSC_ARCH}")
  endif()
endif()


find_package (Threads REQUIRED)

find_package(Boost 1.60.0
  REQUIRED
  COMPONENTS log log_setup program_options system thread unit_test_framework)
add_definitions(-DBOOST_SPIRIT_USE_PHOENIX_V3 -DBOOST_ALL_DYN_LINK)

option(MPI "Enables MPI-based communication and running coupling tests." ON)
if (MPI)
  find_package(MPI REQUIRED)
  include_directories(${MPI_INCLUDE_PATH})
  set(COMPILE_FLAGS  ${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
  set(LINK_FLAGS ${LINK_FLAGS} ${MPI_LINK_FLAGS})
endif()

find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

option(PYTHON "Python support" ON)
if (PYTHON)
  set(Python_ADDITIONAL_VERSIONS "2.7")
  find_package(PythonLibs 2.7 REQUIRED)
  include_directories(${PYTHON_INCLUDE_DIRS})
  add_definitions(-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
else()
  add_definitions(-DPRECICE_NO_PYTHON)
endif()


# Fills the sources* variables
add_subdirectory("src")

# Much target_link_libraries boilerplate

add_library(solib ${sourcesAllNoMain})
set_target_properties(solib
  PROPERTIES OUTPUT_NAME libprecice)
target_link_libraries(solib ${PYTHON_LIBRARIES})
target_link_libraries(solib ${MPI_LIBRARIES})
target_link_libraries(solib ${Boost_LIBRARIES})
target_link_libraries(solib ${petsc})

add_library(staticlib ${sourcesAllNoMain})
set_target_properties(staticlib
  PROPERTIES OUTPUT_NAME libprecice)
target_link_libraries(staticlib ${PYTHON_LIBRARIES})
target_link_libraries(staticlib ${MPI_LIBRARIES})
target_link_libraries(staticlib ${Boost_LIBRARIES})
target_link_libraries(staticlib ${petsc})

add_executable(precice
  "src/drivers/main.cpp" ${sourcesAllNoMain} ${sourcesTarchTests})
target_link_libraries(precice Threads::Threads)
target_link_libraries(precice ${PYTHON_LIBRARIES})
target_link_libraries(precice ${MPI_LIBRARIES})
target_link_libraries(precice ${Boost_LIBRARIES})
target_link_libraries(precice ${petsc})

add_executable(testprecice
  "src/testing/main.cpp" ${sourcesAllNoMain} ${sourcesTests})
target_link_libraries(testprecice Threads::Threads)
target_link_libraries(testprecice ${PYTHON_LIBRARIES})
target_link_libraries(testprecice ${MPI_LIBRARIES})
target_link_libraries(testprecice ${Boost_LIBRARIES})
target_link_libraries(testprecice ${petsc})

#Works, but I would prefer to have it just once for all targets and at the top 
of the file
set_property(TARGET testprecice APPEND
  PROPERTY COMPILE_DEFINITIONS "FOO")

> BTW, you don't include the -D when adding to COMPILE_DEFINITIONS, just put 
> FOO, not -DFOO. Have a read of the docs, they may give you other clues for 
> this property (e.g. using the ..._CONFIG variant of it).

Yeah, I found out that I don't have to add -D. The docs say that generator 
expressions are preferable to using _CONFIG
variant.

Best,
Florian

> 
> 
> On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner  > wrote:
> 
> Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > You appear to be setting a GLOBAL property where you probably meant 
> DIRECTORY. You could also consider setting the
> > target property instead rather than applying it to all targets (unless 
> that's what you want).
> 
> I tried to set the property on all targets, therefore I thought GLOBAL is 
> the right thing.
> 
> However,
> 
> set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
>   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> 
> hasn't had any effect either.
> 
> set_property(TARGET testprecice APPEND
>   PROPERTY COMPILE_DEFINITIONS "FOO")
> 
> works. But setting it on all targets is exactly what I want. How can I do 
> that?
> 
> Best,
> Florian
> 
> >
> >
> > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner  
> >> wrote:
> >
> > Hello,
> >
> > I want to add compile definitions. Since I want to use generator 
> 

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-18 Thread Craig Scott
On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner 
wrote:

> Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > You appear to be setting a GLOBAL property where you probably meant
> DIRECTORY. You could also consider setting the
> > target property instead rather than applying it to all targets (unless
> that's what you want).
>
> I tried to set the property on all targets, therefore I thought GLOBAL is
> the right thing.
>
> However,
>
> set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
>   PROPERTY COMPILE_DEFINITIONS "-DFOO")
>
> hasn't had any effect either.
>

BTW, you don't include the -D when adding to COMPILE_DEFINITIONS, just put
FOO, not -DFOO. Have a read of the docs
,
they may give you other clues for this property (e.g. using the ..._CONFIG
variant of it).


-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-18 Thread Craig Scott
It might be easier if you showed the whole CMakeLists.txt file so we can
see the full picture. Is it available somewhere you can link to, or even
better if it's small enough, just post it inline here.


On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner 
wrote:

> Am 18.07.2017 um 10:59 schrieb Craig Scott:
> > You appear to be setting a GLOBAL property where you probably meant
> DIRECTORY. You could also consider setting the
> > target property instead rather than applying it to all targets (unless
> that's what you want).
>
> I tried to set the property on all targets, therefore I thought GLOBAL is
> the right thing.
>
> However,
>
> set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
>   PROPERTY COMPILE_DEFINITIONS "-DFOO")
>
> hasn't had any effect either.
>
> set_property(TARGET testprecice APPEND
>   PROPERTY COMPILE_DEFINITIONS "FOO")
>
> works. But setting it on all targets is exactly what I want. How can I do
> that?
>
> Best,
> Florian
>
> >
> >
> > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner  > wrote:
> >
> > Hello,
> >
> > I want to add compile definitions. Since I want to use generator
> expressions, I can't use add_definitions, but have to
> > use the COMPILE_DEFINITIONS property, but neither:
> >
> > set_property(GLOBAL APPEND
> >   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> >
> > for testing
> >
> > or
> >
> > set_property(GLOBAL APPEND
> >   PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)
> >
> > which should be final result, produces any -DFOO compiler switches.
> >
> > I also tried placing it before and after the add_executable call.
> >
> > What is wrong with that call?
> >
> > Thanks,
> > Florian
> > --
> >
> > 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 <
> http://cmake.org/cmake/help/support.html>
> > CMake Consulting: http://cmake.org/cmake/help/consulting.html <
> http://cmake.org/cmake/help/consulting.html>
> > CMake Training Courses: http://cmake.org/cmake/help/training.html <
> 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:
> > http://public.kitware.com/mailman/listinfo/cmake <
> http://public.kitware.com/mailman/listinfo/cmake>
> >
> >
> >
> >
> > --
> > Craig Scott
> > Melbourne, Australia
> > https://crascit.com
>



-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-17 Thread Florian Lindner
Am 18.07.2017 um 10:59 schrieb Craig Scott:
> You appear to be setting a GLOBAL property where you probably meant 
> DIRECTORY. You could also consider setting the
> target property instead rather than applying it to all targets (unless that's 
> what you want).

I tried to set the property on all targets, therefore I thought GLOBAL is the 
right thing.

However,

set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND
  PROPERTY COMPILE_DEFINITIONS "-DFOO")

hasn't had any effect either.

set_property(TARGET testprecice APPEND
  PROPERTY COMPILE_DEFINITIONS "FOO")

works. But setting it on all targets is exactly what I want. How can I do that?

Best,
Florian

> 
> 
> On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner  > wrote:
> 
> Hello,
> 
> I want to add compile definitions. Since I want to use generator 
> expressions, I can't use add_definitions, but have to
> use the COMPILE_DEFINITIONS property, but neither:
> 
> set_property(GLOBAL APPEND
>   PROPERTY COMPILE_DEFINITIONS "-DFOO")
> 
> for testing
> 
> or
> 
> set_property(GLOBAL APPEND
>   PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)
> 
> which should be final result, produces any -DFOO compiler switches.
> 
> I also tried placing it before and after the add_executable call.
> 
> What is wrong with that call?
> 
> Thanks,
> Florian
> --
> 
> 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:
> http://public.kitware.com/mailman/listinfo/cmake 
> 
> 
> 
> 
> 
> -- 
> Craig Scott
> Melbourne, Australia
> https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Append to property COMPILE_DEFINITIONS

2017-07-17 Thread Craig Scott
You appear to be setting a GLOBAL property where you probably meant
DIRECTORY. You could also consider setting the target property instead
rather than applying it to all targets (unless that's what you want).


On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner 
wrote:

> Hello,
>
> I want to add compile definitions. Since I want to use generator
> expressions, I can't use add_definitions, but have to
> use the COMPILE_DEFINITIONS property, but neither:
>
> set_property(GLOBAL APPEND
>   PROPERTY COMPILE_DEFINITIONS "-DFOO")
>
> for testing
>
> or
>
> set_property(GLOBAL APPEND
>   PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)
>
> which should be final result, produces any -DFOO compiler switches.
>
> I also tried placing it before and after the add_executable call.
>
> What is wrong with that call?
>
> Thanks,
> Florian
> --
>
> 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:
> http://public.kitware.com/mailman/listinfo/cmake
>



-- 
Craig Scott
Melbourne, Australia
https://crascit.com
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Append to property COMPILE_DEFINITIONS

2017-07-17 Thread Florian Lindner
Hello,

I want to add compile definitions. Since I want to use generator expressions, I 
can't use add_definitions, but have to
use the COMPILE_DEFINITIONS property, but neither:

set_property(GLOBAL APPEND
  PROPERTY COMPILE_DEFINITIONS "-DFOO")

for testing

or

set_property(GLOBAL APPEND
  PROPERTY COMPILE_DEFINITIONS $<$:-DDebug>)

which should be final result, produces any -DFOO compiler switches.

I also tried placing it before and after the add_executable call.

What is wrong with that call?

Thanks,
Florian
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake