Define _USE_MATH_DEFINES everywhere that uses math constants

On Win32, things are failing to build with messages like:

RenderableEntityItem.cpp(674,51): error C2065: 'M_PI': undeclared identifier

This is because as per Microsoft documentation, _USE_MATH_DEFINES is needed to
obtain constants like M_PI:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-160

It seems this worked previously due to some quirk of CMake, but stopped working
after some reordering. This change makes this definition explicit where it is needed.
This commit is contained in:
Dale Glass 2021-07-17 19:34:26 +02:00
parent 276a0506bf
commit 32c3725b5d
6 changed files with 19 additions and 0 deletions

View file

@ -7,3 +7,7 @@ include_hifi_library_headers(hfm)
include_hifi_library_headers(image)
target_nsight()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -19,3 +19,6 @@ include_hifi_library_headers(graphics-scripting) # for Forward.h
target_bullet()
target_polyvox()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -9,3 +9,7 @@ include_hifi_library_headers(ktx)
include_hifi_library_headers(material-networking)
include_hifi_library_headers(procedural)
link_hifi_libraries(shared shaders networking octree avatars graphics model-networking)
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -11,3 +11,7 @@ if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED)
target_link_libraries(image Threads::Threads)
endif()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -16,3 +16,6 @@ if (NOT ANDROID)
target_nsight()
endif ()
if (WIN32)
add_compile_definitions(_USE_MATH_DEFINES)
endif()

View file

@ -7,6 +7,7 @@ setup_hifi_library(Gui Network Script)
if (WIN32)
target_link_libraries(${TARGET_NAME} Wbemuuid.lib)
add_compile_definitions(_USE_MATH_DEFINES)
endif()
if (ANDROID)