I’m trying to create a version string, which is treated as a char* when used.
I’m currently using
#define VERSION_MAJOR @cmakeproject_VERSION_MAJOR@
#define VERSION_MINOR @cmakeproject_VERSION_MINOR@
#define VERSION_PATCH @cmakeproject_VERSION_PATCH@
#define VERSION_STRING "" VERSION_MAJOR "." VERSION_MINOR "." VERSION_PATCH
After cmake configures, this will look like
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_STRING "" VERSION_MAJOR "." VERSION_MINOR "." VERSION_PATCH
As far as I understand, VERSION_STRING at compile-time will end up looking like
"" 1 "." 2 "." 3
And, this results in error: expected ‘)’ before numeric constant
Is there a way to make it so that VERSION_STRING at compile time looks like “1.2.3”?
Stringification with slingshot should do the trick:
It’ll expand to
"1" "." "2" "." "3", which is the same as"1.2.3".