diff --git a/recipe/0001-Do-not-override-CXXFLAGS-for-the-libraries.patch b/recipe/0001-Do-not-override-CXXFLAGS-for-the-libraries.patch
new file mode 100644
index 0000000..2f253de
--- /dev/null
+++ b/recipe/0001-Do-not-override-CXXFLAGS-for-the-libraries.patch
@@ -0,0 +1,35 @@
+From 315fc0a568b1066a83b1226ceeb59e783514baf8 Mon Sep 17 00:00:00 2001
+From: Isuru Fernando <isuruf@gmail.com>
+Date: Mon, 25 Mar 2024 14:02:11 -0500
+Subject: [PATCH] Do not override CXXFLAGS for the libraries
+
+---
+ CMakeLists.txt | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b06ac4575..a88f8114f 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -278,13 +278,16 @@ ENDIF (MSVC)
+ 
+ IF(OPENMM_BUILD_SHARED_LIB)
+     ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
+-    SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY" SOVERSION "${OPENMM_MAJOR_VERSION}.${OPENMM_MINOR_VERSION}")
++    SET_TARGET_PROPERTIES(${SHARED_TARGET} PROPERTIES SOVERSION "${OPENMM_MAJOR_VERSION}.${OPENMM_MINOR_VERSION}")
++    TARGET_LINK_OPTIONS(${SHARED_TARGET} "${EXTRA_LINK_FLAGS}")
++    TARGET_COMPILE_OPTIONS(${SHARED_TARGET} "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_SHARED_LIBRARY -DLEPTON_BUILDING_SHARED_LIBRARY -DPTHREAD_BUILDING_SHARED_LIBRARY")
+ ENDIF(OPENMM_BUILD_SHARED_LIB)
+ 
+ IF(OPENMM_BUILD_STATIC_LIB)
+     ADD_LIBRARY(${STATIC_TARGET} STATIC ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
+     SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_USE_STATIC_LIBRARIES -DLEPTON_USE_STATIC_LIBRARIES -DPTW32_STATIC_LIB")
+-    SET_TARGET_PROPERTIES(${STATIC_TARGET} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_BUILDING_STATIC_LIBRARY -DPTHREAD_BUILDING_STATIC_LIBRARY")
++    TARGET_LINK_OPTIONS(${SHARED_TARGET} "${EXTRA_LINK_FLAGS}")
++    TARGET_COMPILE_OPTIONS(${SHARED_TARGET} "${EXTRA_COMPILE_FLAGS} -DOPENMM_BUILDING_STATIC_LIBRARY -DLEPTON_BUILDING_STATIC_LIBRARY -DPTHREAD_BUILDING_STATIC_LIBRARY")
+ ENDIF(OPENMM_BUILD_STATIC_LIB)
+ 
+ IF(OPENMM_BUILD_C_AND_FORTRAN_WRAPPERS)
+-- 
+2.42.0
+
diff --git a/recipe/meta.yaml b/recipe/meta.yaml
index 6ef29f0..6365eea 100644
--- a/recipe/meta.yaml
+++ b/recipe/meta.yaml
@@ -19,6 +19,7 @@ source:
   git_rev: "ec797ac"
   patches:
     - 0001-wheels.patch
+    - 0001-Do-not-override-CXXFLAGS-for-the-libraries.patch
 
 build:
   number: {{ build }}