[Cmake] How to do configuration specific options in the MS Visual
Studio Projects
Brad King
brad.king at kitware.com
Mon Jun 28 10:11:27 EDT 2004
Aleksey Sanin wrote:
> Hi, All!
>
> Probably the question is trivial but I can find answer in cmake docs or
> in google and
> my experiments show no positive signs. Thus I got to a point when I need
> help.
>
> I have a CMake based makefiles system that generates MS VS .NET project
> files.
> There is an external library ABC that has two flavors: debug and
> release. Obviously,
> I want to link my debug builds with debug version of ABC and link my
> release builds
> with release version of ABC. The problem is that both debug and release
> versions
> of ABC have *the same* name "libabc.lib". Thus I want to place these
> versions into
> two different folders, say "external/debug" and "external/release". Now
> I need to tell
> CMake to generate *different* library search paths for "Debug" and
> "Release" configurations
> in MS Visual Studio and I can't find a way to do this.
>
> I have found the "debug" and "optimized" flags for LINK_LIBRARIES
> directive. But
> this does not work if the library has the same name. By some internal
> reasons, the option
> of renaming the library ABC is not a solution. Also I know that I can
> have different debug and
> release names for my target and use SET_TARGET_PROPERTIES command to set
> different LINK_FLAGS but this is also not acceptable to me. Also
> creating two project
> files is not a good idea too.
>
> I would appreciate any hints for the solution.
There is no explicit support for something like this in the current
Visual Studio generators. You can try something like this (untested):
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
TARGET_LINK_LIBRARIES(mytarget /path/to/$(IntDir)/libabc.lib)
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio")
# Do something else to link the library.
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
The "$(IntDir)" should be parens, not curlys. It will be passed by
CMake through to the generated project file and Visual Studio will
evaluate "$(IntDir)" to "Debug" or "Release" at build time.
-Brad
More information about the Cmake
mailing list