1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
# Copyright 2017 Skytechnology sp. z o.o..
#
# This file is part of LizardFS.
#
# LizardFS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# LizardFS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LizardFS If not, see <http://www.gnu.org/licenses/>.
function(shared_add_library NAME ...)
list(REMOVE_AT ARGV 0)
add_library(${NAME} ${ARGV})
if(ENABLE_PIC_TARGETS)
add_library(${NAME}_pic ${ARGV})
if("${CMAKE_VERSION}" VERSION_GREATER 2.8.9)
set_property(TARGET ${NAME}_pic PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
set_property(TARGET ${NAME}_pic PROPERTY COMPILE_FLAGS "-fPIC")
endif()
endif()
endfunction()
function(shared_target_link_libraries TARGET)
list(REMOVE_AT ARGV 0)
set(libraries_static "")
set(libraries_pic "")
set(scan_mode "MIXED")
foreach(library IN LISTS ARGV)
if("${library}" MATCHES "STATIC|SHARED|MIXED" )
set(scan_mode "${library}")
elseif("${scan_mode}" STREQUAL "STATIC")
list(APPEND libraries_static "${library}")
elseif("${scan_mode}" STREQUAL "SHARED")
list(APPEND libraries_pic "${library}")
else()
if(TARGET "${library}_pic")
list(APPEND libraries_pic "${library}_pic")
else()
list(APPEND libraries_pic "${library}")
endif()
list(APPEND libraries_static "${library}")
endif()
endforeach()
target_link_libraries(${TARGET} ${libraries_static})
if(ENABLE_PIC_TARGETS)
target_link_libraries(${TARGET}_pic ${libraries_pic})
endif()
endfunction()
|