Cygwin fails to link a c++ project with sanitizers

I have a c++ project which I try to build with Cygwin (with gcc compiler) in CLion. It compiles successfully, but on the linking stage I get an error:

/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lasan
/usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lubsan
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/main.dir/build.make:106: main.exe] Error 1
make[2]: *** [CMakeFiles/Makefile2:158: CMakeFiles/main.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:165: CMakeFiles/main.dir/rule] Error 2
make: *** [Makefile:184: main] Error 2

It seems like the linker fails to find sanitizer libraries, because when I change a line in my CMakeLists.txt from

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined,address,leak -fno-sanitize-recover=all -D_GLIBCXX_DEBUG")

to

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize-recover=all -D_GLIBCXX_DEBUG")

it builds successfully. The code doesn't matter, the same happens with a "hello world" project.

I would like to use sanitizers in my development, so my question is how do I make it link correctly.