How to put regex string as compiler option
I want to write a simple function in CMake:
function(add_my_compiler_options target_name regexes)
if(NOT "${regexes}" STREQUAL "")
target_compile_options(${target_name}
PRIVATE
"-fprofile-filter-files=${regexes}"
)
endif()
endfunction()
And I want to call it like this:
set(regexes [=[^.*first\.(h|cpp)$;^.*second\.(h|cpp)$]=])
add_my_compiler_options(${regexes})
How to fix this function to get this compiler command line?:
compiler -fprofile-filter-files="^.*first\.(h|cpp)$;^.*second\.(h|cpp)$"