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

it didnt worked. ( inspecting e.q. flags.make and compilation )

if i set COMPILE_DEFINITIONS (without config) it worked. This is the point i 
stuct like above again.



-----Ursprüngliche Nachricht-----
Von:    Nils Gladitz <[email protected]>
Gesendet:       Mo 21.07.2014 12:13
Betreff:        Re: [CMake] Source List Compilation Depending on Configuration
An:     Jörg Kreuzberger <[email protected]>; [email protected]; 
> On 07/21/2014 11:46 AM, Jörg Kreuzberger wrote:
> > Hi!
> >
> > if i want to add sources to list of compilation i can rely on 
> CMAKE_BUILD_TYPE.
> > E.g if i want to add a source file only for release, i append it to list of 
> source files only then.
> >
> > BUT: how can i do this for multi configuration like vs?
> > So i want to add it to the sources, so that it appears in vs, but only want 
> to compile it in release build?
> >
> > Is there an easy way to handle this?
> 
> I don't think CMake supports configuration specific source files (I 
> assume this might not be supported by all target build systems?).
> 
> It should be possible to use the preprocessor (with configuration 
> specific defines through the COMPILE_DEFINITIONS_<CONFIG> property) to 
> work around it.
> 
> E.g. either guard the source file's content itself with
>    #ifdef CONFIG_SPECIFIC_DEFINE
>    <source file content>
>    #endif
> 
> or add a wrapper source file that does something like
> 
>    #ifdef CONFIG_SPECIFIC_DEFINE
>    #include "config1.cpp"
>    #endif
> 
> or even
> 
>    #ifdef CONFIG_SPECIFIC_DEFINE
>    #include "config1.cpp"
>    #else
>    #include "config2.cpp"
>    #endif
> 
> 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!


-- 

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

Reply via email to