[CMake] Source List Compilation Depending on Configuration

Jörg Kreuzberger j.kreuzberger at procitec.de
Mon Jul 21 09:19:25 EDT 2014


1) i reset it with
 set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_INIT} )
 set( CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE_INIT} )
 set( CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG_INIT} )

 and then append my own custom compiler definitions. "-DNDEBUG" appears in flags.make, only in CXX_FLAGS, but not in CXX_DEFINES!

and this is the issue i had with it: as long it appears only in CXX_FLAGS, it works for the code compilation but it does not work for qt4_wrapp_cpp (missing defines for moc).


2) the point i want to change global compiler properties is in my toplevel CMakeLists.txt,
there i do 
include( cmake/GlobalCompilerSettings.cmake)

3) following your example, it does not work for COMPILE_DEFINITIONS_RELEASE, but does work for COMPILE_DEFINITIONS.
(works means it appears in CXX_DEFINES)
using release cmake 3.0.0 version. Platform is ubuntu linux (makefile generator)




-----Ursprüngliche Nachricht-----
Von:	Nils Gladitz <nilsgladitz at gmail.com>
Gesendet:	Mo 21.07.2014 14:45
Betreff:	Re: AW: [CMake] Source List Compilation Depending on Configuration
An:	Jörg Kreuzberger <j.kreuzberger at procitec.de>; 
CC:	cmake at cmake.org; 
> On 07/21/2014 02:29 PM, Jörg Kreuzberger wrote:
> > Hm, following your suggestion i replace lines
> > if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
> > add_definitions( -DNDEBUG )
> > endif()
> >
> > with
> > set_directory_properties( PROPERTIES COMPILE_DEFINITIONS_RELEASE 
> "${COMPILE_DEFINITIONS_RELEASE};NDEBUG" )
> 
> ${COMPILE_DEFINITIONS_RELEASE} does not expand the property but you 
> could use set_property() with the APPEND flag for that.
> 
> NDEBUG is set by default for MinSizeRel, Release and RelWithDebInfo so 
> you should have found it in the Release flags even without using the 
> property (unless you override the default flags).
> 
> With
>    set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELEASE "FOOBAR")
> 
> I get
>    ./CMakeFiles/foo.dir/flags.make:CXX_DEFINES = -DFOOBAR
> When configuring a Release build with the Makefiles generator.
> 
> Nils
> 
> 
> 
> 
> 
>

Mannheim HRB 504702
Geschäftsführer: Dipl.-Ing. (FH) Michael Brenk (Vorsitzender), Dipl.-Ing. (FH) Dipl.-Inf. (FH) Jens Heyen

This e-mail may contain confidential and/or legally protected information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this email is strictly forbidden.
Thank you!




More information about the CMake mailing list