[CMake] How does one figure configuration in CMakeLists.txt?

Brad King brad.king at kitware.com
Sat Feb 26 20:24:43 EST 2005


Shishir Ramam wrote:
> I have been unable to figure out which config (Debug/Release)
> is set in a Visual Studio project. 
> 
> The problem is that I'd like to copy a config file into the same 
> directory as the executable in the binary tree. 
> 
> Using ${CMAKE_CURRENT_BINARY_DIR} puts it in the 
> parent directory of the executable. 

There is a variable "${CMAKE_CFG_INTDIR}" that evaluates to the proper 
directory for all configurations on any platform.  Basically it 
evaluates to nothing for Makefiles and $(IntDir) for project files with 
multiple configurations.  The catch is that anything using it must be 
evaluated at build time so that things like $(IntDir) are evaluated by 
the build system.  For example, something like:

ADD_CUSTOM_TARGET(copy_text ALL
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src.txt
   ${CMAKE_COMMAND} -E copy
   ${CMAKE_CURRENT_SOURCE_DIR}/src.txt
   ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_CFG_INTDIR}/dest.txt
)

Will produce a custom target that copies the file for you at build time 
into the proper location.

-Brad


More information about the CMake mailing list