Включение/отключение сборки вариантов библиотеки через флаги CMake

This commit is contained in:
Andrei Astafev 2021-12-10 11:13:43 +03:00
parent 357c19771f
commit 032fdee52b
2 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# Создание динамической библиотеки из объектной библиотеки
function(myx_cmake_add_shared_library target)
myx_cmake_canonical_string(${target} _ctarget)
option(BUILD_${_ctarget}_SHARED "build shared library ${_ctarget}" ON)
if(NOT BUILD_${_ctarget}_SHARED)
return()
endif()
get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(
@ -19,5 +24,4 @@ function(myx_cmake_add_shared_library target)
install(TARGETS ${target}-shared
COMPONENT main
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endfunction()

View File

@ -1,5 +1,10 @@
# Создание статической библиотеки из объектной библиотеки
function(myx_cmake_add_static_library target)
myx_cmake_canonical_string(${target} _ctarget)
option(BUILD_${_ctarget}_STATIC "build static library ${_ctarget}" ON)
if(NOT BUILD_${_ctarget}_STATIC)
return()
endif()
get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(