0

I want my libraries to be generated as lib-something.so.1.0.0 and not liblib-something.so.1.0.0. For this, I used the proposals from this link: stop_preppending_'lib'_to_libs. But it seems that CMake is not able to find the library anymore.

This is what I did:

lib-something/src/CMakeLists.txt:

add_library(lib-something SHARED
    ${CMAKE_CURRENT_SOURCE_DIR}/Something.cpp )

set_target_properties(lib-something PROPERTIES PREFIX "")

lib-another/src/CMakeLists.txt:

add_dependencies(lib-another lib-something)

It is able to find it if I do:

add_dependencies(lib-another something)

altough my target is named 'lib-something'. I don't want that. If I were okey with having to add dependencies as 'something' I would have removed the 'lib' from the target name and it would have been enough. I find this an easy way to be identified by the users as libraries and not executables.

Any ideas?

Edited: I also tried this:

add_library(something SHARED
        ${CMAKE_CURRENT_SOURCE_DIR}/Something.cpp )
set_target_properties(something PROPERTIES OUTPUT_NAME "lib-something")

In other projects:

add_dependencies(lib-another lib-something)

It works, but it looks that the generation of the libraries is also liblib...

As far as I have seen, there is no way to avoid this 'liblib' thing without changing the prefix into "", and if this prefix is changed then the library is not found no matter what.

  • It seems you want to have **target** named `something` but name a library file **differently** (as `lib-something`). If so, then see that question about renaming the file: https://stackoverflow.com/questions/31038963/how-do-you-rename-a-library-filename-in-cmake. – Tsyvarev May 18 '20 at 09:59
  • No, I want target be named lib-something and the library the file also lib-something. And I want to be able to use lib-something also in add_dependencies in other projects. I the properties from your link. See my edited question. – Maria Cojocaru May 18 '20 at 18:02
  • Sorry, still don't understand the problem. The command [add_dependencies](https://cmake.org/cmake/help/v3.9/command/add_dependencies.html) accepts exactly a **target name**. The name of the output file is completely unrelated for this command. So, what do you mean when say "CMake is not able to find the library anymore." and by providing `add_dependencies(lib-another lib-something)` line of code? – Tsyvarev May 18 '20 at 18:14
  • When generating the libraries, CMake prepends the name of the target - which already has the keyword 'lib' - with another 'lib'. To solve that I set the PREFIX property void. The generation of libraries is good but CMake cannot find the library I give as a dependency to other project... I think because my target is lib-something but when CMake prepends a target it prepends it like this: libsomething... without dash. – Maria Cojocaru May 19 '20 at 15:51

0 Answers0