-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Description
I have initialized a C project "foobar" and made the following changes:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e4e720..ea04ae4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,8 @@ target_include_directories(
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/export>"
)
+target_link_libraries(foobar_foobar PRIVATE m)
+
target_compile_features(foobar_foobar PUBLIC c_std_11)
# ---- Install rules ----
diff --git a/source/foobar.c b/source/foobar.c
index 362d5fe..c0bf09d 100644
--- a/source/foobar.c
+++ b/source/foobar.c
@@ -1,6 +1,8 @@
#include "foobar/foobar.h"
+#define _USE_MATH_DEFINE
+#include <math.h>
const char* exported_function()
{
- return "foobar";
+ return M_PI < 3. ? "foobar" : "palim";
}
Obviously, my attempt is to link libm to the project but running
> cmake --preset=dev-unix
> cmake --build build/dev-unix
fails:
foobar/source/foobar.c:6:10: error: ‘M_PI’ undeclared (first use in this function)
6 | return M_PI < 3. ? "foobar" : "palim";
|
Could you help me to fix this problem?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels