Don't read CMAKE_BUILD_TYPE if it is not there (#811)

Weird, but seems consistent with the rest of cmake here.
This commit is contained in:
Roman Lebedev 2019-05-08 02:06:50 +03:00 committed by Dominic Hamon
parent 7d856b0304
commit 33d4404650

View File

@ -34,7 +34,9 @@ if(LIBRT)
target_link_libraries(benchmark ${LIBRT})
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
endif()
if(NOT CMAKE_THREAD_LIBS_INIT AND "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}" MATCHES ".*-fsanitize=[^ ]*address.*")
message(WARNING "CMake's FindThreads.cmake did not fail, but CMAKE_THREAD_LIBS_INIT ended up being empty. This was fixed in https://github.com/Kitware/CMake/commit/d53317130e84898c5328c237186dbd995aaf1c12 Let's guess that -pthread is sufficient.")
target_link_libraries(benchmark -pthread)