I am trying to use the new logic in CMake 3.3 that checks if a value is in a list
cmake_minimum_required(VERSION 3.3)
cmake_policy(SET CMP0057 NEW)
set(l A B C)
foreach( e ${l} )
if( ${e} IN_LIST "${l}" )
message( "element ${e} found in ${l}" )
else()
message( "element ${e} NOT found in ${l}" )
endif()
endforeach()
Running this with CMake 3.4.3 on OSX Yosemite gives an unexpected result:
$ cmake -P cmakeBug.cmake
element A NOT found in A;B;C
element B NOT found in A;B;C
element C NOT found in A;B;C
Am I missing something trivial or is there a bug in CMake?
Try IF ( ${e} IN_LIST l )
. According to the docs the second argument is a list variable, not a list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With