May be you can try with Negative Look ahead. However it will be easier to do t like this:
file(GLOB_RECURSE FILES CONFIGURE_DEPENDS src/*.cpp)
foreach( FILE ${FILES})
if (${FILE} MATCHES test.cpp)
list(APPEND TESTS ${FILE})
else()
list(APPEND SOURCES ${FILE})
endif()
endforeach()
This way you can use sources to compile and you will also have the test list ready.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…