sudara / pamplejuce

A JUCE audio plugin template. JUCE 7, Catch2, Pluginval, macOS notarization, Azure Trusted Signing, Github Actions
https://melatonin.dev/blog/
MIT License
394 stars 37 forks source link

[cmake] Version can not be used in CMakeLists.txt #11

Closed koerthawkins closed 1 year ago

koerthawkins commented 2 years ago

Bug description

The version information contained in VERSION can not be handled by CMake. If you use the most recent [CMakeLists.txt]() on the codesign branch I get the following error:

CMake Error at CMakeLists.txt:25 (project):
  VERSION "0.2.1

  " format invalid.

I tried to add string quotes here and there but to no avail.

To reproduce

Steps to reproduce the behavior:

  1. Run CMake configuration via e.g. cmake . -B build-debug -G "Unix Makefiles"

Platform

I tested this on my laptop using Ubuntu 20.04, kernel 5.4.0-122-generic. I don't know whether the problem is reproducible on other platforms.

Possible fix

This easy fix worked for me:

# fails
file(READ VERSION CURRENT_VERSION)
# works
file(STRINGS VERSION CURRENT_VERSION)

However, someone would need to try and reproduce the fix on Windows and MacOS.

sudara commented 2 years ago

Hey Lukas,

Which version of CMake are you on?

Do you maybe have extra newlines in the VERSION file? It works for me on Linux

The codesign branch isn't yet stable, gotta clean up the macOS dmg stuff and add Windows codesigning... but it'll be merged soon!

Greetings from Vienna, Sudara

koerthawkins commented 2 years ago

I'm using version 3.24.0-rc4. No, I made sure to avoid any newlines or extra characters in the VERSION file.

To be honest the CMake documentation didn't provide my a reason yet why file(READ VERSION currentversion) should not work but file(STRINGS VERSION currentversion) does. The only possible explanation I could think of would be that with file(READ ...) CMake 3.24 interprets the version number as a float?

Anyhow, is there a reason against using file(STRINGS ...)? Don't want to annoy you, but reading the documentation it just seems to be the slightly cleaner variant in any case for me. :)

sudara commented 2 years ago

Interesting... the reason why I asked about newlines is that your error clearly shows a newline as a part of the output. I wonder if it's possible your editor is automatically adding a newline at the end of VERSION on save.

I have other projects using this format, and other people depend on Pamplejuce, so I'd have to look into the STRINGS addition. Maybe I can get something more robust that will ignore newlines, trim whitespace, etc...

koerthawkins commented 2 years ago

Yes. I intentionally changed the VERSION file with both CLion and NeoVim to exclude the newline character, and it's not in the file. But yes, it's weird indeed!

Anyway, thx for the response. Gladly it's only a small thing, I can live with it if it happens only for me. :)

sudara commented 1 year ago

This was changed to STRINGS some time back, thank you!