myx-cmake/MyxCMake/modules/MyxCMakeAddSharedLibrary.cmake

24 lines
869 B
CMake
Raw Normal View History

2021-12-08 11:32:04 +00:00
# Создание динамической библиотеки из объектной библиотеки
function(myx_cmake_add_shared_library target)
get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
2021-12-08 11:32:04 +00:00
message(
FATAL_ERROR
"MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
2021-12-08 11:32:04 +00:00
return()
endif()
add_library(${target}-shared SHARED $<TARGET_OBJECTS:${target}>)
set_target_properties(
${target}-shared
PROPERTIES OUTPUT_NAME ${target}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-shared
COMPONENT main
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
2021-12-08 11:32:04 +00:00
endfunction()