Skip to content

Commit a69b0ae

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Separate DLL export/import for test helpers dll, and fix typo.
The DLL export issue isn't a problem currently, since we don't explicitly export any symbols from the test dll. This will be an issue in the future though. Additionally, there was a typo in absl_internal_test_dll_contains that caused abseil_test_dll to be empty (and therefore not create a lib file). PiperOrigin-RevId: 504555797 Change-Id: Ic7b50bcbe704f7c8fd44028071abcf5d6babb2cf
1 parent f1d1657 commit a69b0ae

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

CMake/AbseilDll.cmake

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ function(absl_internal_test_dll_contains)
654654
STRING(REGEX REPLACE "^absl::" "" _target ${ABSL_INTERNAL_TEST_DLL_TARGET})
655655

656656
list(FIND
657-
ABSL_INTERNA_TEST_DLL_TARGETS
657+
ABSL_INTERNAL_TEST_DLL_TARGETS
658658
"${_target}"
659659
_index)
660660

@@ -703,14 +703,18 @@ function(absl_make_dll)
703703
set(_dll "abseil_test_dll")
704704
set(_dll_files ${ABSL_INTERNAL_TEST_DLL_FILES})
705705
set(_dll_libs "abseil_dll" "GTest::gtest" "GTest::gmock")
706-
set(_dll_compile_definiations "GTEST_LINKED_AS_SHARED_LIBRARY=1")
707-
set(_dll_includes ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
706+
set(_dll_compile_definitions "GTEST_LINKED_AS_SHARED_LIBRARY=1")
707+
set(_dll_includes ${absl_gtest_src_dir}/googletest/include ${absl_gtest_src_dir}/googlemock/include)
708+
set(_dll_consume "ABSL_CONSUME_TEST_DLL")
709+
set(_dll_build "ABSL_BUILD_TEST_DLL")
708710
else()
709711
set(_dll "abseil_dll")
710712
set(_dll_files ${ABSL_INTERNAL_DLL_FILES})
711713
set(_dll_libs "")
712-
set(_dll_compile_definiations "")
714+
set(_dll_compile_definitions "")
713715
set(_dll_includes "")
716+
set(_dll_consume "ABSL_CONSUME_DLL")
717+
set(_dll_build "ABSL_BUILD_DLL")
714718
endif()
715719

716720
add_library(
@@ -762,21 +766,21 @@ Name: ${_dll}\n\
762766
Description: Abseil DLL library\n\
763767
URL: https://abseil.io/\n\
764768
Version: ${absl_VERSION}\n\
765-
Libs: -L\${libdir} ${PC_LINKOPTS} $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labseil_dll>\n\
769+
Libs: -L\${libdir} ${PC_LINKOPTS} $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-l${_dll}>\n\
766770
Cflags: -I\${includedir}${PC_CFLAGS}\n")
767771
INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/${_dll}.pc"
768772
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
769773

770774
target_compile_definitions(
771775
${_dll}
772776
PUBLIC
773-
GTEST_LINKED_AS_SHARED_LIBRARY=1
777+
${_dll_compile_definitions}
774778
PRIVATE
775-
ABSL_BUILD_DLL
779+
${_dll_build}
776780
NOMINMAX
777781
INTERFACE
778782
${ABSL_CC_LIB_DEFINES}
779-
ABSL_CONSUME_DLL
783+
${_dll_consume}
780784
)
781785

782786
if(ABSL_PROPAGATE_CXX_STD)

CMake/AbseilHelpers.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,15 @@ function(absl_cc_test)
414414
target_sources(${_NAME} PRIVATE ${ABSL_CC_TEST_SRCS})
415415
target_include_directories(${_NAME}
416416
PUBLIC ${ABSL_COMMON_INCLUDE_DIRS}
417-
PRIVATE ${GMOCK_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS}
417+
PRIVATE ${absl_gtest_src_dir}/googletest/include ${absl_gtest_src_dir}/googlemock/include
418418
)
419419

420420
if (${ABSL_BUILD_DLL})
421421
target_compile_definitions(${_NAME}
422422
PUBLIC
423423
${ABSL_CC_TEST_DEFINES}
424424
ABSL_CONSUME_DLL
425+
ABSL_CONSUME_TEST_DLL
425426
GTEST_LINKED_AS_SHARED_LIBRARY=1
426427
)
427428

absl/base/config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,18 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
759759
#define ABSL_DLL
760760
#endif // defined(_MSC_VER)
761761

762+
#if defined(_MSC_VER)
763+
#if defined(ABSL_BUILD_TEST_DLL)
764+
#define ABSL_TEST_DLL __declspec(dllexport)
765+
#elif defined(ABSL_CONSUME_TEST_DLL)
766+
#define ABSL_TEST_DLL __declspec(dllimport)
767+
#else
768+
#define ABSL_TEST_DLL
769+
#endif
770+
#else
771+
#define ABSL_TEST_DLL
772+
#endif // defined(_MSC_VER)
773+
762774
// ABSL_HAVE_MEMORY_SANITIZER
763775
//
764776
// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of

0 commit comments

Comments
 (0)