Skip to content

Commit

Permalink
deps/googletest: fix adding 'd' suffix in MSVC debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMatula committed Sep 8, 2020
1 parent 0dfbff9 commit 126483c
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions deps/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,32 @@ endif()

set(GOOGLETEST_INSTALL_DIR ${CMAKE_BINARY_DIR}/deps/install/googletest)

#gtest${MSVC_DEBUG_LIB_SUFFIX}
set(GTEST_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX})
if (MSVC)
# Generator expressions screw up Ninja build, use them only for MSVC.
# Googletest adds "d" suffix for MSVC debug build.
# It does not seem this can be controlled from the outside.
set(MSVC_DEBUG_LIB_SUFFIX $<$<AND:${MSVC_GE},$<CONFIG:Debug>>:d>)
else()
set(MSVC_DEBUG_LIB_SUFFIX "")
endif()
set(GTEST_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})

# Generator expressions (possibly in MSVC_DEBUG_LIB_SUFFIX)
# cannot be in BUILD_BYPRODUCTS, do not set byproducts in MSVC
# (it is good only for Ninja build).
if (MSVC)
set(GTEST_BYPRODUCTS "")
else()
set(GTEST_BYPRODUCTS
${GTEST_LIB}
${GTEST_MAIN_LIB}
${GMOCK_LIB}
${GMOCK_MAIN_LIB}
)
endif()

if(GOOGLETEST_LOCAL_DIR)
message(STATUS "Googletest: using local Googletest directory.")
Expand Down Expand Up @@ -48,10 +69,7 @@ ExternalProject_Add(googletest
LOG_CONFIGURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS
${GTEST_LIB}
${GTEST_MAIN_LIB}
${GMOCK_LIB}
${GMOCK_MAIN_LIB}
${GTEST_BYPRODUCTS}
)
if(GOOGLETEST_LOCAL_DIR)
force_configure_step(googletest)
Expand All @@ -69,8 +87,6 @@ set(GMOCK_INCLUDE_DIR ${GOOGLETEST_INSTALL_DIR}/include)

# Create targets.

set(MSVC_DEBUG_LIB_SUFFIX $<$<AND:${MSVC_GE},$<CONFIG:Debug>>:d>)

# gtest
add_library(gtest INTERFACE)
add_library(retdec::deps::gtest ALIAS gtest)
Expand Down

0 comments on commit 126483c

Please sign in to comment.