2
set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
6
set(CMAKE_EXE_LINKER_FLAGS ${pre}BADFLAG${obj})
8
#-----------------------------------------------------------------------------
9
message("before try_compile with CMP0056 WARN-default")
10
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
11
${CMAKE_CURRENT_SOURCE_DIR}/src.c
14
string(REPLACE "\n" "\n " out " ${out}")
16
message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
17
elseif("x${out}" MATCHES "BADFLAG")
18
message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
20
message(STATUS "try_compile with CMP0056 WARN-default worked as expected")
22
message("after try_compile with CMP0056 WARN-default")
24
#-----------------------------------------------------------------------------
25
set(CMAKE_POLICY_WARNING_CMP0056 ON)
26
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
27
${CMAKE_CURRENT_SOURCE_DIR}/src.c
30
string(REPLACE "\n" "\n " out " ${out}")
32
message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
33
elseif("x${out}" MATCHES "BADFLAG")
34
message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
36
message(STATUS "try_compile with CMP0056 WARN-enabled worked as expected")
39
#-----------------------------------------------------------------------------
40
cmake_policy(SET CMP0056 OLD)
41
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
42
${CMAKE_CURRENT_SOURCE_DIR}/src.c
45
string(REPLACE "\n" "\n " out " ${out}")
47
message(FATAL_ERROR "try_compile failed but should have passed:\n${out}")
48
elseif("x${out}" MATCHES "BADFLAG")
49
message(FATAL_ERROR "try_compile output mentions BADFLAG:\n${out}")
51
message(STATUS "try_compile with CMP0056 OLD worked as expected")
54
#-----------------------------------------------------------------------------
55
cmake_policy(SET CMP0056 NEW)
56
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
57
${CMAKE_CURRENT_SOURCE_DIR}/src.c
60
string(REPLACE "\n" "\n " out " ${out}")
62
message(FATAL_ERROR "try_compile passed but should have failed:\n${out}")
63
elseif(NOT "x${out}" MATCHES "BADFLAG")
64
message(FATAL_ERROR "try_compile did not fail with BADFLAG:\n${out}")
66
message(STATUS "try_compile with CMP0056 NEW worked as expected")