diff --git a/CMakeLists.txt b/CMakeLists.txt
index bcae9a92b3f9efad28b247bbebb6c3f036c56475..d19cf21574321e6e73905b1574e5e1ea8806ccaf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,7 +61,7 @@ target_link_libraries(opusfile
   PUBLIC
     Ogg::ogg
     Opus::opus
-    $<$<BOOL:OP_HAVE_LIBM>:m>
+    $<$<BOOL:${OP_HAVE_LIBM}>:m>
 )
 target_compile_options(opusfile
   PRIVATE
@@ -167,7 +167,7 @@ if(NOT OP_DISABLE_HTTP)
       OpenSSL::SSL
       $<$<C_COMPILER_ID:MSVC>:ws2_32>
       $<$<C_COMPILER_ID:MSVC>:crypt32>
-      $<$<BOOL:OP_HAVE_LIBM>:m>
+      $<$<BOOL:${OP_HAVE_LIBM}>:m>
   )
   target_compile_options(opusurl
     PRIVATE