pedrolcl / drumstick

Drumstick Qt/C++ MIDI libraries (Mirror)
https://sourceforge.net/projects/drumstick/
GNU General Public License v3.0
12 stars 3 forks source link

"Macro names must be identifiers" errors while building drumstick 2.8.0 #13

Closed GvMariani closed 1 year ago

GvMariani commented 1 year ago

While processing library/alsa stuff, new drumstick sources (2.8.0) fail to build here (gcc 11.2.0, x86_64), with multiple "macro names must be identifiers" errors (see attached full log of a failed build). BuildError.txt.

By looking at one failed command line, I noticed a definition looking suspect ("-D-DRTKIT_SUPPORT"): it looks like a spurious "-"... Indeed, changing the line 26 in the CMakeLists.txt file for library/alsa from "$<$<BOOL:${HAVE_DBUS}>:-DRTKIT_SUPPORT>" to "$<$<BOOL:${HAVE_DBUS}>:DRTKIT_SUPPORT>" (ie removing the stray "-" before DRKIT_SUPPORT) it completely fixes the issue.

pedrolcl commented 1 year ago

What is your CMake version? The minimum supported CMake version is 3.14

The generated command line in the build log is wrong, but your solution is also wrong. You have enabled the option USE_DBUS, which also enables the macro "RTKIT_SUPPORT", which in turn enables using RealtimeKit.

If you take a look to the cmake 3.14 documentation (or newer), target_compile_definitions says that:

Any leading -D on an item will be removed. Empty items are ignored. For example, the following are all equivalent:

So, if your CMake is broken and doesn't do what it should do, then you should remove "-D" and not only the "-".

pedrolcl commented 1 year ago

Seems that this bug has already been detected in CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/24186

The fix for this issue was merged for CMake 3.26: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8004

So, I think that we should fix drumstick anyway, because although RealtimeKit (and DBus) is not enabled by many Linux distributions nowadays, it is still a problem for those using older CMake versions.

GvMariani commented 1 year ago

What is your CMake version? The minimum supported CMake version is 3.14

I have 3.21.3...

The generated command line in the build log is wrong, but your solution is also wrong. You have enabled the option USE_DBUS, which also enables the macro "RTKIT_SUPPORT", which in turn enables using RealtimeKit.

If you take a look to the cmake 3.14 documentation (or newer), target_compile_definitions says that:

Any leading -D on an item will be removed. Empty items are ignored. For example, the following are all equivalent:

So, if your CMake is broken and doesn't do what it should do, then you should remove "-D" and not only the "-".

Oops... You're right, I should remove also the "D": with my solution now I have "-DDRTKIT_SUPPORT" and this is plain wrong. I will update my local patch and wait for a fixed release...

pedrolcl commented 1 year ago

Fix released in v2.8.1