asmaloney / GDExtensionTemplate

📜 A template project for building Godot 4 GDExtensions using CMake
The Unlicense
233 stars 21 forks source link

Setting FLOAT_PRECISION properly #55

Open BrianWiz opened 1 year ago

BrianWiz commented 1 year ago

I'm new to CMake so I'm not entirely sure if this is the best solution, I was running into issues with real_t not being set correctly on my project.

I fixed it by putting this in the main CMakeLists.txt and then using the following env when using cmake -B: -DFLOAT_PRECISION=double

if ("${FLOAT_PRECISION}" STREQUAL "double")
    add_definitions(-DREAL_T_IS_DOUBLE)
endif()

Thanks so much for this project, it's been massively helpful.

asmaloney commented 1 year ago

Thanks Brian! Good catch - I've never used the doubles version of Godot, so it hadn't occurred to me.

I'll take a look and add something for this in my next release.

asmaloney commented 1 year ago

I submitted a fix to godot-cpp to resolve this.

https://github.com/godotengine/godot-cpp/pull/1145

The correct solution is to add the define to the godot-cpp target using public target_compile_definitions. Then when that target is used, the define will come along for the ride...