How to evaluate $<CONFIG>_POSTFIX?

I’m trying to do:

    install ( FILES
        ${CMAKE_CURRENT_BINARY_DIR}/BTF.pc
        DESTINATION ${SUITESPARSE_LIBDIR}/pkgconfig RENAME BTF${$<CONFIG>_POSTFIX} )

Which doesn’t work (‘<’ in variable name). And $_POSTFIX evaluated to Release_POSTFIX.
How do I get this to evaluate to whatever the build type postfix is? Thanks!

install doesn’t support genex arguments (not that this works anyways as the variable expansion will try to go before the genex is expanded). I think the best you can do is install(SCRIPT) where you write it with each configuration’s postfix variable as a set() to it and then perform the file(INSTALL) manually for the requested configuration. I can try to sketch some actual code later, but I don’t have time right now.

Hmm, that seems cumbersome. Perhaps I should back up a bit and talk about the general situation:

In Fedora we build a number of BLAS using libraries in multiple flavors:

  • standard
  • 64-bit INTs with no symbol suffix
  • 64-bit INTs with _ symbol suffix

I’m trying to update the suitesparse package to the latest which is using cmake to build now and I need to build these multiple configurations - but I need to end up with different cmake and pkgconfig configurations for the different builds.

Does the above seem like the right direction for the pkgconfig files? For the cmake files I’m starting to try with CMAKE_BUILD_TYPE set to Release, Release64, Release64_ for the different builds. Does that seem right?

I’m also trying out RENAME '$name'${${CMAKE_BUILD_TYPE}_POSTFIX} which seems to expand better. But apparently that does not work, resolves to empty for me.

Hrm. Separate prefixes like MPI does sounds easier, but I guess that ship has sailed (nevermind the cross-product problem given the likely overlap of MPI and BLAS usage).

Try to uppercase the build type first.

I suspect that adding a SUITESPARSE_VARIANT_SUFFIX cache variable (or similar) to control this upstream and using it everywhere it makes sense would be better and less “oops, forgot a spot”-prone.

This seems to work:

string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
     install ( FILES
         ${CMAKE_CURRENT_BINARY_DIR}/BTF.pc
        DESTINATION ${SUITESPARSE_LIBDIR}/pkgconfig RENAME BTF${CMAKE_${CMAKE_BUILD_TYPE_UPPER}_POSTFIX}.pc )

I’m trying to find a fairly generic method that could apply to any cmake project. I’ve opened some discussion in suitespare here: Need ability to build and package multiple configurations of suitesparse · Issue #425 · DrTimothyAldenDavis/SuiteSparse · GitHub

Unfortunately I can’t install the different build types to the same cmake directory. I get:

-- Old export file "/home/orion/BUILDROOT/suitesparse-7.2.0-0.2.fc40.x86_64/usr/lib64/cmake/SuiteSparse_config/SuiteSparse_configTargets.cmake" will be replaced.  Removing files [/home/orion/BUILDROOT/suitesparse-7.2.0-0.2.fc40.x86_64/usr/lib64/cmake/SuiteSparse_config/SuiteSparse_configTargets-release.cmake].

You may need to DESTDIR-redirect them and then overlay them. Or you should use Ninja Multi-Config which is more multi-config aware (and would also verify that your overlapping artifacts are