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@