mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Make dependency paths relocatable
The generated configurations for both CMake and pkg-config included absolute paths to dependencies (OpenSSL, MbedTLS). This is contrary to the general CMake advise to create relocatable packages [1]. Additionally, when building both mbedtls and libevent via CMake's FetchContent in the same project, loading the project would fail with INTERFACE_INCLUDE_DIRECTORIES property contains path: "/home/user/project/cmake-build/_deps/mbedtls-build/include" which is prefixed in the source directory. The required changes include: - Adding the outer includes only to the BUILD_INTERFACE solves the makes the CMake paths relocatable and thus solves the FetchContent problem. - Updates to libevent_*.pc.in fixes the relocatable issues for pkg-config and properly declares currently missing dependencies. - Using components for linking to OpenSSL (requiring CMake 3.4) and MbedTLS. The new MbedTLS target names now match the component names of the MbedTLS' CMake project. - Use the Threads CMake library reference instead of a direct reference to support both built-in pthread and -lpthread. v2 (azat): get back CMAKE_REQUIRED_LIBRARIES [1] https://cmake.org/cmake/help/v3.25/manual/cmake-packages.7.html#creating-relocatable-packages
This commit is contained in:
parent
81c6b8823c
commit
acfac7ae4a
@ -19,7 +19,7 @@
|
|||||||
# start libevent.sln
|
# start libevent.sln
|
||||||
#
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.1.2 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
|
||||||
|
|
||||||
if (POLICY CMP0054)
|
if (POLICY CMP0054)
|
||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
@ -578,10 +578,9 @@ if (NOT EVENT__DISABLE_THREAD_SUPPORT)
|
|||||||
set(PTHREADS_AVAILABLE ON)
|
set(PTHREADS_AVAILABLE ON)
|
||||||
|
|
||||||
set(EVENT__HAVE_PTHREADS 1)
|
set(EVENT__HAVE_PTHREADS 1)
|
||||||
list(APPEND LIB_APPS ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
|
|
||||||
# for CHECK_SYMBOLS_EXIST()
|
# for CHECK_SYMBOLS_EXIST()
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
list(APPEND LIB_APPS Threads::Threads)
|
||||||
|
|
||||||
CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T)
|
CHECK_TYPE_SIZE(pthread_t EVENT__SIZEOF_PTHREAD_T)
|
||||||
list(APPEND SYMBOLS_TO_CHECK pthread_mutexattr_setprotocol)
|
list(APPEND SYMBOLS_TO_CHECK pthread_mutexattr_setprotocol)
|
||||||
@ -951,15 +950,14 @@ if (NOT EVENT__DISABLE_OPENSSL)
|
|||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
set(EVENT__HAVE_OPENSSL 1)
|
set(EVENT__HAVE_OPENSSL 1)
|
||||||
|
set(OPENSSL_TARGETS OpenSSL::SSL)
|
||||||
|
|
||||||
message(STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}")
|
message(STATUS "OpenSSL include: ${OPENSSL_INCLUDE_DIR}")
|
||||||
message(STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}")
|
message(STATUS "OpenSSL lib: ${OPENSSL_LIBRARIES}")
|
||||||
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
list(APPEND SRC_OPENSSL bufferevent_openssl.c bufferevent_ssl.c)
|
list(APPEND SRC_OPENSSL bufferevent_openssl.c bufferevent_ssl.c)
|
||||||
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
|
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
|
||||||
list(APPEND LIB_APPS ${OPENSSL_LIBRARIES})
|
list(APPEND LIB_APPS ${OPENSSL_TARGETS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT EVENT__DISABLE_MBEDTLS)
|
if (NOT EVENT__DISABLE_MBEDTLS)
|
||||||
@ -980,15 +978,14 @@ if (NOT EVENT__DISABLE_MBEDTLS)
|
|||||||
find_package(MbedTLS REQUIRED)
|
find_package(MbedTLS REQUIRED)
|
||||||
|
|
||||||
set(EVENT__HAVE_MBEDTLS 1)
|
set(EVENT__HAVE_MBEDTLS 1)
|
||||||
|
set(MBEDTLS_TARGETS MbedTLS::mbedtls MbedTLS::mbedcrypto MbedTLS::mbedx509)
|
||||||
|
|
||||||
message(STATUS "mbed TLS include: ${MBEDTLS_INCLUDE_DIR}")
|
message(STATUS "mbed TLS include: ${MBEDTLS_INCLUDE_DIR}")
|
||||||
message(STATUS "mbed TLS lib: ${MBEDTLS_LIBRARIES}")
|
message(STATUS "mbed TLS lib: ${MBEDTLS_LIBRARIES}")
|
||||||
|
|
||||||
include_directories(${MBEDTLS_INCLUDE_DIR})
|
|
||||||
|
|
||||||
list(APPEND SRC_MBEDTLS bufferevent_mbedtls.c bufferevent_ssl.c)
|
list(APPEND SRC_MBEDTLS bufferevent_mbedtls.c bufferevent_ssl.c)
|
||||||
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
|
list(APPEND HDR_PUBLIC include/event2/bufferevent_ssl.h)
|
||||||
list(APPEND LIB_APPS ${MBEDTLS_LIBRARIES})
|
list(APPEND LIB_APPS ${MBEDTLS_TARGETS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT EVENT__DISABLE_TESTS)
|
if (NOT EVENT__DISABLE_TESTS)
|
||||||
@ -996,10 +993,8 @@ if (NOT EVENT__DISABLE_TESTS)
|
|||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
|
|
||||||
if (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
|
if (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
set(EVENT__HAVE_LIBZ 1)
|
set(EVENT__HAVE_LIBZ 1)
|
||||||
list(APPEND LIB_APPS ${ZLIB_LIBRARIES})
|
list(APPEND LIB_APPS ZLIB::ZLIB)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -1011,7 +1006,7 @@ set(SRC_EXTRA
|
|||||||
sha1.c
|
sha1.c
|
||||||
evrpc.c)
|
evrpc.c)
|
||||||
|
|
||||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 3.20)
|
if(${CMAKE_VERSION} VERSION_LESS "3.20")
|
||||||
include(TestBigEndian)
|
include(TestBigEndian)
|
||||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||||
if(IS_BIG_ENDIAN)
|
if(IS_BIG_ENDIAN)
|
||||||
@ -1089,16 +1084,14 @@ add_event_library(event_extra
|
|||||||
if (NOT EVENT__DISABLE_OPENSSL)
|
if (NOT EVENT__DISABLE_OPENSSL)
|
||||||
add_event_library(event_openssl
|
add_event_library(event_openssl
|
||||||
INNER_LIBRARIES event_core
|
INNER_LIBRARIES event_core
|
||||||
OUTER_INCLUDES ${OPENSSL_INCLUDE_DIR}
|
LIBRARIES ${OPENSSL_TARGETS}
|
||||||
LIBRARIES ${OPENSSL_LIBRARIES}
|
|
||||||
SOURCES ${SRC_OPENSSL})
|
SOURCES ${SRC_OPENSSL})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT EVENT__DISABLE_MBEDTLS)
|
if (NOT EVENT__DISABLE_MBEDTLS)
|
||||||
add_event_library(event_mbedtls
|
add_event_library(event_mbedtls
|
||||||
INNER_LIBRARIES event_core
|
INNER_LIBRARIES event_core
|
||||||
OUTER_INCLUDES ${MBEDTLS_INCLUDE_DIR}
|
LIBRARIES ${MBEDTLS_TARGETS}
|
||||||
LIBRARIES ${MBEDTLS_LIBRARIES}
|
|
||||||
SOURCES ${SRC_MBEDTLS})
|
SOURCES ${SRC_MBEDTLS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -1106,6 +1099,7 @@ if (EVENT__HAVE_PTHREADS)
|
|||||||
set(SRC_PTHREADS evthread_pthread.c)
|
set(SRC_PTHREADS evthread_pthread.c)
|
||||||
add_event_library(event_pthreads
|
add_event_library(event_pthreads
|
||||||
INNER_LIBRARIES event_core
|
INNER_LIBRARIES event_core
|
||||||
|
LIBRARIES Threads::Threads
|
||||||
SOURCES ${SRC_PTHREADS})
|
SOURCES ${SRC_PTHREADS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(LIBEVENT_SHARED_LIBRARIES "")
|
set(LIBEVENT_SHARED_LIBRARIES "")
|
||||||
set(LIBEVENT_STATIC_LIBRARIES "")
|
set(LIBEVENT_STATIC_LIBRARIES "")
|
||||||
@ -11,10 +12,10 @@ macro(set_event_shared_lib_flags LIB_NAME)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(generate_pkgconfig LIB_NAME)
|
macro(generate_pkgconfig LIB_NAME)
|
||||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
set(exec_prefix "\${prefix}")
|
||||||
set(libdir ${CMAKE_INSTALL_LIBDIR})
|
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
set(includedir ${CMAKE_INSTALL_INCLUDEDIR})
|
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
|
||||||
set(VERSION ${EVENT_ABI_LIBVERSION})
|
set(VERSION ${EVENT_ABI_LIBVERSION})
|
||||||
|
|
||||||
@ -23,11 +24,6 @@ macro(generate_pkgconfig LIB_NAME)
|
|||||||
set(LIBS "${LIBS} -l${LIB}")
|
set(LIBS "${LIBS} -l${LIB}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(OPENSSL_LIBS "")
|
|
||||||
foreach(LIB ${OPENSSL_LIBRARIES})
|
|
||||||
set(OPENSSL_LIBS "${OPENSSL_LIBS} -l${LIB}")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
|
configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
|
||||||
install(
|
install(
|
||||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc"
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc"
|
||||||
@ -37,7 +33,7 @@ endmacro()
|
|||||||
|
|
||||||
# LIB_NAME maybe event_core, event_extra, event_openssl, event_pthreads or event.
|
# LIB_NAME maybe event_core, event_extra, event_openssl, event_pthreads or event.
|
||||||
# Targets whose LIB_NAME is not 'event' should be exported and installed.
|
# Targets whose LIB_NAME is not 'event' should be exported and installed.
|
||||||
macro(export_install_target TYPE LIB_NAME OUTER_INCLUDES)
|
macro(export_install_target TYPE LIB_NAME)
|
||||||
if("${LIB_NAME}" STREQUAL "event")
|
if("${LIB_NAME}" STREQUAL "event")
|
||||||
install(TARGETS "${LIB_NAME}_${TYPE}"
|
install(TARGETS "${LIB_NAME}_${TYPE}"
|
||||||
LIBRARY DESTINATION "lib" COMPONENT lib
|
LIBRARY DESTINATION "lib" COMPONENT lib
|
||||||
@ -57,7 +53,6 @@ macro(export_install_target TYPE LIB_NAME OUTER_INCLUDES)
|
|||||||
PUBLIC "$<INSTALL_INTERFACE:include>"
|
PUBLIC "$<INSTALL_INTERFACE:include>"
|
||||||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
||||||
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
|
||||||
${OUTER_INCS}
|
|
||||||
)
|
)
|
||||||
set_target_properties("${LIB_NAME}_${TYPE}" PROPERTIES EXPORT_NAME ${PURE_NAME})
|
set_target_properties("${LIB_NAME}_${TYPE}" PROPERTIES EXPORT_NAME ${PURE_NAME})
|
||||||
export(TARGETS "${LIB_NAME}_${TYPE}"
|
export(TARGETS "${LIB_NAME}_${TYPE}"
|
||||||
@ -81,8 +76,7 @@ endmacro()
|
|||||||
# - EVENT_ABI_LIBVERSION_REVISION
|
# - EVENT_ABI_LIBVERSION_REVISION
|
||||||
# - EVENT_ABI_LIBVERSION_AGE
|
# - EVENT_ABI_LIBVERSION_AGE
|
||||||
# - EVENT_PACKAGE_RELEASE
|
# - EVENT_PACKAGE_RELEASE
|
||||||
# - CMAKE_THREAD_LIBS_INIT LIB_PLATFORM
|
# - LIB_PLATFORM
|
||||||
# - OPENSSL_LIBRARIES
|
|
||||||
# - EVENT_SHARED_FLAGS
|
# - EVENT_SHARED_FLAGS
|
||||||
# - EVENT_LIBRARY_STATIC
|
# - EVENT_LIBRARY_STATIC
|
||||||
# - EVENT_LIBRARY_SHARED
|
# - EVENT_LIBRARY_SHARED
|
||||||
@ -94,13 +88,10 @@ macro(add_event_library LIB_NAME)
|
|||||||
cmake_parse_arguments(LIB
|
cmake_parse_arguments(LIB
|
||||||
"" # Options
|
"" # Options
|
||||||
"VERSION" # One val
|
"VERSION" # One val
|
||||||
"SOURCES;LIBRARIES;INNER_LIBRARIES;OUTER_INCLUDES" # Multi val
|
"SOURCES;LIBRARIES;INNER_LIBRARIES" # Multi val
|
||||||
${ARGN}
|
${ARGN}
|
||||||
)
|
)
|
||||||
|
|
||||||
if ("${LIB_OUTER_INCLUDES}" STREQUAL "")
|
|
||||||
set(LIB_OUTER_INCLUDES NONE)
|
|
||||||
endif()
|
|
||||||
set(ADD_EVENT_LIBRARY_INTERFACE)
|
set(ADD_EVENT_LIBRARY_INTERFACE)
|
||||||
set(INNER_LIBRARIES)
|
set(INNER_LIBRARIES)
|
||||||
|
|
||||||
@ -114,12 +105,11 @@ macro(add_event_library LIB_NAME)
|
|||||||
set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_static")
|
set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_static")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries("${LIB_NAME}_static"
|
target_link_libraries("${LIB_NAME}_static"
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${LIB_PLATFORM}
|
${LIB_PLATFORM}
|
||||||
${INNER_LIBRARIES}
|
${INNER_LIBRARIES}
|
||||||
${LIB_LIBRARIES})
|
${LIB_LIBRARIES})
|
||||||
|
|
||||||
export_install_target(static "${LIB_NAME}" "${LIB_OUTER_INCLUDES}")
|
export_install_target(static "${LIB_NAME}")
|
||||||
|
|
||||||
set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_static")
|
set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_static")
|
||||||
endif()
|
endif()
|
||||||
@ -131,7 +121,6 @@ macro(add_event_library LIB_NAME)
|
|||||||
set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_shared")
|
set(INNER_LIBRARIES "${LIB_INNER_LIBRARIES}_shared")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries("${LIB_NAME}_shared"
|
target_link_libraries("${LIB_NAME}_shared"
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
|
||||||
${LIB_PLATFORM}
|
${LIB_PLATFORM}
|
||||||
${INNER_LIBRARIES}
|
${INNER_LIBRARIES}
|
||||||
${LIB_LIBRARIES})
|
${LIB_LIBRARIES})
|
||||||
@ -174,7 +163,7 @@ macro(add_event_library LIB_NAME)
|
|||||||
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
export_install_target(shared "${LIB_NAME}" "${LIB_OUTER_INCLUDES}")
|
export_install_target(shared "${LIB_NAME}")
|
||||||
|
|
||||||
set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_shared")
|
set(ADD_EVENT_LIBRARY_INTERFACE "${LIB_NAME}_shared")
|
||||||
|
|
||||||
|
@ -151,24 +151,26 @@ find_package_handle_standard_args(MbedTLS
|
|||||||
VERSION_VAR MBEDTLS_VERSION)
|
VERSION_VAR MBEDTLS_VERSION)
|
||||||
|
|
||||||
|
|
||||||
if(NOT TARGET mbedtls)
|
if(NOT TARGET MbedTLS::mbedtls)
|
||||||
add_library(mbedtls UNKNOWN IMPORTED)
|
add_library(MbedTLS::mbedtls UNKNOWN IMPORTED)
|
||||||
set_target_properties(mbedtls PROPERTIES
|
set_target_properties(MbedTLS::mbedtls PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
|
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
INTERFACE_LINK_LIBRARIES MbedTLS::mbedx509
|
||||||
IMPORTED_LOCATION "${MBEDTLS_LIBRARY}")
|
IMPORTED_LOCATION "${MBEDTLS_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT TARGET mbedcrypto)
|
if(NOT TARGET MbedTLS::mbedcrypto)
|
||||||
add_library(mbedcrypto UNKNOWN IMPORTED)
|
add_library(MbedTLS::mbedcrypto UNKNOWN IMPORTED)
|
||||||
set_target_properties(mbedcrypto PROPERTIES
|
set_target_properties(MbedTLS::mbedcrypto PROPERTIES
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${MBEDTLS_CRYPTO_LIBRARY}")
|
IMPORTED_LOCATION "${MBEDTLS_CRYPTO_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT TARGET mbedx509)
|
if(NOT TARGET MbedTLS::mbedx509)
|
||||||
add_library(mbedx509 UNKNOWN IMPORTED)
|
add_library(MbedTLS::mbedx509 UNKNOWN IMPORTED)
|
||||||
set_target_properties(mbedx509 PROPERTIES
|
set_target_properties(MbedTLS::mbedx509 PROPERTIES
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
INTERFACE_LINK_LIBRARIES MbedTLS::mbedcrypto
|
||||||
IMPORTED_LOCATION "${MBEDTLS_X509_LIBRARY}")
|
IMPORTED_LOCATION "${MBEDTLS_X509_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
# The following table lists all available components. If none is given, all imported targets will used.
|
# The following table lists all available components. If none is given, all imported targets will used.
|
||||||
# core - the core functons of libevent
|
# core - the core functons of libevent
|
||||||
# extra - extra functions, contains http, dns and rpc
|
# extra - extra functions, contains http, dns and rpc
|
||||||
# pthreads - multiple threads for libevent, not exists on Windows
|
# pthreads - multiple threads for libevent, does not exist on Windows
|
||||||
# openssl - openssl support for libevent
|
# openssl - OpenSSL support for libevent
|
||||||
|
# mbedtls - MbedTLS support for libevent
|
||||||
#
|
#
|
||||||
# By default, the shared libraries of libevent will be found. To find the static ones instead,
|
# By default, the shared libraries of libevent will be found. To find the static ones instead,
|
||||||
# you must set the LIBEVENT_STATIC_LINK variable to TRUE before calling find_package(Libevent ...).
|
# you must set the LIBEVENT_STATIC_LINK variable to TRUE before calling find_package(Libevent ...).
|
||||||
@ -34,6 +35,14 @@
|
|||||||
|
|
||||||
set(LIBEVENT_VERSION @EVENT_PACKAGE_VERSION@)
|
set(LIBEVENT_VERSION @EVENT_PACKAGE_VERSION@)
|
||||||
|
|
||||||
|
# Load the dependencies of all components. As find_dependency propagates the original
|
||||||
|
# find_package attributes (i.e. required or not), there's no need to repeat this or filter
|
||||||
|
# by component.
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(Threads)
|
||||||
|
find_dependency(MbedTLS)
|
||||||
|
find_dependency(OpenSSL)
|
||||||
|
|
||||||
# IMPORTED targets from LibeventTargets.cmake
|
# IMPORTED targets from LibeventTargets.cmake
|
||||||
set(LIBEVENT_STATIC_LIBRARIES "@LIBEVENT_STATIC_LIBRARIES@")
|
set(LIBEVENT_STATIC_LIBRARIES "@LIBEVENT_STATIC_LIBRARIES@")
|
||||||
set(LIBEVENT_SHARED_LIBRARIES "@LIBEVENT_SHARED_LIBRARIES@")
|
set(LIBEVENT_SHARED_LIBRARIES "@LIBEVENT_SHARED_LIBRARIES@")
|
||||||
@ -46,6 +55,12 @@ endif()
|
|||||||
if(${LIBEVENT_STATIC_LINK})
|
if(${LIBEVENT_STATIC_LINK})
|
||||||
set(_LIB_TYPE static)
|
set(_LIB_TYPE static)
|
||||||
set(_AVAILABLE_LIBS "${LIBEVENT_STATIC_LIBRARIES}")
|
set(_AVAILABLE_LIBS "${LIBEVENT_STATIC_LIBRARIES}")
|
||||||
|
|
||||||
|
# CMake before 3.15 doesn't link OpenSSL to pthread/dl, do it ourselves instead
|
||||||
|
if (${CMAKE_VERSION} VERSION_LESS "3.15.0" AND ${LIBEVENT_STATIC_LINK} AND ${OPENSSL_FOUND} AND ${Threads_FOUND})
|
||||||
|
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||||
|
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
|
endif ()
|
||||||
else()
|
else()
|
||||||
set(_LIB_TYPE shared)
|
set(_LIB_TYPE shared)
|
||||||
set(_AVAILABLE_LIBS "${LIBEVENT_SHARED_LIBRARIES}")
|
set(_AVAILABLE_LIBS "${LIBEVENT_SHARED_LIBRARIES}")
|
||||||
@ -64,7 +79,7 @@ macro(no_component_msg _comp)
|
|||||||
set(pthreadlib ", pthreads")
|
set(pthreadlib ", pthreads")
|
||||||
endif()
|
endif()
|
||||||
message(FATAL_ERROR "Your libevent library does not contain a ${_comp} component!\n"
|
message(FATAL_ERROR "Your libevent library does not contain a ${_comp} component!\n"
|
||||||
"The valid components are core, extra${pthreadlib} and openssl.")
|
"The valid components are core, extra${pthreadlib}, openssl and mbedtls.")
|
||||||
else()
|
else()
|
||||||
message_if_needed(WARNING "Your libevent library does not contain a ${_comp} component!")
|
message_if_needed(WARNING "Your libevent library does not contain a ${_comp} component!")
|
||||||
endif()
|
endif()
|
||||||
|
@ -8,9 +8,6 @@ includedir=@includedir@
|
|||||||
Name: libevent_core
|
Name: libevent_core
|
||||||
Description: libevent_core
|
Description: libevent_core
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires:
|
Libs: -L${libdir} -levent_core@CMAKE_DEBUG_POSTFIX@
|
||||||
Conflicts:
|
|
||||||
Libs: -L${libdir} -levent_core
|
|
||||||
Libs.private: @LIBS@
|
Libs.private: @LIBS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
@ -8,9 +8,7 @@ includedir=@includedir@
|
|||||||
Name: libevent_extra
|
Name: libevent_extra
|
||||||
Description: libevent_extra
|
Description: libevent_extra
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires:
|
Requires: libevent_core
|
||||||
Conflicts:
|
Libs: -L${libdir} -levent_extra@CMAKE_DEBUG_POSTFIX@
|
||||||
Libs: -L${libdir} -levent_extra
|
|
||||||
Libs.private: @LIBS@
|
Libs.private: @LIBS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ Name: libevent_mbedtls
|
|||||||
Description: libevent_mbedtls adds mbedtls-based TLS support to libevent
|
Description: libevent_mbedtls adds mbedtls-based TLS support to libevent
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires: libevent_core
|
Requires: libevent_core
|
||||||
Conflicts:
|
Libs: -L${libdir} -levent_mbedtls@CMAKE_DEBUG_POSTFIX@
|
||||||
Libs: -L${libdir} -levent_mbedtls
|
Libs.private: -lmbedtls -lmbedx509 @LIBS@
|
||||||
Libs.private: @LIBS@ @MBEDTLS_LIBS@
|
Cflags: -I${includedir}
|
||||||
Cflags: -I${includedir} @MBEDTLS_INCS@
|
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ Name: libevent_openssl
|
|||||||
Description: libevent_openssl adds openssl-based TLS support to libevent
|
Description: libevent_openssl adds openssl-based TLS support to libevent
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires: libevent_core
|
Requires: libevent_core
|
||||||
Conflicts:
|
Requires.private: libssl
|
||||||
Libs: -L${libdir} -levent_openssl
|
Libs: -L${libdir} -levent_openssl@CMAKE_DEBUG_POSTFIX@
|
||||||
Libs.private: @LIBS@ @OPENSSL_LIBS@
|
Libs.private: @LIBS@
|
||||||
Cflags: -I${includedir} @OPENSSL_INCS@
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ Name: libevent_pthreads
|
|||||||
Description: libevent_pthreads adds pthreads-based threading support to libevent
|
Description: libevent_pthreads adds pthreads-based threading support to libevent
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires: libevent_core
|
Requires: libevent_core
|
||||||
Conflicts:
|
Libs: -L${libdir} -levent_pthreads@CMAKE_DEBUG_POSTFIX@
|
||||||
Libs: -L${libdir} -levent_pthreads
|
Libs.private: @CMAKE_THREAD_LIBS_INIT@ @LIBS@
|
||||||
Libs.private: @LIBS@ @PTHREAD_LIBS@
|
Cflags: -I${includedir}
|
||||||
Cflags: -I${includedir} @PTHREAD_CFLAGS@
|
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.1.2)
|
cmake_minimum_required(VERSION 3.4)
|
||||||
if (POLICY CMP0074)
|
if (POLICY CMP0074)
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
|
||||||
project(verify)
|
project(verify)
|
||||||
# set(CMAKE_VERBOSE_MAKEFILE 1)
|
# set(CMAKE_VERBOSE_MAKEFILE 1)
|
||||||
if(NOT ${EVENT__CODE_COMPONENT} STREQUAL "")
|
if(NOT ${EVENT__CODE_COMPONENT} STREQUAL "")
|
||||||
|
@ -46,10 +46,24 @@ def link_and_run(link, code):
|
|||||||
"""
|
"""
|
||||||
exec_cmd("cmake --build . -v --target clean", True)
|
exec_cmd("cmake --build . -v --target clean", True)
|
||||||
arch = ''
|
arch = ''
|
||||||
|
vcpkg = ''
|
||||||
|
openssldir = ''
|
||||||
|
mbedtlsdir = ''
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
arch = '-A x64'
|
arch = '-A x64'
|
||||||
cmd = 'cmake .. %s -DEVENT__LINK_COMPONENT=%s -DEVENT__CODE_COMPONENT=%s' % (
|
vcpkg_root = os.environ.get('VCPKG_ROOT')
|
||||||
arch, link, code)
|
if vcpkg_root is not None:
|
||||||
|
vcpkg = f"-DCMAKE_TOOLCHAIN_FILE={vcpkg_root}/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
elif platform.system() == "Darwin":
|
||||||
|
openssldir = '-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl'
|
||||||
|
mbedtlsdir = '-DMBEDTLS_ROOT_DIR=/usr/local/opt/mbedtls@2'
|
||||||
|
cmd = f"cmake .." \
|
||||||
|
f" {arch}" \
|
||||||
|
f" {vcpkg}" \
|
||||||
|
f" -DEVENT__LINK_COMPONENT={link}" \
|
||||||
|
f" -DEVENT__CODE_COMPONENT={code}" \
|
||||||
|
f" {openssldir}" \
|
||||||
|
f" {mbedtlsdir}"
|
||||||
if link_type == "static":
|
if link_type == "static":
|
||||||
cmd = "".join([cmd, " -DLIBEVENT_STATIC_LINK=1"])
|
cmd = "".join([cmd, " -DLIBEVENT_STATIC_LINK=1"])
|
||||||
r = exec_cmd(cmd, True)
|
r = exec_cmd(cmd, True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user