Reputation: 2682
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.
Upvotes: 5
Views: 1917
Reputation: 3599
set LIBRARY_OUTPUT_NAME
for shared libraries
set OUTPUT_NAME
for static libraries
sample code from ShivaVG
# create object
add_library(ShivaVG_objlib OBJECT
${libShivaVG_SOURCES})
set_property(TARGET ShivaVG_objlib
PROPERTY POSITION_INDEPENDENT_CODE 1)
# create library (static)
add_library(ShivaVGStatic
STATIC $<TARGET_OBJECTS:ShivaVG_objlib>)
set_target_properties(ShivaVGStatic
PROPERTIES OUTPUT_NAME ShivaVG)
# create library (shared)
add_library(ShivaVGShared
SHARED $<TARGET_OBJECTS:ShivaVG_objlib>)
target_link_libraries(ShivaVGShared
${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} -lm)
set_target_properties(ShivaVGShared
PROPERTIES LIBRARY_OUTPUT_NAME ShivaVG)
this will produce ShivaVG.so
and ShivaVG.a
Upvotes: 1
Reputation: 2682
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.
Upvotes: 3