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

--

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