CMake output name for dynamic-loaded library?

10,244

Solution 1

You can unset the prefix with this line:

set_target_properties(foo PROPERTIES PREFIX "")

Solution 2

The prefix "lib" is a convention for unix/linux and is exploited widely by compilers (e.g. when you link you write -lfoo).

I don't know if you can force cmake to create foo.so instead of libfoo.so, but maybe you can use "libfoo" for python module. Another option is to create install target in cmake ,which will renmae libfoo.so to foo.so

Share:
10,244
Anton Kazennikov
Author by

Anton Kazennikov

Updated on June 05, 2022

Comments

  • Anton Kazennikov
    Anton Kazennikov almost 2 years

    I'm trying to write cmake rules to build dynamic-loaded library for python using boost.python on linux. I'd like to use 'foo' for python module name. So, the library must be called foo.so. But by default, cmake uses standard rules for library naming, so if I write

    add_library(foo foo.cpp)
    

    I will get libfoo.so on output. Even set_target_properties(foo PROPERTIES OUTPUT_NAME "foobar") will create libfoobar.so.

    How to change this behavior?