Skip to content

How to link additional libraries #71

Answered by friendlyanon
avitase asked this question in Q&A
Discussion options

You must be logged in to vote

M_PI is a non-standard feature of some C standard libraries. On Windows for example, _USE_MATH_DEFINES is how you enable this extension: https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-170

On GNU systems the same can be done with _XOPEN_SOURCE: https://man7.org/linux/man-pages/man7/feature_test_macros.7.html#:~:text=the%20man%20pages.-,_XOPEN_SOURCE,-Defining%20this%20macro

I recommend not relying to non-standard extensions if not necessary.

Regarding libm, it's a Linux-only thing and I'm not totally certain how it could be best handled. Maybe something along the lines of:

if(CMAKE_SYSTEM_NAME MATCHES Linux) # probably right?
  include(CheckLibraryExists)
 …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@avitase
Comment options

@friendlyanon
Comment options

Answer selected by avitase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #70 on August 19, 2022 17:03.