Sadly, CMake follows the awkward "implicit lib" convention, which inevitably causes problems when library names don't actually follow the convention (e.g. zlib), or have 'lib' as an explicit part of their name.
For example, suppose I want to add libusb:
add_library(libusb ...)
On Windows this will correctly produce libusb.lib
. On Unix it will produce the hilarious liblibusb.a
. Is there any way to prevent this behaviour? I know I can set the output name explicitly using OUTPUT_NAME
but I'd have to use some funky generator expressions to preserve libusb.lib
on Windows. I wonder if there is a better way?
(And no add_library(usb ...
is not a solution; the library is called libusb not usb.)
You can modify it via CMAKE_STATIC_LIBRARY_PREFIX
. So in your case just do after your project()
command:
set(CMAKE_STATIC_LIBRARY_PREFIX "")
Or you can change it per target via the PREFIX
target property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With