diff --git a/CMakeLists.txt b/CMakeLists.txt
index 676b7e0d67b37a862b6716f57668c9d86f1cf476..145e703686891fc64b11d12d78e95146296a3c3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ endif ()
 search_for_boost()
 # Optional dependencies
 add_optional_dependency("octomap >= 1.6")
-if (OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS)
+if (OCTOMAP_FOUND)
   include_directories(SYSTEM ${OCTOMAP_INCLUDE_DIRS})
   link_directories(${OCTOMAP_LIBRARY_DIRS})
   SET(HPP_FCL_HAVE_OCTOMAP TRUE)