diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3fc08c3492e503ee4bcf2bd798519441e603411a..d2d53d9cb4c80233995131989a1bef1a2cd28046 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,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)