summaryrefslogtreecommitdiff
path: root/test-export
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo.bauersachs@xovis.com>2022-12-01 18:39:52 +0100
committerAzat Khuzhin <azat@libevent.org>2023-05-16 07:46:56 +0200
commitacfac7ae4a3edbbb7ce4ceee7208b4245a6e203e (patch)
treed5cff6a42f735e390e30a8ededa681b12a35ff09 /test-export
parent81c6b8823c1b58d7837e827bb1098aa5f9e5956b (diff)
downloadlibevent-acfac7ae4a3edbbb7ce4ceee7208b4245a6e203e.tar.gz
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
Diffstat (limited to 'test-export')
-rw-r--r--test-export/CMakeLists.txt3
-rw-r--r--test-export/test-export.py18
2 files changed, 18 insertions, 3 deletions
diff --git a/test-export/CMakeLists.txt b/test-export/CMakeLists.txt
index 89c1806c..84e15181 100644
--- a/test-export/CMakeLists.txt
+++ b/test-export/CMakeLists.txt
@@ -1,7 +1,8 @@
-cmake_minimum_required(VERSION 3.1.2)
+cmake_minimum_required(VERSION 3.4)
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
project(verify)
# set(CMAKE_VERBOSE_MAKEFILE 1)
if(NOT ${EVENT__CODE_COMPONENT} STREQUAL "")
diff --git a/test-export/test-export.py b/test-export/test-export.py
index 84824350..efeac0cc 100644
--- a/test-export/test-export.py
+++ b/test-export/test-export.py
@@ -46,10 +46,24 @@ def link_and_run(link, code):
"""
exec_cmd("cmake --build . -v --target clean", True)
arch = ''
+ vcpkg = ''
+ openssldir = ''
+ mbedtlsdir = ''
if platform.system() == "Windows":
arch = '-A x64'
- cmd = 'cmake .. %s -DEVENT__LINK_COMPONENT=%s -DEVENT__CODE_COMPONENT=%s' % (
- arch, link, code)
+ vcpkg_root = os.environ.get('VCPKG_ROOT')
+ 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":
cmd = "".join([cmd, " -DLIBEVENT_STATIC_LINK=1"])
r = exec_cmd(cmd, True)