2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2012-08-13 21:47:32 +04:00
|
|
|
project(TryCompile)
|
2003-02-10 21:19:34 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(TEST_ASSERT value msg)
|
|
|
|
if (NOT ${value})
|
|
|
|
message (SEND_ERROR "Assertion failure:" ${msg} )
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endmacro()
|
2007-07-31 22:52:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(TEST_FAIL value msg)
|
|
|
|
if (${value})
|
|
|
|
message (SEND_ERROR "Failing test succeeded:" ${msg} )
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
|
|
|
endmacro()
|
2007-07-31 22:52:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(TEST_EXPECT_EXACT command expected)
|
|
|
|
if(NOT "x${result}" STREQUAL "x${expected}")
|
|
|
|
message(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2007-07-31 22:52:01 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(TEST_EXPECT_CONTAINS command expected)
|
|
|
|
if(NOT "${result}" MATCHES "${expected}")
|
|
|
|
message(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2007-07-31 22:52:01 +04:00
|
|
|
|
2008-07-15 18:04:01 +04:00
|
|
|
|
2003-02-10 21:19:34 +03:00
|
|
|
# try to compile a file that should compile
|
2007-05-24 20:06:59 +04:00
|
|
|
# also check that COPY_FILE works
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(SHOULD_PASS
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_SOURCE_DIR}/pass.c
|
2007-05-24 20:06:59 +04:00
|
|
|
OUTPUT_VARIABLE TRY_OUT
|
|
|
|
COPY_FILE ${TryCompile_BINARY_DIR}/CopyOfPass
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT SHOULD_PASS)
|
|
|
|
message(SEND_ERROR "should pass failed ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT EXISTS "${TryCompile_BINARY_DIR}/CopyOfPass")
|
|
|
|
message(SEND_ERROR "COPY_FILE to \"${TryCompile_BINARY_DIR}/CopyOfPass\" failed")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
file(REMOVE "${TryCompile_BINARY_DIR}/CopyOfPass")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-02-10 21:19:34 +03:00
|
|
|
|
2013-07-09 23:26:15 +04:00
|
|
|
# try to compile a file that should compile
|
|
|
|
# also check that COPY_FILE_ERROR works
|
|
|
|
file(WRITE ${TryCompile_BINARY_DIR}/invalid "")
|
|
|
|
try_compile(SHOULD_PASS
|
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/pass.c
|
|
|
|
OUTPUT_VARIABLE TRY_OUT
|
|
|
|
COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path
|
|
|
|
COPY_FILE_ERROR _captured
|
|
|
|
)
|
|
|
|
if(NOT SHOULD_PASS)
|
|
|
|
message(SEND_ERROR "should pass failed ${TRY_OUT}")
|
|
|
|
endif()
|
|
|
|
if(NOT _captured MATCHES "Cannot copy output executable.*/invalid/path")
|
|
|
|
message(SEND_ERROR "COPY_FILE_ERROR did not capture expected message")
|
|
|
|
endif()
|
|
|
|
|
2003-02-10 21:19:34 +03:00
|
|
|
# try to compile a file that should not compile
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(SHOULD_FAIL
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_SOURCE_DIR}/fail.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SHOULD_FAIL)
|
|
|
|
message(SEND_ERROR "Should fail passed ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-02-10 21:19:34 +03:00
|
|
|
|
|
|
|
# try to compile a file that should compile
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(SHOULD_PASS
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_SOURCE_DIR}/pass.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT SHOULD_PASS)
|
|
|
|
message(SEND_ERROR "should pass failed ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-02-10 21:19:34 +03:00
|
|
|
|
|
|
|
# try to compile a file that should not compile
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(SHOULD_FAIL
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 00:20:10 +03:00
|
|
|
${TryCompile_SOURCE_DIR}/fail.c
|
2003-02-10 21:19:34 +03:00
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(SHOULD_FAIL)
|
|
|
|
message(SEND_ERROR "Should fail passed ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
2013-06-06 21:54:44 +04:00
|
|
|
# try to compile two files that should compile
|
|
|
|
try_compile(SHOULD_PASS
|
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
|
|
|
SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx
|
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
if(NOT SHOULD_PASS)
|
|
|
|
message(SEND_ERROR "should pass failed ${TRY_OUT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# try to compile two files that should not compile
|
|
|
|
try_compile(SHOULD_FAIL
|
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
|
|
|
SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c
|
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
if(SHOULD_FAIL)
|
|
|
|
message(SEND_ERROR "Should fail passed ${TRY_OUT}")
|
|
|
|
endif()
|
|
|
|
|
2013-07-03 23:57:02 +04:00
|
|
|
# try to compile a file that should compile
|
|
|
|
set(_c_flags "${CMAKE_C_FLAGS}")
|
2016-03-09 17:42:18 +03:00
|
|
|
if(WATCOM)
|
2013-07-03 23:57:02 +04:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -dTESTDEF")
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"")
|
|
|
|
endif()
|
|
|
|
try_compile(SHOULD_PASS
|
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
|
|
|
${TryCompile_SOURCE_DIR}/testdef.c
|
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
|
|
|
if(NOT SHOULD_PASS)
|
|
|
|
message(SEND_ERROR "should pass failed ${TRY_OUT}")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${_c_flags}")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT SHOULD_FAIL)
|
|
|
|
if(SHOULD_PASS)
|
|
|
|
message("All Tests passed, ignore all previous output.")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Test failed")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Test failed")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(CMAKE_ANSI_FOR_SCOPE
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 06:00:40 +03:00
|
|
|
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
message("Compiler supports ansi for")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Compiler does not support ansi for scope")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-02-11 06:00:40 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(CMAKE_ANSI_FOR_SCOPE
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2003-02-11 06:00:40 +03:00
|
|
|
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
message("Compiler supports ansi for")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Compiler does not support ansi for scope")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
message("use the module now")
|
|
|
|
include(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake)
|
|
|
|
if (CMAKE_ANSI_FOR_SCOPE)
|
|
|
|
message("Compiler supports ansi for")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("Compiler does not support ansi for scope")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
message("Testing try_compile project mode")
|
|
|
|
try_compile(TEST_INNER
|
2009-08-03 21:37:28 +04:00
|
|
|
${TryCompile_BINARY_DIR}/CMakeFiles/Inner
|
|
|
|
${TryCompile_SOURCE_DIR}/Inner
|
2009-08-04 22:37:46 +04:00
|
|
|
TryCompileInner innerexe
|
|
|
|
OUTPUT_VARIABLE output)
|
|
|
|
TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}")
|
2009-08-03 21:37:28 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(TryCompile pass.c)
|
2007-05-24 19:27:51 +04:00
|
|
|
|
|
|
|
######################################
|
|
|
|
|
|
|
|
# now two tests for TRY_RUN
|
|
|
|
|
|
|
|
# try to run a file that should compile and run without error
|
2007-06-01 19:16:29 +04:00
|
|
|
# also check that OUTPUT_VARIABLE contains both the compile output
|
|
|
|
# and the run output
|
2012-08-13 21:47:32 +04:00
|
|
|
try_run(SHOULD_RUN SHOULD_COMPILE
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2007-05-24 19:27:51 +04:00
|
|
|
${TryCompile_SOURCE_DIR}/exit_success.c
|
|
|
|
OUTPUT_VARIABLE TRY_OUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT SHOULD_COMPILE)
|
|
|
|
message(SEND_ERROR "exit_success failed compiling: ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${SHOULD_RUN}" STREQUAL "0")
|
|
|
|
message(SEND_ERROR "exit_success failed running with exit code ${SHOULD_RUN}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-01 19:16:29 +04:00
|
|
|
# check the compile output for the filename
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${TRY_OUT}" MATCHES "exit_success")
|
|
|
|
message(SEND_ERROR " TRY_OUT didn't contain \"exit_success\": \"${TRY_OUT}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-01 19:16:29 +04:00
|
|
|
# check the run output
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${TRY_OUT}" MATCHES "hello world")
|
|
|
|
message(SEND_ERROR " TRY_OUT didn't contain \"hello world\": \"${TRY_OUT}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-01 19:16:29 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
try_run(ARG_TEST_RUN ARG_TEST_COMPILE
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2009-10-29 06:29:13 +03:00
|
|
|
${TryCompile_SOURCE_DIR}/expect_arg.c
|
|
|
|
OUTPUT_VARIABLE TRY_OUT
|
|
|
|
ARGS arg1 arg2)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT ARG_TEST_COMPILE)
|
|
|
|
message(SEND_ERROR "expect_arg failed compiling: ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${ARG_TEST_RUN}" STREQUAL "0")
|
|
|
|
message(SEND_ERROR "expect_arg failed running with exit code ${ARG_TEST_RUN} ${TRY_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-05-24 19:27:51 +04:00
|
|
|
|
|
|
|
# try to run a file that should compile and run, but return an error
|
2012-08-13 21:47:32 +04:00
|
|
|
try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
|
2012-08-13 21:42:58 +04:00
|
|
|
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
|
2007-05-24 19:27:51 +04:00
|
|
|
${TryCompile_SOURCE_DIR}/exit_with_error.c
|
2007-06-01 19:16:29 +04:00
|
|
|
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
|
|
|
|
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT SHOULD_COMPILE)
|
|
|
|
message(STATUS " exit_with_error failed compiling: ${COMPILE_OUTPUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${SHOULD_EXIT_WITH_ERROR}" STREQUAL "0")
|
|
|
|
message(SEND_ERROR " exit_with_error passed with exit code ${SHOULD_EXIT_WITH_ERROR}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-05-24 19:27:51 +04:00
|
|
|
|
2007-06-01 19:16:29 +04:00
|
|
|
# check the compile output, it should contain the filename
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${COMPILE_OUTPUT}" MATCHES "exit_with_error")
|
|
|
|
message(SEND_ERROR " COMPILE_OUT didn't contain \"exit_with_error\": \"${COMPILE_OUTPUT}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-01 19:16:29 +04:00
|
|
|
#... but not the run time output
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${COMPILE_OUTPUT}" MATCHES "hello world")
|
|
|
|
message(SEND_ERROR " COMPILE_OUT contains the run output: \"${COMPILE_OUTPUT}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-06-01 19:16:29 +04:00
|
|
|
# check the run output, it should stdout
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT "${RUN_OUTPUT}" MATCHES "hello world")
|
|
|
|
message(SEND_ERROR " RUN_OUTPUT didn't contain \"hello world\": \"${RUN_OUTPUT}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-07-31 22:52:01 +04:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# also test that the CHECK_C_SOURCE_COMPILES, CHECK_CXX_SOURCE_COMPILES
|
|
|
|
# CHECK_C_SOURCE_RUNS and CHECK_CXX_SOURCE_RUNS macros work
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
include(CheckCSourceRuns)
|
|
|
|
include(CheckCXXSourceRuns)
|
2007-07-31 22:52:01 +04:00
|
|
|
|
|
|
|
CHECK_C_SOURCE_COMPILES("I dont build" C_BUILD_SHOULD_FAIL)
|
|
|
|
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" C_BUILD_SHOULD_WORK)
|
|
|
|
CHECK_C_SOURCE_RUNS("int main() {return 1;}" C_RUN_SHOULD_FAIL)
|
|
|
|
CHECK_C_SOURCE_RUNS("int main() {return 0;}" C_RUN_SHOULD_WORK)
|
|
|
|
|
|
|
|
TEST_FAIL(C_BUILD_SHOULD_FAIL "CHECK_C_SOURCE_COMPILES() succeeded, but should have failed")
|
|
|
|
TEST_ASSERT(C_BUILD_SHOULD_WORK "CHECK_C_SOURCE_COMPILES() failed")
|
|
|
|
TEST_FAIL(C_RUN_SHOULD_FAIL "CHECK_C_SOURCE_RUNS() succeeded, but should have failed")
|
|
|
|
TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed")
|
|
|
|
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("I dont build" CXX_BUILD_SHOULD_FAIL)
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK)
|
|
|
|
CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL)
|
|
|
|
CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK)
|
|
|
|
|
|
|
|
TEST_FAIL(CXX_BUILD_SHOULD_FAIL "CHECK_CXX_SOURCE_COMPILES() succeeded, but should have failed")
|
|
|
|
TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed")
|
|
|
|
TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed")
|
|
|
|
TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(lang C CXX)
|
2014-10-14 18:25:32 +04:00
|
|
|
if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL "PathScale")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(${lang}_DD --)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2010-01-25 16:47:32 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(C_BOGUS_FLAG CACHE)
|
|
|
|
include(CheckCCompilerFlag)
|
2010-01-25 16:47:32 +03:00
|
|
|
CHECK_C_COMPILER_FLAG(${C_DD}-_this_is_not_a_flag_ C_BOGUS_FLAG)
|
2009-09-17 23:33:12 +04:00
|
|
|
TEST_FAIL(C_BOGUS_FLAG "CHECK_C_COMPILER_FLAG() succeeded, but should have failed")
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(CXX_BOGUS_FLAG CACHE)
|
|
|
|
include(CheckCXXCompilerFlag)
|
2010-01-25 16:47:32 +03:00
|
|
|
CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG)
|
2009-09-17 23:33:12 +04:00
|
|
|
TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed")
|
2010-12-16 21:34:54 +03:00
|
|
|
|
2014-10-14 18:25:32 +04:00
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(C_STRICT_PROTOTYPES CACHE)
|
2010-12-16 21:34:54 +03:00
|
|
|
CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
|
|
|
|
TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2011-03-04 18:36:29 +03:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
#
|
|
|
|
# also test that the check_prototype_definition macro works
|
|
|
|
|
|
|
|
include(CheckPrototypeDefinition)
|
|
|
|
|
|
|
|
check_prototype_definition(remove
|
|
|
|
"int remove(const char *pathname)"
|
|
|
|
"0"
|
|
|
|
"stdio.h"
|
|
|
|
TEST_REMOVE_PROTO)
|
|
|
|
test_assert(TEST_REMOVE_PROTO "check_prototype_definition for remove() failed")
|