| 1 |
enable_language(C) |
| 2 |
enable_language(CXX) |
| 3 |
include(CheckIncludeFile) |
| 4 |
include(CheckIncludeFileCXX) |
| 5 |
include(CheckIncludeFiles) |
| 6 |
|
| 7 |
set(CMAKE_REQUIRED_LIBRARIES does_not_exist) |
| 8 |
|
| 9 |
#============================================================================ |
| 10 |
|
| 11 |
check_include_file("stddef.h" HAVE_STDDEF_H_1) |
| 12 |
if(NOT HAVE_STDDEF_H_1) |
| 13 |
message(SEND_ERROR "HAVE_STDDEF_H_1 failed but should have passed.") |
| 14 |
endif() |
| 15 |
if(NOT _CIF_CMP0075_WARNED) |
| 16 |
message(SEND_ERROR "HAVE_STDDEF_H_1 did not warn but should have") |
| 17 |
endif() |
| 18 |
check_include_file("stddef.h" HAVE_STDDEF_H_2) # second does not warn |
| 19 |
if(NOT HAVE_STDDEF_H_2) |
| 20 |
message(SEND_ERROR "HAVE_STDDEF_H_2 failed but should have passed.") |
| 21 |
endif() |
| 22 |
unset(_CIF_CMP0075_WARNED) |
| 23 |
|
| 24 |
#---------------------------------------------------------------------------- |
| 25 |
|
| 26 |
check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_1) |
| 27 |
if(NOT HAVE_STDDEF_H_CXX_1) |
| 28 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 failed but should have passed.") |
| 29 |
endif() |
| 30 |
if(NOT _CIF_CMP0075_WARNED) |
| 31 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 did not warn but should have") |
| 32 |
endif() |
| 33 |
check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_2) # second does not warn |
| 34 |
if(NOT HAVE_STDDEF_H_CXX_2) |
| 35 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_2 failed but should have passed.") |
| 36 |
endif() |
| 37 |
unset(_CIF_CMP0075_WARNED) |
| 38 |
|
| 39 |
#---------------------------------------------------------------------------- |
| 40 |
|
| 41 |
check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_1) |
| 42 |
if(NOT HAVE_STDLIB_H_1) |
| 43 |
message(SEND_ERROR "HAVE_STDLIB_H_1 failed but should have passed.") |
| 44 |
endif() |
| 45 |
if(NOT _CIF_CMP0075_WARNED) |
| 46 |
message(SEND_ERROR "HAVE_STDLIB_H_1 did not warn but should have") |
| 47 |
endif() |
| 48 |
check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_2) # second does not warn |
| 49 |
if(NOT HAVE_STDLIB_H_2) |
| 50 |
message(SEND_ERROR "HAVE_STDLIB_H_2 failed but should have passed.") |
| 51 |
endif() |
| 52 |
unset(_CIF_CMP0075_WARNED) |
| 53 |
|
| 54 |
#============================================================================ |
| 55 |
cmake_policy(SET CMP0075 OLD) |
| 56 |
# These should not warn. |
| 57 |
# These should pass the checks due to ignoring 'does_not_exist'. |
| 58 |
|
| 59 |
check_include_file("stddef.h" HAVE_STDDEF_H_3) |
| 60 |
if(NOT HAVE_STDDEF_H_3) |
| 61 |
message(SEND_ERROR "HAVE_STDDEF_H_3 failed but should have passed.") |
| 62 |
endif() |
| 63 |
if(_CIF_CMP0075_WARNED) |
| 64 |
message(SEND_ERROR "HAVE_STDDEF_H_3 warned but should not have") |
| 65 |
endif() |
| 66 |
unset(_CIF_CMP0075_WARNED) |
| 67 |
|
| 68 |
#---------------------------------------------------------------------------- |
| 69 |
|
| 70 |
check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_3) |
| 71 |
if(NOT HAVE_STDDEF_H_CXX_3) |
| 72 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 failed but should have passed.") |
| 73 |
endif() |
| 74 |
if(_CIF_CMP0075_WARNED) |
| 75 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 warned but should not have") |
| 76 |
endif() |
| 77 |
unset(_CIF_CMP0075_WARNED) |
| 78 |
|
| 79 |
#---------------------------------------------------------------------------- |
| 80 |
|
| 81 |
check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_3) |
| 82 |
if(NOT HAVE_STDLIB_H_3) |
| 83 |
message(SEND_ERROR "HAVE_STDLIB_H_3 failed but should have passed.") |
| 84 |
endif() |
| 85 |
if(_CIF_CMP0075_WARNED) |
| 86 |
message(SEND_ERROR "HAVE_STDLIB_H_3 warned but should not have") |
| 87 |
endif() |
| 88 |
unset(_CIF_CMP0075_WARNED) |
| 89 |
|
| 90 |
#============================================================================ |
| 91 |
cmake_policy(SET CMP0075 NEW) |
| 92 |
# These should not warn. |
| 93 |
# These should fail the checks due to requiring 'does_not_exist'. |
| 94 |
|
| 95 |
check_include_file("stddef.h" HAVE_STDDEF_H_4) |
| 96 |
if(HAVE_STDDEF_H_4) |
| 97 |
message(SEND_ERROR "HAVE_STDDEF_H_4 passed but should have failed.") |
| 98 |
endif() |
| 99 |
if(_CIF_CMP0075_WARNED) |
| 100 |
message(SEND_ERROR "HAVE_STDDEF_H_4 warned but should not have") |
| 101 |
endif() |
| 102 |
unset(_CIF_CMP0075_WARNED) |
| 103 |
|
| 104 |
#---------------------------------------------------------------------------- |
| 105 |
|
| 106 |
check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_4) |
| 107 |
if(HAVE_STDDEF_H_CXX_4) |
| 108 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 passed but should have failed.") |
| 109 |
endif() |
| 110 |
if(_CIF_CMP0075_WARNED) |
| 111 |
message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 warned but should not have") |
| 112 |
endif() |
| 113 |
unset(_CIF_CMP0075_WARNED) |
| 114 |
|
| 115 |
#---------------------------------------------------------------------------- |
| 116 |
|
| 117 |
check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_4) |
| 118 |
if(HAVE_STDLIB_H_4) |
| 119 |
message(SEND_ERROR "HAVE_STDLIB_H_4 passed but should have failed.") |
| 120 |
endif() |
| 121 |
if(_CIF_CMP0075_WARNED) |
| 122 |
message(SEND_ERROR "HAVE_STDLIB_H_4 warned but should not have") |
| 123 |
endif() |
| 124 |
unset(_CIF_CMP0075_WARNED) |