Problem specifying Install Prefix

I wrote:

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/${CMAKE_VS_PLATFORM_NAME}/$<CONFIG>)
message ("Install prefix set to: " ${CMAKE_INSTALL_PREFIX})

Which reported:

Install prefix set to: C:/Users/amonra/Documents/GitHub/DSS/x64/$<CONFIG>

Whereas I expected:

Install prefix set to: C:/Users/amonra/Documents/GitHub/DSS/x64/Debug

What am I doing wrong please?

David

From what I remember, you can not use $<CONFIG> like that, as this is a generator expression, so it doesn’t get evaluated at that stage. You probably should use CMAKE_BUILD_TYPE instead, but that will work only with single-config generators (such as Ninja); while with multi-config generators (such as Visual Studio) it will be either empty or some auto-detected default value, so it isn’t reliable (unless you provide it with -D or environment variable).

1 Like

Using CMAKE_BUILD_TYPE seemed to work OK, I added some code to catch the case where it isn’t set.

Thanks, David