Search code examples
cmakelibraries

CMake ignores library_output_name


I have a simple CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8.9) project (sample)

add_library(Shared SHARED foo.c)
set_target_properties(Shared PROPERTIES library_output_name libdemo.so.1.2.3)

I want my library to be called libdemo.so.1.2.3 but it is being called libShared.so. How can I get this file to name the library as I want? Since I want to add a static version of the same library I don't just want to change the add_library()directive since the static library will have the same name with just a different extension.


Solution

  • Changing set_target_properties() line to be:

    set_target_properties(Shared PROPERTIES LIBRARY_OUTPUT_NAME demo.so.1.2.3)

    solves the problem.

    No error is generated by the previous method but it silently ignores the line.