A relevant fragment of my CMakeLists.txt file:
add_executable(hello main.cpp)
set(helloCompileOptions -Wall -Wextra -O3 -Wno-narrowing -ffast-math -march=native)
target_compile_options(hello PRIVATE ${helloCompileOptions})
target_compile_features(hello PUBLIC cxx_std_23)
add_compile_definitions(COMPILE_OPTIONS="${helloCompileOptions}")
produces these compilation errors:
[build] <command line>:1:9: error: macro name must be an identifier
[build] 1 | #define -O3 1
[build] | ^
[build] <command line>:2:9: error: macro name must be an identifier
[build] 2 | #define -Wextra 1
[build] | ^
...
How should I handle the helloCompileOptions list, so it compiles and is avalable as a string to my C++ code?
Using CMake string processing:
makes this line:
produce: