WarnDeprecated.cmake 561 B

12345678910111213141516171819
  1. enable_language(C)
  2. set(CMAKE_WARN_DEPRECATED SOME_VALUE)
  3. try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
  4. SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c
  5. OUTPUT_VARIABLE out
  6. )
  7. if(NOT result)
  8. message(FATAL_ERROR "try_compile failed:\n${out}")
  9. endif()
  10. # Check that the cache was populated with our custom variable.
  11. file(STRINGS ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CMakeCache.txt entries
  12. REGEX CMAKE_WARN_DEPRECATED:UNINITIALIZED=${CMAKE_WARN_DEPRECATED}
  13. )
  14. if(NOT entries)
  15. message(FATAL_ERROR "try_compile did not populate cache as expected")
  16. endif()