[CMake] Generated VC8 project don't change the library paths

Brad King brad.king at kitware.com
Fri Sep 1 12:06:04 EDT 2006


Radu Mihai wrote:
> Hello, first time on the list
> 
> I am working on a project that links with some external libs that we
> build ourselves (OpenSceneGraph).
> To accommodate the use of release and debug versions the current layout
> looks like this:
> osg/lib.rel/ .....
> osg/lib.dbg/ .....
> 
> The CMakeLists.txt for our code has this to set the directory to add to
> search for libs:
> 
> set(tool_libs ${OSG_ROOT}/lib.${${CMAKE_BUILD_TYPE}_DIR}/)
[snip]
> Is there any way to set LINK_DIRECTORIES based on the configuration in
> such a way that VC8(7,6) will have the directory change when the build
> type is changed in the IDE ?

CMAKE_BUILD_TYPE is not used by the VS generators.  It is used by the
Makefile generators to select which configuration to build.  Since VS
selects the configuration at build time CMake generates all available
configurations into the project files.  The way to change a path on a
per-configuration basis is to use ${CMAKE_CFG_INTDIR} which expands to
"." on Makefile generators and "$(OutDir)" on VS generators.  For VS
this will give you "Debug" and "Release" at build time depending on the
configuration chosen.

Instead of using link directories should specify full paths to the
libraries to be linked.  You can switch between release and debug
libraries like this:

SET(MY_LIBS optimized /path/to/lib.rel/foo_opt.lib
            debug     /path/to/lib.dbg/foo_dbg.lib)

Then use TARGET_LINK_LIBRARIES with ${MY_LIBS}.

-Brad


More information about the CMake mailing list