From 9765d6e866ca8721eb389b3719c878db662be1f2 Mon Sep 17 00:00:00 2001 From: Jerome Hue <jerome.hue@cea.fr> Date: Fri, 21 Mar 2025 16:02:51 +0100 Subject: [PATCH] Only define _USE_MATH_DEFINES on Windows platforms The _USE_MATH_DEFINES macro is only needed on Windows to expose math constants like M_PI in math.h/cmath. --- CMakeLists.txt | 4 +++- unit_tests/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c5c6b9..6c87a89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,9 @@ target_link_libraries(${module_name} ) # Add definition _USE_MATH_DEFINES to enable math constant definitions from math.h/cmath. -target_compile_definitions(${module_name} PRIVATE _USE_MATH_DEFINES) +if (WIN32) + target_compile_definitions(${module_name} PRIVATE _USE_MATH_DEFINES) +endif() #Set target properties set_property(TARGET ${module_name} PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 571c96b9..217cf8fb 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -21,7 +21,9 @@ file(GLOB_RECURSE src_files "*.cpp") add_executable(tests${module_name} ${src_files}) -target_compile_definitions(tests${module_name} PRIVATE _USE_MATH_DEFINES) +if (WIN32) + target_compile_definitions(tests${module_name} PRIVATE _USE_MATH_DEFINES) +endif() target_link_libraries(tests${module_name} PRIVATE ${module_name}) -- GitLab