mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: Build binpac shared lib instead of static by default
Related to https://github.com/zeek/zeek/issues/307
This commit is contained in:
parent
7bb1a148af
commit
7e6e24a4d8
2 changed files with 50 additions and 8 deletions
|
@ -3,6 +3,20 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||||
include(cmake/CommonCMakeConfig.cmake)
|
include(cmake/CommonCMakeConfig.cmake)
|
||||||
|
|
||||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1)
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1)
|
||||||
|
string(REPLACE "." " " _version_numbers ${BINPAC_VERSION})
|
||||||
|
separate_arguments(_version_numbers)
|
||||||
|
list(GET _version_numbers 0 BINPAC_VERSION_MAJOR)
|
||||||
|
list(GET _version_numbers 1 BINPAC_VERSION_MINOR)
|
||||||
|
|
||||||
|
# The SO number shall increase only if binary interface changes.
|
||||||
|
set(BINPAC_SOVERSION 0)
|
||||||
|
|
||||||
|
set(ENABLE_SHARED true)
|
||||||
|
|
||||||
|
if ( ENABLE_STATIC_ONLY )
|
||||||
|
set(ENABLE_STATIC true)
|
||||||
|
set(ENABLE_SHARED false)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Set default install paths
|
# Set default install paths
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -43,11 +57,27 @@ if (CMAKE_BUILD_TYPE)
|
||||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
macro(display test desc summary)
|
||||||
|
if ( ${test} )
|
||||||
|
set(${summary} ${desc})
|
||||||
|
else ()
|
||||||
|
set(${summary} no)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
display(ENABLE_SHARED yes shared_summary)
|
||||||
|
display(ENABLE_STATIC yes static_summary)
|
||||||
|
|
||||||
message(
|
message(
|
||||||
"\n==================| BinPAC Build Summary |===================="
|
"\n==================| BinPAC Build Summary |===================="
|
||||||
|
"\nVersion: ${BINPAC_VERSION}"
|
||||||
|
"\nSO version: ${BINPAC_SOVERSION}"
|
||||||
"\n"
|
"\n"
|
||||||
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
|
||||||
"\nDebug mode: ${ENABLE_DEBUG}"
|
"\nDebug mode: ${ENABLE_DEBUG}"
|
||||||
|
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
||||||
|
"\nShared libs: ${shared_summary}"
|
||||||
|
"\nStatic libs: ${static_summary}"
|
||||||
"\n"
|
"\n"
|
||||||
"\nCC: ${CMAKE_C_COMPILER}"
|
"\nCC: ${CMAKE_C_COMPILER}"
|
||||||
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
|
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
|
||||||
|
|
|
@ -25,11 +25,21 @@ set(binpac_lib_SRCS
|
||||||
${binpac_headers}
|
${binpac_headers}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(binpac_lib STATIC ${binpac_lib_SRCS})
|
if ( ENABLE_SHARED )
|
||||||
|
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
||||||
|
set_target_properties(binpac_lib PROPERTIES
|
||||||
|
SOVERSION ${BINPAC_SOVERSION}
|
||||||
|
VERSION ${BINPAC_VERSION_MAJOR}.${BINPAC_VERSION_MINOR}
|
||||||
|
MACOSX_RPATH true
|
||||||
|
OUTPUT_NAME binpac)
|
||||||
|
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
set_target_properties(binpac_lib PROPERTIES OUTPUT_NAME binpac)
|
if ( ENABLE_STATIC )
|
||||||
|
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
||||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
set_target_properties(binpac_static PROPERTIES OUTPUT_NAME binpac)
|
||||||
|
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif ()
|
||||||
|
|
||||||
if ( BRO_ROOT_DIR )
|
if ( BRO_ROOT_DIR )
|
||||||
# Installed in binpac subdir just for organization purposes.
|
# Installed in binpac subdir just for organization purposes.
|
||||||
|
@ -40,9 +50,11 @@ endif ()
|
||||||
|
|
||||||
# This is set to assist superprojects that want to build BinPac
|
# This is set to assist superprojects that want to build BinPac
|
||||||
# from source and rely on it as a target
|
# from source and rely on it as a target
|
||||||
set(BinPAC_LIBRARY binpac_lib
|
if ( ENABLE_SHARED )
|
||||||
CACHE STRING "BinPAC static library" FORCE
|
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
|
||||||
)
|
else ()
|
||||||
|
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(BinPAC_INCLUDE_DIR
|
set(BinPAC_INCLUDE_DIR
|
||||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue