https://github.com/Kitware/CMake
Raw File
Tip revision: b5602e7254c8ce4a6f732c017d784cd80559e5aa authored by Brad King on 20 March 2024, 14:03:43 UTC
CMake 3.28.4
Tip revision: b5602e7
CMP0057-NEW.cmake
cmake_policy(SET CMP0057 NEW)

set(MY_NON_EXISTENT_LIST)

set(MY_EMPTY_LIST "")

set(MY_LIST foo bar)

if(NOT "foo" IN_LIST MY_LIST)
  message(FATAL_ERROR "expected item 'foo' not found in list MY_LIST")
endif()

if("baz" IN_LIST MY_LIST)
  message(FATAL_ERROR "unexpected item 'baz' found in list MY_LIST")
endif()

if("foo" IN_LIST MY_NON_EXISTENT_LIST)
  message(FATAL_ERROR
    "unexpected item 'baz' found in non existent list MY_NON_EXISTENT_LIST")
endif()

if("foo" IN_LIST MY_EMPTY_LIST)
  message(FATAL_ERROR
    "unexpected item 'baz' found in empty list MY_EMPTY_LIST")
endif()

set(VAR "foo")

if(NOT VAR IN_LIST MY_LIST)
  message(FATAL_ERROR "expected item VAR not found in list MY_LIST")
endif()
back to top