[CMake] Using Visual Studio $(PlatformName) in <CONFIG>_POSTFIX

Paul Richards paul.richards at gmail.com
Mon Apr 28 11:05:13 EDT 2008


I am using CMake to replicate an existing set of Visual Studio project files.

The old project files used the $(PlatformName) and
$(ConfigurationName) macros from Visual Studio in the output
filenames.  This resulted in output filenames of the pattern:

foobar_Win32_Debug.lib
foobar_Win32_Release.lib
foobar_x64_Debug.lib
foobar_x64_Release.lib


If I use the string $(PlatformName) in my <CONFIG>_POSTFIX setting
within CMake, eg:
SET_TARGET_PROPERTIES(FooBar PROPERTIES DEBUG_POSTFIX _$(PlatformName)_Debug)

Two things happen:

1)
The build in Visual Studio succeeds and I get a file called
"FooBar_Win32_Debug.lib" exactly as I want.

2)
The INSTALL project fails as it can't find
"FooBar_$(PlatformName)_Release.lib".  Presumably whatever tool is
performing the install doesn't expand $(PlatformName).


As I see it, either (1) or (2) is a bug.  [I imagine that (1) will be
dubbed a bug, as arguably CMake should escape characters that are
special to the target build tool in such a way that the filenames are
the same across all platforms.  This would indirectly fix (2), as the
file "FooBar_$(PlatformName)_Release.lib" would now genuinely exist.]

So my question, is there a recommended way to create target filenames
of the form I require (foobar_Win32_Debug.lib,
foobar_Win32_Release.lib, ..) and so the INSTALL projects work
correctly?



-- 
Paul Richards


More information about the CMake mailing list