0

In my CMakeLists I have a statement:

target_link_libraries(mytarget somelib)

The problem is that I am working on Windows and somelib has a verbatim name - libsomelib.a. I cannot control that because the library is built by another person (who thinks it is a cool idea to name Windows libraries in a UNIX fashion) and installed somewhere.

Prior to the statement I have

set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")

which seems to affect only libraries produced by a given CMakeLists, and, in the list of dependencies (of a generated VS project) it still appears as somelib.lib. My question is what can be done to get this dependent library properly named?

def
  • 521
  • 4
  • 16
  • 1
    research `add_library(.. IMPORTED` – KamilCuk Aug 23 '21 at 20:58
  • 1
    "who thinks it is a cool idea to name Windows libraries in a UNIX fashion" - Probably, that library is build with MinGW, which creates `.a` library files on Windows. In that case, it is unlikely that you could use that library with Visual Studio. In any case, you could call `target_link_libraries` with **exact path** to the `somelib` library, like `"C:/path/to/lib/libsomelib.a"`. See also [that question](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library) about linking with external library. – Tsyvarev Aug 23 '21 at 21:04
  • @Tsyvarev, it is built under Cygwin using VS toolchain – def Aug 23 '21 at 21:10

0 Answers0