summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorHong Xu <hong@topbug.net>2019-07-07 15:47:06 -0700
committerBrad King <brad.king@kitware.com>2019-07-26 15:09:28 -0400
commit72fcadb007261f8e1883040d7dc5643e3555aa45 (patch)
tree0a7f2ab77a257930351375e04a61223149f74bdc /Tests
parent93f10f06b3b86085a180e5259f653646e1705baf (diff)
downloadcmake-72fcadb007261f8e1883040d7dc5643e3555aa45.tar.gz
CheckCXXSymbolExists: Make C++-syntax symbols work on more compilers
On some compilers the syntax `#ifndef std::fopen` will always lead to compilation error. Avoid generating it in the check.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
index f058c19fb6..2028a135cf 100644
--- a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
+++ b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
@@ -49,6 +49,15 @@ else ()
message(STATUS "errno found in <cerrno>")
endif ()
+check_cxx_symbol_exists("std::fopen" "cstdio" CSE_RESULT_FOPEN)
+if (NOT CSE_RESULT_FOPEN)
+ if(NOT ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10))
+ message(SEND_ERROR "CheckCXXSymbolExists did not find std::fopen in <cstdio>")
+ endif()
+else()
+ message(STATUS "std::fopen found in <cstdio>")
+endif()
+
if (CMAKE_COMPILER_IS_GNUCXX)
string(APPEND CMAKE_CXX_FLAGS " -O3")
unset(CSE_RESULT_O3 CACHE)
@@ -60,3 +69,8 @@ if (CMAKE_COMPILER_IS_GNUCXX)
message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3")
endif ()
endif ()
+
+check_cxx_symbol_exists("std::non_existent_function_for_symbol_test<int*>" "algorithm" CSE_RESULT_NON_SYMBOL)
+if (CSE_RESULT_NON_SYMBOL)
+ message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol.")
+endif()