mirror of
https://github.com/google/googletest.git
synced 2024-12-28 11:10:44 +08:00
Makes the cmake script work on Solaris and AIX (by Hady Zalek).
This commit is contained in:
parent
17e4860871
commit
92344b762a
@ -59,24 +59,46 @@ link_directories(
|
||||
find_package(Threads)
|
||||
|
||||
# Defines the compiler/linker flags used to build gtest. You can
|
||||
# tweak these definitions to suit your need.
|
||||
# tweak these definitions to suit your need. A variable's value is
|
||||
# empty before it's explicitly assigned to.
|
||||
|
||||
if (MSVC)
|
||||
# Newlines inside flags variables break CMake's NMake generator.
|
||||
set(cxx_base "${CMAKE_CXX_FLAGS} -GS -W4 -WX -wd4275 -nologo -J -Zi")
|
||||
set(cxx_base "${cxx_base} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
|
||||
set(cxx_base "${cxx_base} -DSTRICT -DWIN32_LEAN_AND_MEAN")
|
||||
set(cxx_default "${cxx_base} -EHsc -D_HAS_EXCEPTIONS=1")
|
||||
set(cxx_strict "${cxx_default}")
|
||||
else()
|
||||
set(cxx_base "${CMAKE_CXX_FLAGS} -Wall -Werror -Wshadow")
|
||||
|
||||
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available.
|
||||
set(cxx_base "${cxx_base} -DGTEST_HAS_PTHREAD=1")
|
||||
endif()
|
||||
set(cxx_base_flags "-GS -W4 -WX -wd4275 -nologo -J -Zi")
|
||||
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
|
||||
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
|
||||
set(cxx_exceptions_flags "-EHsc -D_HAS_EXCEPTIONS=1")
|
||||
set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti_flags "-GR-")
|
||||
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(cxx_base_flags "-Wall -Wshadow")
|
||||
set(cxx_exceptions_flags "-fexceptions")
|
||||
set(cxx_no_exception_flags "-fno-exceptions")
|
||||
set(cxx_no_rtti_flags "-fno-rtti")
|
||||
set(cxx_strict_flags "${cxx_strict_flags} -Wextra")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
|
||||
set(cxx_exceptions_flags "-features=except")
|
||||
set(cxx_no_exception_flags "-features=no%except -DGTEST_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti_flags "-features=no%rtti")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "VisualAge")
|
||||
set(cxx_exceptions_flags "-qeh")
|
||||
set(cxx_no_exception_flags "-qnoeh")
|
||||
set(cxx_no_rtti_flags "-qnortti")
|
||||
endif()
|
||||
|
||||
set(cxx_default "${cxx_base} -fexceptions")
|
||||
set(cxx_strict "${cxx_default} -Wextra")
|
||||
endif()
|
||||
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available.
|
||||
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
|
||||
endif()
|
||||
|
||||
# For building gtest's own tests and samples.
|
||||
set(cxx_default "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exceptions_flags}")
|
||||
set(cxx_no_exception
|
||||
"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
|
||||
set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags} -DGTEST_HAS_RTTI=0")
|
||||
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
|
||||
|
||||
# For building the gtest libraries.
|
||||
set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
|
||||
|
||||
########################################################################
|
||||
#
|
||||
@ -242,15 +264,6 @@ endif()
|
||||
############################################################
|
||||
# C++ tests built with non-standard compiler flags.
|
||||
|
||||
if (MSVC)
|
||||
set(cxx_no_exception "${cxx_base} -D_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti "${cxx_default} -GR-")
|
||||
else()
|
||||
set(cxx_no_exception "${cxx_base} -fno-exceptions")
|
||||
set(cxx_no_rtti "${cxx_default} -fno-rtti -DGTEST_HAS_RTTI=0")
|
||||
endif()
|
||||
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
|
||||
|
||||
if (build_all_gtest_tests)
|
||||
cxx_library(gtest_no_exception "${cxx_no_exception}"
|
||||
src/gtest-all.cc)
|
||||
|
@ -797,7 +797,7 @@ Derived* CheckedDowncastToActualType(Base* base) {
|
||||
return dynamic_cast<Derived*>(base); // NOLINT
|
||||
#else
|
||||
return static_cast<Derived*>(base); // Poor man's downcast.
|
||||
#endif // GTEST_HAS_RTTI
|
||||
#endif
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STREAM_REDIRECTION_
|
||||
|
Loading…
x
Reference in New Issue
Block a user