McMartin / FRUT

Building JUCE projects using CMake made easy
https://frut.readthedocs.io
GNU General Public License v3.0
432 stars 40 forks source link

"math cannot parse the expression" Error in Reprojucer when configuring a project #754

Open JoseDiazRohena opened 1 year ago

JoseDiazRohena commented 1 year ago

Hi! I'm excited to get this working but have run into some issues.

I configured and built FRUT as instructed in "getting started". I was able to successfully create a cmakelist.txt for my project, but configuring with cmake .. G Xcode fails with the following error:

CMake Error at ~/ToteBag/Third Party/FRUT/prefix/FRUT/cmake/Reprojucer.cmake:6749 (math):
  math cannot parse the expression: "(1 << 16) + (0 << 8) + 0r1": syntax
  error, unexpected exp_NUMBER, expecting end of file (26).
Call Stack (most recent call first):
  ~/ToteBag/Third Party/FRUT/prefix/FRUT/cmake/Reprojucer.cmake:4653 (_FRUT_version_to_dec)
  ~/ToteBag/Third Party/FRUT/prefix/FRUT/cmake/Reprojucer.cmake:2671 (_FRUT_generate_plist_file)
  CMakeLists.txt:352 (jucer_project_end)

I'm using Xcode 14.2 and Cmake 3.25.1

JoseDiazRohena commented 1 year ago

I think this may be due to an out of date cmake on my part.

JoseDiazRohena commented 1 year ago

Wait. I think there is an issue in the docs. It says that "Reprojucer.cmake requires CMake version 3.4 minimum." However, the latest version of cmake I can find is 3.25.1, See: https://cmake.org/download/

McMartin commented 1 year ago

Hi @JoseDiazRohena,

Thanks for using FRUT!

FRUT indeed requires CMake 3.4 (which was released in November 2015), or a later version. The last version of CMake (3.25.1 as you found out) should work fine, though I haven't tested personally.

Based on the CMake error you shared above, Reproducer.cmake is trying to convert the version of your project (1.0.0r1) into an integer, by splitting on periods and using bit shifting. Unfortunately, 0r1 is not a valid number that can be bit shifted.

Does Projucer really accept a project version like 1.0.0r1? If it does, then you found a bug in Reprojucer.cmake, since it should reproduce how Projucer works. I'll have a look on my side to see what Projucer's behavior is.

I hope this helps!

McMartin commented 1 year ago

It seems that Projucer is fine with non-integers values in the project version because it uses juce::String::getIntValue, which returns the first integer in the string and ignores anything afterwards. This means that 0r1 is treated like 0 and the math expression (that contains the bit shifting) works fine.

As I wrote above, you found a bug in Reprojucer.cmake. Thanks for finding it and opening that issue!

I'll take care of fixing it as soon as I can.

JoseDiazRohena commented 1 year ago

Ah! I'm glad to have helped 🫡.