Generator expressions for IMPORTED_IMPLIB/LOCATION properties?

CMake 3.21:

I’m trying to wrap fmod with a SHARED IMPORTED target and support Windows builds. The .lib name depends on bitness and build type, as does the dll, but the IMPORTED_IMPLIB and IMPORTED_LOCATION properties don’t appear to take generator expressions.

SET_PARGET_PROPERTIES(
    ExternFMOD
    PROPERTIES
        IMPORTED_IMPLIB "${_fmod_lib_dir}/$<IF:$<CONFIG:Debug>,fmodL64_vc.lib,fmod64_vc.lib>"
        IMPORTED_LOCATION "${_fmod_lib_dir}/$<IF:$<CONFIG:Debug>,fmodL64.dll,fmod64.dll>"
)

fails:

LINK : fatal error LNK1104: cannot open file '...\lib\$<IF:$<CONFIG:Debug>,fmodL64_vc.lib,fmod64_vc.lib>'  ...

It doesn’t appear to allow the old ‘optimized’ or ‘debug’ patterns, either.

This approach seems to be dead in the water without explicit generator expression support for IMPLIB_ properties?

You can use specialized properties for some configurations: IMPORTED_IMPLIB_<CONFIG> and IMPORTED_LOCATION_<CONFIG>.

SET_PARGET_PROPERTIES(
    ExternFMOD
    PROPERTIES
        IMPORTED_IMPLIB_DEBUG "${_fmod_lib_dir}/fmodL64_vc.lib"
        IMPORTED_IMPLIB "${_fmod_lib_dir}/fmod64_vc.lib"
        IMPORTED_LOCATION_DEBUG "${_fmod_lib_dir}/fmodL64.dll"
        IMPORTED_LOCATION "${_fmod_lib_dir}/fmod64.dll"
)
1 Like