~ubuntu-branches/ubuntu/trusty/cmake3/trusty-updates

« back to all changes in this revision

Viewing changes to Tests/RunCMake/try_compile/CMP0056.cmake

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2017-02-23 17:55:24 UTC
  • Revision ID: package-import@ubuntu.com-20170223175524-5nh7s4pu97fsa0t7
Tags: upstream-3.5.1
ImportĀ upstreamĀ versionĀ 3.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
enable_language(C)
 
2
set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
 
3
if(BORLAND)
 
4
  set(pre -)
 
5
endif()
 
6
set(CMAKE_EXE_LINKER_FLAGS ${pre}BADFLAG${obj})
 
7
 
 
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
 
12
  OUTPUT_VARIABLE out
 
13
  )
 
14
string(REPLACE "\n" "\n  " out "  ${out}")
 
15
if(NOT RESULT)
 
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}")
 
19
else()
 
20
  message(STATUS "try_compile with CMP0056 WARN-default worked as expected")
 
21
endif()
 
22
message("after try_compile with CMP0056 WARN-default")
 
23
 
 
24
#-----------------------------------------------------------------------------
 
25
set(CMAKE_POLICY_WARNING_CMP0056 ON)
 
26
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
 
27
  ${CMAKE_CURRENT_SOURCE_DIR}/src.c
 
28
  OUTPUT_VARIABLE out
 
29
  )
 
30
string(REPLACE "\n" "\n  " out "  ${out}")
 
31
if(NOT RESULT)
 
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}")
 
35
else()
 
36
  message(STATUS "try_compile with CMP0056 WARN-enabled worked as expected")
 
37
endif()
 
38
 
 
39
#-----------------------------------------------------------------------------
 
40
cmake_policy(SET CMP0056 OLD)
 
41
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
 
42
  ${CMAKE_CURRENT_SOURCE_DIR}/src.c
 
43
  OUTPUT_VARIABLE out
 
44
  )
 
45
string(REPLACE "\n" "\n  " out "  ${out}")
 
46
if(NOT RESULT)
 
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}")
 
50
else()
 
51
  message(STATUS "try_compile with CMP0056 OLD worked as expected")
 
52
endif()
 
53
 
 
54
#-----------------------------------------------------------------------------
 
55
cmake_policy(SET CMP0056 NEW)
 
56
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR}
 
57
  ${CMAKE_CURRENT_SOURCE_DIR}/src.c
 
58
  OUTPUT_VARIABLE out
 
59
  )
 
60
string(REPLACE "\n" "\n  " out "  ${out}")
 
61
if(RESULT)
 
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}")
 
65
else()
 
66
  message(STATUS "try_compile with CMP0056 NEW worked as expected")
 
67
endif()