Skip to content

Commit e901445

Browse files
committed
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 amzn/amazon-s3-gst-plugin#13
1 parent 8a1cf0d commit e901445

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ else()
266266
set(PKG_CONFIG_LIB_DIRECTORY "${LIBRARY_DIRECTORY}")
267267
endif()
268268

269+
# MSVC consumers of the shared library need to define this macro when linking
270+
# to aws-cpp-sdk-* libs, or they will get undefined reference errors. Also
271+
# doesn't hurt to define this with MinGW, so add it unconditionally on Windows.
272+
if(WIN32 AND BUILD_SHARED_LIBS)
273+
set(PKG_CONFIG_EXPORT_CFLAGS "-DUSE_IMPORT_EXPORT")
274+
endif()
275+
269276
if (ENABLE_ADDRESS_SANITIZER)
270277
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer")
271278
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.1)

toolchains/pkg-config.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ libdir=@CMAKE_INSTALL_PREFIX@/@PKG_CONFIG_LIB_DIRECTORY@
44
Name: @PROJECT_NAME@
55
Description: @PROJECT_DESCRIPTION@
66
Version: @PROJECT_VERSION@
7-
Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@
7+
Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@ @PKG_CONFIG_EXPORT_CFLAGS@
88
Libs: -L${libdir} -l@PROJECT_NAME@
99
Libs.private: @ALL_DEP_LIBS_LINK_FLAGS@
1010
Requires: @PROJECT_LIBS_STRING@

0 commit comments

Comments
 (0)