2021-12-08 11:32:04 +00:00
|
|
|
# Создание статической библиотеки из объектной библиотеки
|
|
|
|
function(myx_cmake_add_static_library target)
|
2021-12-10 08:13:43 +00:00
|
|
|
myx_cmake_canonical_string(${target} _ctarget)
|
|
|
|
option(BUILD_${_ctarget}_STATIC "build static library ${_ctarget}" ON)
|
|
|
|
if(NOT BUILD_${_ctarget}_STATIC)
|
|
|
|
return()
|
|
|
|
endif()
|
2021-12-09 14:14:28 +00:00
|
|
|
get_target_property(__target_type ${target} TYPE)
|
|
|
|
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
|
2021-12-12 20:11:20 +00:00
|
|
|
message(FATAL_ERROR
|
|
|
|
"MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
|
2021-12-08 11:32:04 +00:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>)
|
2021-12-09 14:14:28 +00:00
|
|
|
set_target_properties(${target}-static
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME ${target}
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
|
|
|
install(TARGETS ${target}-static
|
|
|
|
COMPONENT static
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2021-12-08 11:32:04 +00:00
|
|
|
|
|
|
|
endfunction()
|