mirror of https://github.com/getdnsapi/getdns.git
Add options ENABLE_STATIC and ENABLE_SHARED.
Stick a cautious toe in the water of CMake options, and add enabling/disabling shared/static library builds, because that's easy.
This commit is contained in:
parent
d447999c60
commit
60eb113770
|
@ -110,6 +110,12 @@ else ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Options.
|
# Options.
|
||||||
|
option(ENABLE_SHARED "build shared libraries" ON)
|
||||||
|
option(ENABLE_STATIC "build static libraries" ON)
|
||||||
|
if ((NOT ENABLE_SHARED) AND (NOT ENABLE_STATIC))
|
||||||
|
message(FATAL_ERROR "You must build either static or shared libraries.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
set(DNSSEC_ROADBLOCK_AVOIDANCE 1) # Nail on, as build fails if off.
|
set(DNSSEC_ROADBLOCK_AVOIDANCE 1) # Nail on, as build fails if off.
|
||||||
set(STUB_NATIVE_DNSSEC 1) # Nail on for now.
|
set(STUB_NATIVE_DNSSEC 1) # Nail on for now.
|
||||||
set(MAXIMUM_UPSTREAM_OPTION_SPACE 3000)
|
set(MAXIMUM_UPSTREAM_OPTION_SPACE 3000)
|
||||||
|
@ -465,6 +471,7 @@ set_property(TARGET getdns_objects PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||||
set_property(TARGET getdns_objects PROPERTY C_STANDARD 11)
|
set_property(TARGET getdns_objects PROPERTY C_STANDARD 11)
|
||||||
|
|
||||||
# Static library version of main library.
|
# Static library version of main library.
|
||||||
|
if (ENABLE_STATIC)
|
||||||
add_library(getdns STATIC $<TARGET_OBJECTS:getdns_objects>)
|
add_library(getdns STATIC $<TARGET_OBJECTS:getdns_objects>)
|
||||||
target_include_directories(getdns PUBLIC
|
target_include_directories(getdns PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
||||||
|
@ -477,8 +484,10 @@ target_link_libraries(getdns
|
||||||
${getdns_system_libs}
|
${getdns_system_libs}
|
||||||
)
|
)
|
||||||
set_target_properties(getdns PROPERTIES OUTPUT_NAME getdns${static_lib_suffix})
|
set_target_properties(getdns PROPERTIES OUTPUT_NAME getdns${static_lib_suffix})
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Shared library version of main library.
|
# Shared library version of main library.
|
||||||
|
if (ENABLE_SHARED)
|
||||||
add_library(getdns_shared SHARED $<TARGET_OBJECTS:getdns_objects>)
|
add_library(getdns_shared SHARED $<TARGET_OBJECTS:getdns_objects>)
|
||||||
target_include_directories(getdns_shared PUBLIC
|
target_include_directories(getdns_shared PUBLIC
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
||||||
|
@ -492,6 +501,10 @@ target_link_libraries(getdns_shared
|
||||||
)
|
)
|
||||||
set_target_properties(getdns_shared PROPERTIES OUTPUT_NAME getdns)
|
set_target_properties(getdns_shared PROPERTIES OUTPUT_NAME getdns)
|
||||||
|
|
||||||
|
if (NOT ENABLE_STATIC)
|
||||||
|
add_library(getdns ALIAS getdns_shared)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Generate platform-specific link file with the export symbols.
|
# Generate platform-specific link file with the export symbols.
|
||||||
file(STRINGS src/libgetdns.symbols symbols)
|
file(STRINGS src/libgetdns.symbols symbols)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
@ -528,6 +541,7 @@ else ()
|
||||||
math(EXPR compat_version "${GETDNS_VERSION_CURRENT}-${GETDNS_VERSION_AGE}")
|
math(EXPR compat_version "${GETDNS_VERSION_CURRENT}-${GETDNS_VERSION_AGE}")
|
||||||
set_target_properties(getdns_shared PROPERTIES VERSION "${compat_version}.${GETDNS_VERSION_AGE}.${GETDNS_VERSION_REVISION}" SOVERSION "${compat_version}")
|
set_target_properties(getdns_shared PROPERTIES VERSION "${compat_version}.${GETDNS_VERSION_AGE}.${GETDNS_VERSION_REVISION}" SOVERSION "${compat_version}")
|
||||||
endif ()
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
# The tools.
|
# The tools.
|
||||||
|
@ -635,11 +649,13 @@ set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
configure_file(getdns.pc.in getdns.pc @ONLY)
|
configure_file(getdns.pc.in getdns.pc @ONLY)
|
||||||
|
|
||||||
# Installing.
|
# Installing.
|
||||||
install(TARGETS getdns getdns_shared getdns_query getdns_server_mon
|
if (ENABLE_STATIC)
|
||||||
RUNTIME DESTINATION bin
|
install(TARGETS getdns LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||||
LIBRARY DESTINATION lib
|
endif ()
|
||||||
ARCHIVE DESTINATION lib
|
if (ENABLE_SHARED)
|
||||||
)
|
install(TARGETS getdns_shared LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||||
|
endif ()
|
||||||
|
install(TARGETS getdns_query getdns_server_mon RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/getdns DESTINATION include)
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/getdns DESTINATION include)
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man3 DESTINATION share/man)
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man3 DESTINATION share/man)
|
||||||
|
|
Loading…
Reference in New Issue