Saturday, October 29, 2022

[SOLVED] CMake target_compile_definitions add comma separated list for value

Issue

I wish to replicate in CMake the following:

#define mydef a, b, c

However

target_compile_definitions(myproject PRIVATE mydef="a, b, c")

seems to result in

#define mydef "a, b, c"

What would be the correct syntax to achieve the desired result?


Solution

You need to quote the whole parameter including the name of the symbol you want to define:

target_compile_definitions(myproject PRIVATE "mydef=a, b, c")


Answered By - fabian
Answer Checked By - Katrina (WPSolving Volunteer)