cmakelinker

Cmake, link library, possible different endings of the name


I need to link the library. The name of the lib is LibName.VERSION.lib. VERSION can be different. How do I tell cmake that?

I use target_link_libraries. If I specify precisely the "LibName.VERSION" as a name it works, but the VERSION can differ. If I specify only the "LibName" it does not work. Is there any way without specifying the VERSION (without env var, cmake args, etc.)?


Solution

  • I solved this by using:

    target_link_libraries(
        ${PROJECT_NAME} PRIVATE
        "${SOME_PATH}/lib/LibName.*.lib"
    )