[CMake] VS.NET generation...

Brad King brad.king at kitware.com
Mon Nov 1 21:16:50 EST 2004


Lars Pechan wrote:
> Hi there,
> I have two questions about the VS.NET 2003 generator:
> 
> Q1) LIBRARY/EXECUTABLE_OUTPUT_PATH
> I use this to make sure some exes and libs end up where I want them. 
> During the build I then need to run some of the utilities that have been 
> created in earlier steps.  Essentially I do
> 
> SET(EXEDIR ${Proj_BINARY_DIR}/exe)
> 
> ADD_EXECUTABLE(foo ${fooSources})
> SET(EXECUTABLE_OUTPUT_PATH ${EXEDIR})
> 
> and then invoke foo.exe by running
> 
> COMMAND ${EXEDIR}/foo
> 
> in a custom command later.
> 
> Using NMake Makefiles this works fine. Using the VS.NET generator though 
> changes my EXE dir to ${EXE}/Release for a Release build and 
> ${EXE}/Debug for a Debug build. foo.exe ends up in ${EXE}/Release.
> 
> Now when I need to run foo.exe later it is not found. My CUSTOM_COMMAND 
> refers to it as ${EXE}/foo but it isn't there, it's in ${EXE}/Release.
> 
> So how can I reference an executable produced in the project itself 
> without hacking CMakeLists.txt for different buildstyles or something 
> equally unmaintainable?

There is a variable called CMAKE_CFG_INTDIR which expands to "." for 
Makefile builds and $(INTDIR) for VS project builds.  This is intended 
to solve the problem.  The best solution though is to use the example 
from the FAQ:

http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F

> Q2) Suppressing _DEBUG from a debug build.
> As far as I can see either the CMake generator or VS.NET itself 
> automatically adds _DEBUG to the preprocessor settings for a project. 
> This leads to linking being done against /MTd which contains the debug 
> routines for malloc etc.
> 
> The project I'm converting has to be linked against /MT so I tried doing 
> a REMOVE_DEFINITIONS(-D_DEBUG) (also tried /D_DEBUG and just _DEBUG) but 
> the symbol is still defined.
> 
> Is there any way around this?

You can try the "RelWithDebInfo" build configuration.  This might do 
what you want.

-Brad


More information about the CMake mailing list