Skip to content

Commit

Permalink
Fixed missing _USE_MATH_DEFINES preprocessor definition
Browse files Browse the repository at this point in the history
When generating solution by multiple configure, then generate combo instead of single configure, generate combo or generate alone, _USE_MATH_DEFINES preprocessor definition is not populated.
Alternative solution is to add unset(HAVE_M_PI CACHE) in the else block just after add_definitions(-D_USE_MATH_DEFINES), but the proposed way avoids unnecessary checks each time the project is configured.
  • Loading branch information
wmamrak authored Apr 18, 2017
1 parent 600a6b6 commit 049c38e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ check_symbol_exists(M_PI math.h HAVE_M_PI)

if(NOT HAVE_M_PI)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_USE_MATH_DEFINES)
unset(HAVE_M_PI CACHE)

check_symbol_exists(M_PI math.h HAVE_M_PI)
check_symbol_exists(M_PI math.h HAVE_M_PI2)

if(NOT HAVE_M_PI)
if(NOT HAVE_M_PI2)
message(FATAL_ERROR "`M_PI` not defined in `math.h`.")
else()
add_definitions(-D_USE_MATH_DEFINES)
Expand Down

0 comments on commit 049c38e

Please sign in to comment.