0

Right-click on the solution title in the Solution Explorer window, then go to Configuration Properties -> Configuration. The table appears, showing check-boxes, allowing to turn off/on a build of particular projects for certain configurations.

My solution and projects are generated with CMake.

Is it possible to turn off a particular project for Debug build configuration from CMakeLists.txt?

==

Background of a problem is failing build of Cython project for Debug config. Release builds fine. CMake module was taken from this example on Github.

Debug config wants debug Python library python27_d.lib, that is forced by pyconfig.h. I use Anaconda python, which is missing this library.

Moreover, I don't need debug build of that project. I've unsuccessfully spent several hours, modifying CMakeLists.txt in various ways, trying to remove definition of _DEBUG macro from compiler command line. CLI parameter /D_DEBUG was absent in all dialogs with properties and "complete command line" listings, that Visual Studio has shown me. Nevertheless, something has always appended it.

So, I'd like to simply disable this project in Debug build for now.

Community
  • 1
  • 1
wl2776
  • 4,099
  • 4
  • 35
  • 77
  • 1
    Have you tried setting the target's `EXCLUDE_FROM_DEFAULT_BUILD_DEBUG` property to `1`? Please not that [`EXCLUDE_FROM_DEFAULT_BUILD_`](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.html) was added with CMake version 2.8.11 (and does not work with older versions). – Florian Dec 29 '16 at 09:46
  • Never heard about it, will try – wl2776 Dec 29 '16 at 09:49

1 Answers1

1

This sets that check-box from the first part of the question to unchecked state:

set_property(TARGET <my Cython module>
             PROPERTY EXCLUDE_FROM_DEFAULT_BUILD_DEBUG TRUE)

Now I wonder, where did compiler command line come from, because /D_DEBUG was absent in all dialogs with properties, that Visual Studio has shown me (second part of the question).

I am building this project in VS2013. Initially, that string /D_DEBUG was present in Project properties -> C/C++ -> Preprocessor -> Preprocessor definitions for the Debug configuration. Then I've added

string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")

to my CMakeLists.txt file, building the Cython code, and that macro has disappeared from the Project properties.

Nevertheless, the project was still requiring python27_d.dll.

I've also added

#define _DEBUG

in one of files, and have got the following compiler warning

C:\projects\project\file.cpp(9): warning C4005: '_DEBUG' : macro redefinition
          command-line arguments :  see previous definition of '_DEBUG'
wl2776
  • 4,099
  • 4
  • 35
  • 77
  • 1
    It's a pre-defined VC macro. So for the second part of your question see e.g. [_DEBUG vs NDEBUG](http://stackoverflow.com/questions/2290509/debug-vs-ndebug) or [MSDN: C/C++ - Preprocessor Reference - Preprocessor - Macros - Predefined Macros](https://msdn.microsoft.com/en-us/library/b0084kay.aspx). – Florian Dec 29 '16 at 20:25
  • Ah, now I see. It was needed to remove also /LDd, /MDd and /MTd. – wl2776 Dec 30 '16 at 10:41
  • That's then more or less the same as the "RelWithDebInfo" configuration. So you could probably copy the settings from there. – Florian Dec 31 '16 at 15:11