2012-01-03 02:04:42 +04:00
|
|
|
# This test will verify if CheckSymbolExists 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 CheckCXXSymbolExists
|
|
|
|
# test, too.
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
project(CheckSymbolExists C)
|
2012-01-03 02:04:42 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
2012-01-03 02:04:42 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}")
|
2012-01-03 02:04:42 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CheckSymbolExists)
|
2012-01-03 02:04:42 +04:00
|
|
|
|
|
|
|
foreach(_config_type Release RelWithDebInfo MinSizeRel Debug)
|
|
|
|
set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type})
|
|
|
|
unset(CSE_RESULT_${_config_type} CACHE)
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Testing configuration ${_config_type}")
|
2012-01-03 02:04:42 +04:00
|
|
|
|
|
|
|
check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type})
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (CSE_RESULT_${_config_type})
|
|
|
|
message(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-01-03 02:04:42 +04:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
|
|
|
unset(CSE_RESULT_ERRNO CACHE)
|
|
|
|
|
|
|
|
check_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (NOT CSE_RESULT_ERRNO)
|
|
|
|
message(SEND_ERROR "CheckSymbolExists did not find errno in <errno.h>")
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "errno found as expected")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-01-03 02:04:42 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCC)
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND CMAKE_C_FLAGS " -O3")
|
2012-01-03 02:04:42 +04:00
|
|
|
unset(CSE_RESULT_O3 CACHE)
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Testing with optimization -O3")
|
2012-01-03 02:04:42 +04:00
|
|
|
|
|
|
|
check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if (CSE_RESULT_O3)
|
|
|
|
message(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing with optimization -O3")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endif ()
|