[CMake] how to compile single source file with debug options?

Gonzalo ggarra13 at gmail.com
Fri Jun 10 13:13:27 EDT 2016



El 10/06/16 a las 13:57, Sergey Spiridonov escribió:
> I do release build, but I want single source file to be compiled in
> debug mode, with "-O0 -DDEBUG" options instead of "-O3".
>
> Of course, without recompiling whole directory.
>
Oh, I see. In perspective, Windows, for example, does not allow mixing 
debug and non debug builds.
I am afraid cmake cannot do what you want.  But you may be able to do it 
with a wrapper bash script.
The idea would be to have two CMakeCache.txt files (one debug, one 
release) and a CMakeFiles directory.  Once you want to compile a single 
file in a directory, you'd rename the debug CMakeCache.txt file and run 
cmake/make.
I'll let others chime in with more elegant solutions.

-- 
Gonzalo Garramuño
ggarra13 at gmail.com



More information about the CMake mailing list