Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/InstallationHelper.cmake
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | _add_install_target("${ARG_COMPONENT}" | ||||
${INSTALL_EXCLUDE_FROM_ALL} | ${INSTALL_EXCLUDE_FROM_ALL} | ||||
DEPENDS ${_target} | DEPENDS ${_target} | ||||
) | ) | ||||
endfunction() | endfunction() | ||||
function(install_shared_library NAME) | function(install_shared_library NAME) | ||||
cmake_parse_arguments(ARG | cmake_parse_arguments(ARG | ||||
"EXCLUDE_FROM_ALL" | "EXCLUDE_FROM_ALL" | ||||
"" | "DESCRIPTION" | ||||
"PUBLIC_HEADER" | "PUBLIC_HEADER" | ||||
${ARGN} | ${ARGN} | ||||
) | ) | ||||
set(_sources ${ARG_UNPARSED_ARGUMENTS}) | set(_sources ${ARG_UNPARSED_ARGUMENTS}) | ||||
get_target_property(_target_type ${NAME} TYPE) | get_target_property(_target_type ${NAME} TYPE) | ||||
if(_target_type STREQUAL "SHARED_LIBRARY") | if(_target_type STREQUAL "SHARED_LIBRARY") | ||||
set(_shared_name "${NAME}") | set(_shared_name "${NAME}") | ||||
target_sources(${NAME} PRIVATE ${_sources}) | target_sources(${NAME} PRIVATE ${_sources}) | ||||
else() | else() | ||||
set(_shared_name "${NAME}-shared") | set(_shared_name "${NAME}-shared") | ||||
add_library(${_shared_name} SHARED ${_sources}) | add_library(${_shared_name} SHARED ${_sources}) | ||||
target_link_libraries(${_shared_name} ${NAME}) | target_link_libraries(${_shared_name} ${NAME}) | ||||
endif() | endif() | ||||
if(ARG_PUBLIC_HEADER) | if(ARG_PUBLIC_HEADER) | ||||
set_property(TARGET ${_shared_name} PROPERTY PUBLIC_HEADER ${ARG_PUBLIC_HEADER}) | set_property(TARGET ${_shared_name} PROPERTY PUBLIC_HEADER ${ARG_PUBLIC_HEADER}) | ||||
endif() | endif() | ||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |||||
# FIXME For compatibility reason with autotools, the version is set | |||||
# to 0.0.0 (major being actually 0). This is obviously wrong and the | |||||
# version of the library should reflect the version of the release. | |||||
# On platforms other than linux, only the major version (0) is used. | |||||
# Replace the VERSION line with the statement below to set the | |||||
# correct version: | |||||
# set(_properties VERSION "${CMAKE_PROJECT_VERSION}") | |||||
list(APPEND _properties VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.0.0") | |||||
else() | |||||
list(APPEND _properties VERSION "${CMAKE_PROJECT_VERSION_MAJOR}") | |||||
endif() | |||||
# For autotools compatibility, rename the library to ${OUTPUT_NAME}-0.dll | |||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
list(APPEND _properties OUTPUT_NAME "${NAME}-${CMAKE_PROJECT_VERSION_MAJOR}") | |||||
# DLL_EXPORT is defined by libtool, and is expected by some sources. | # DLL_EXPORT is defined by libtool, and is expected by some sources. | ||||
target_compile_definitions(${_shared_name} PRIVATE DLL_EXPORT) | target_compile_definitions(${_shared_name} PRIVATE DLL_EXPORT) | ||||
else() | |||||
list(APPEND _properties OUTPUT_NAME "${NAME}") | include(WindowsVersionInfo) | ||||
if(ARG_DESCRIPTION) | |||||
set(DESCRIPTION DESCRIPTION "${ARG_DESCRIPTION}") | |||||
endif() | |||||
generate_windows_version_info(${_shared_name} ${DESCRIPTION}) | |||||
endif() | endif() | ||||
list(APPEND _properties OUTPUT_NAME "${NAME}") | |||||
list(APPEND _properties VERSION "${CMAKE_PROJECT_VERSION}") | |||||
list(APPEND _properties SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") | list(APPEND _properties SOVERSION "${CMAKE_PROJECT_VERSION_MAJOR}") | ||||
set_target_properties(${_shared_name} PROPERTIES ${_properties}) | set_target_properties(${_shared_name} PROPERTIES ${_properties}) | ||||
# Forward EXCLUDE_FROM_ALL if set | # Forward EXCLUDE_FROM_ALL if set | ||||
if(ARG_EXCLUDE_FROM_ALL) | if(ARG_EXCLUDE_FROM_ALL) | ||||
set(FORWARD_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) | set(FORWARD_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) | ||||
endif() | endif() | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |