63 lines
2.1 KiB
CMake
Raw Normal View History

2012-04-19 19:04:21 +03:00
# This test will verify if CheckCXXSymbolExists only report symbols available
# for linking that really are. You can find some documentation on this in
# bug 11333 where we found out that gcc would optimize out the actual
# reference to the symbol, so symbols that are in fact _not_ available in the
# given libraries (but seen in header) were reported as present.
#
# If you change this test do not forget to change the CheckSymbolExists
# test, too.
2013-03-16 19:13:01 +02:00
project(CheckCXXSymbolExists CXX)
2012-04-19 19:04:21 +03:00
2013-03-16 19:13:01 +02:00
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2012-04-19 19:04:21 +03:00
2013-03-16 19:13:01 +02:00
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../CheckSymbolExists")
2012-04-19 19:04:21 +03:00
2013-03-16 19:13:01 +02:00
include(CheckCXXSymbolExists)
2012-04-19 19:04:21 +03:00
foreach(_config_type Release RelWithDebInfo MinSizeRel Debug)
set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type})
unset(CSE_RESULT_${_config_type} CACHE)
2013-03-16 19:13:01 +02:00
message(STATUS "Testing configuration ${_config_type}")
2012-04-19 19:04:21 +03:00
check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type})
2013-03-16 19:13:01 +02:00
if (CSE_RESULT_${_config_type})
message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}")
endif ()
2012-04-19 19:04:21 +03:00
endforeach()
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
unset(CSE_RESULT_ERRNO_CERRNO CACHE)
2013-03-16 19:13:01 +02:00
message(STATUS "Checking <cerrno>")
2012-04-19 19:04:21 +03:00
check_cxx_symbol_exists(errno "cerrno" CSE_RESULT_ERRNO_CERRNO)
2013-03-16 19:13:01 +02:00
if (NOT CSE_RESULT_ERRNO_CERRNO)
2012-04-19 19:04:21 +03:00
unset(CSE_RESULT_ERRNO_ERRNOH CACHE)
2013-03-16 19:13:01 +02:00
message(STATUS "Checking <errno.h>")
2012-04-19 19:04:21 +03:00
check_cxx_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO_ERRNOH)
2013-03-16 19:13:01 +02:00
if (NOT CSE_RESULT_ERRNO_ERRNOH)
message(SEND_ERROR "CheckCXXSymbolExists did not find errno in <cerrno> and <errno.h>")
else ()
message(STATUS "errno found in <errno.h>")
endif ()
else ()
message(STATUS "errno found in <cerrno>")
endif ()
2012-04-19 19:04:21 +03:00
2013-03-16 19:13:01 +02:00
if (CMAKE_COMPILER_IS_GNUCXX)
2016-10-30 18:24:19 +01:00
string(APPEND CMAKE_CXX_FLAGS " -O3")
2012-04-19 19:04:21 +03:00
unset(CSE_RESULT_O3 CACHE)
2013-03-16 19:13:01 +02:00
message(STATUS "Testing with optimization -O3")
2012-04-19 19:04:21 +03:00
check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3)
2013-03-16 19:13:01 +02:00
if (CSE_RESULT_O3)
message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3")
endif ()
endif ()