Control: tags -1 + patch Hi!
Finally got to this one, On 24.06.2015 06:43, Steve M. Robbins wrote: >> Current libgtest-dev has two different means to determine if >> GTEST_HAS_PTHREAD is defined: one in CMake rules [1] and second one in >> the header [2]. When they don't match [3], > > I have never used the CMake files, but in /usr/src/gtest/CMakeLists.txt, I > see: > > config_compiler_and_linker() # Defined in internal_utils.cmake. > > and as far as I can see, that macro unconditionally defines GTEST_HAS_PTHREAD > in cxx_base_flags. As long as the build uses these flags, it will override > the > logic in the header. > > So I don't see the issue. Can you elaborate further? Sure. Those flags are used for compiling libgtest, yes, but not for anything else that links to libgtest. For each target, CMake maintains two sets of compile definitions: one it uses for compiling the target itself, and another one which is passed (transitively unless specified otherwise) to targets which link themselves to this one. And the second one is missing. >> If you prefer, I can try to produce a patch. > > Yes, patch is always nice. Ack, a patch and a test case attached. -- Eugene V. Lyubimkin aka JackYF, JID: jackyf(maildog)jabber.fsfe.org C++ GNU/Linux userspace developer, Debian Developer
--- gt-cmakelists 2015-07-18 16:17:22.150909549 +0300 +++ /usr/src/gtest/CMakeLists.txt 2015-07-18 16:53:53.725776982 +0300 @@ -68,6 +68,7 @@ # are used for other targets, to ensure that gtest can be compiled by a user # aggressive about warnings. cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) +target_compile_options(gtest INTERFACE ${cxx_public}) cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc) target_link_libraries(gtest_main gtest) --- gt-internal-utils 2015-07-18 16:30:19.190762682 +0300 +++ /usr/src/gtest/cmake/internal_utils.cmake 2015-07-18 16:58:22.703110769 +0300 @@ -42,6 +42,11 @@ endif() endmacro() +macro(set_public_compiler_definitions) + string(REGEX MATCHALL "-DGTEST_HAS_[^ ]*( |$)" list_of_definitions "${cxx_default}") + string(REPLACE " " "" cxx_public "${list_of_definitions}") +endmacro() + # Defines the compiler/linker flags used to build Google Test and # Google Mock. You can tweak these definitions to suit your need. A # variable's value is empty before it's explicitly assigned to. @@ -120,6 +125,7 @@ # For building the gtest libraries. set(cxx_strict "${cxx_default} ${cxx_strict_flags}") + set_public_compiler_definitions() endmacro() # Defines the gtest & gtest_main libraries. User tests should link
testcase.tar.gz
Description: application/gzip