diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc77905232..e90457b38f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,6 +257,22 @@ 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() + +# 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 9b519d2772b..40bc6a6cb7b 100644 --- a/toolchains/pkg-config.pc.in +++ b/toolchains/pkg-config.pc.in @@ -1,10 +1,10 @@ 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@ 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@