diff --git a/Code/Mantid/Framework/CMakeLists.txt b/Code/Mantid/Framework/CMakeLists.txt
index c5aed23208c0c14634e01aa47517771bfa2fa3a4..c6f62086c85db59ce2824d907c329207ebaff999 100644
--- a/Code/Mantid/Framework/CMakeLists.txt
+++ b/Code/Mantid/Framework/CMakeLists.txt
@@ -44,8 +44,8 @@ configure_file ( ${PROJECT_SOURCE_DIR}/${HEADER_DIR}/MantidVersion.h.in
 set ( USE_TCMALLOC ON CACHE BOOL "Flag for replacing regular malloc with tcmalloc" )
 # Note that this is not mandatory, so no REQUIRED
 find_package ( Tcmalloc )
-# If not found, just carry on without it
-if ( TCMALLOC_FOUND )
+# If not found, or not wanted, just carry on without it
+if ( USE_TCMALLOC AND TCMALLOC_FOUND )
   set ( TCMALLOC_LIBRARY ${TCMALLOC_LIBRARIES} )
 endif ()