diff --git a/storage/heap/CMakeLists.txt b/storage/heap/CMakeLists.txt
index 4ec40fe..b0ded18 100644
--- a/storage/heap/CMakeLists.txt
+++ b/storage/heap/CMakeLists.txt
@@ -24,12 +24,20 @@ SET(HEAP_SOURCES  _check.c _rectest.c hp_block.c hp_clear.c hp_close.c hp_create
 
 MYSQL_ADD_PLUGIN(heap ${HEAP_SOURCES} STORAGE_ENGINE MANDATORY RECOMPILE_FOR_EMBEDDED)
 
-IF(WITH_UNIT_TESTS AND WITH_EMBEDDED_SERVER)
+IF(WITH_EMBEDDED_SERVER)
+  SET(HEAP_NOPFS heap_embedded)
+ELSE()
+  ADD_CONVENIENCE_LIBRARY(heap_nopfs ${HEAP_SOURCES})
+  ADD_DEPENDENCIES(heap_nopfs GenError)
+  SET(HEAP_NOPFS heap_nopfs)
+ENDIF()
+
+IF(WITH_UNIT_TESTS)
   ADD_EXECUTABLE(hp_test1 hp_test1.c)
-  TARGET_LINK_LIBRARIES(hp_test1 heap_embedded mysys)
+  TARGET_LINK_LIBRARIES(hp_test1 ${HEAP_NOPFS} mysys)
   ADD_TEST(hp_test1 hp_test1)
 
   ADD_EXECUTABLE(hp_test2 hp_test2.c)
-  TARGET_LINK_LIBRARIES(hp_test2 heap_embedded mysys)
+  TARGET_LINK_LIBRARIES(hp_test2 ${HEAP_NOPFS} mysys)
   ADD_TEST(hp_test2 hp_test2)
 ENDIF()