From 8a1cf0d8d311c31e0f845bf2b10e27d3a30a1767 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 8 Nov 2021 17:12:00 +0530 Subject: [PATCH 1/2] build: Fix libdir in pkgconfig files for Windows Windows import libraries are installed inside ARCHIVE_DIRECTORY, not LIBRARY_DIRECTORY. So we need to use that for libdir on Windows. Related to https://github.com/amzn/amazon-s3-gst-plugin/issues/13 --- CMakeLists.txt | 9 +++++++++ toolchains/pkg-config.pc.in | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc77905232..e4db7df4d73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,15 @@ else() set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}") endif() +# We need to point this to the directory containing import libraries or static +# libraries on Windows, and to the directory containing the so / dylib +# libraries on other platforms. +if(WIN32) + set(PKG_CONFIG_LIB_DIRECTORY "${ARCHIVE_DIRECTORY}") +else() + set(PKG_CONFIG_LIB_DIRECTORY "${LIBRARY_DIRECTORY}") +endif() + if (ENABLE_ADDRESS_SANITIZER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer") if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.1) diff --git a/toolchains/pkg-config.pc.in b/toolchains/pkg-config.pc.in index 9b519d2772b..4e91c93c293 100644 --- a/toolchains/pkg-config.pc.in +++ b/toolchains/pkg-config.pc.in @@ -1,5 +1,5 @@ includedir=@CMAKE_INSTALL_PREFIX@/@INCLUDE_DIRECTORY@ -libdir=@CMAKE_INSTALL_PREFIX@/@LIBRARY_DIRECTORY@ +libdir=@CMAKE_INSTALL_PREFIX@/@PKG_CONFIG_LIB_DIRECTORY@ Name: @PROJECT_NAME@ Description: @PROJECT_DESCRIPTION@ From e90144526d99efad6e724afa43b869a0b081fc6a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 8 Nov 2021 17:33:57 +0530 Subject: [PATCH 2/2] build: Set -DUSE_IMPORT_EXPORT in pkgconfig files on Windows MSVC consumers of the shared library need to define this macro when linking to aws-cpp-sdk-* libs, or they will get undefined reference errors. Also doesn't hurt to define this with MinGW, so add it unconditionally on Windows. Related to https://github.com/amzn/amazon-s3-gst-plugin/issues/13 --- CMakeLists.txt | 7 +++++++ toolchains/pkg-config.pc.in | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4db7df4d73..e90457b38f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,13 @@ else() set(PKG_CONFIG_LIB_DIRECTORY "${LIBRARY_DIRECTORY}") endif() +# MSVC consumers of the shared library need to define this macro when linking +# to aws-cpp-sdk-* libs, or they will get undefined reference errors. Also +# doesn't hurt to define this with MinGW, so add it unconditionally on Windows. +if(WIN32 AND BUILD_SHARED_LIBS) + set(PKG_CONFIG_EXPORT_CFLAGS "-DUSE_IMPORT_EXPORT") +endif() + if (ENABLE_ADDRESS_SANITIZER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer") if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.1) diff --git a/toolchains/pkg-config.pc.in b/toolchains/pkg-config.pc.in index 4e91c93c293..40bc6a6cb7b 100644 --- a/toolchains/pkg-config.pc.in +++ b/toolchains/pkg-config.pc.in @@ -4,7 +4,7 @@ libdir=@CMAKE_INSTALL_PREFIX@/@PKG_CONFIG_LIB_DIRECTORY@ Name: @PROJECT_NAME@ Description: @PROJECT_DESCRIPTION@ Version: @PROJECT_VERSION@ -Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@ +Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@ @PKG_CONFIG_EXPORT_CFLAGS@ Libs: -L${libdir} -l@PROJECT_NAME@ Libs.private: @ALL_DEP_LIBS_LINK_FLAGS@ Requires: @PROJECT_LIBS_STRING@