Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MongoDB library will be used only if exists

  • Loading branch information...
commit 6f36f9bd2c5bd9db20f838c1f75b50dd4b95bf84 1 parent 711b958
@Inkvi Inkvi authored
View
2  CMakeLists.txt
@@ -3,6 +3,8 @@ PROJECT(Cocaine)
SET(COCAINE_VERSION 0.7)
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
+
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/config.hpp.in"
"${PROJECT_SOURCE_DIR}/include/cocaine/config.hpp")
View
59 cmake/Modules/FindMongoDB.cmake
@@ -0,0 +1,59 @@
+# - Find MongoDB
+# Find the MongoDB includes and client library
+# This module defines
+# MongoDB_INCLUDE_DIR, where to find mongo/client/dbclient.h
+# MongoDB_LIBRARIES, the libraries needed to use MongoDB.
+# MongoDB_FOUND, If false, do not try to use MongoDB.
+
+if(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
+ set(MongoDB_FOUND TRUE)
+
+else(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
+
+ find_path(MongoDB_INCLUDE_DIR mongo/client/dbclient.h
+ /usr/include/
+ /usr/local/include/
+ /usr/include/mongo/
+ /usr/local/include/mongo/
+ /opt/mongo/include/
+ $ENV{ProgramFiles}/Mongo/*/include
+ $ENV{SystemDrive}/Mongo/*/include
+ )
+
+if(WIN32)
+ find_library(MongoDB_LIBRARIES NAMES mongoclient
+ PATHS
+ $ENV{ProgramFiles}/Mongo/*/lib
+ $ENV{SystemDrive}/Mongo/*/lib
+ )
+else(WIN32)
+ find_library(MongoDB_LIBRARIES NAMES mongoclient
+ PATHS
+ /usr/lib
+ /usr/lib64
+ /usr/lib/mongo
+ /usr/lib64/mongo
+ /usr/local/lib
+ /usr/local/lib64
+ /usr/local/lib/mongo
+ /usr/local/lib64/mongo
+ /opt/mongo/lib
+ /opt/mongo/lib64
+ )
+endif(WIN32)
+
+ if(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
+ set(MongoDB_FOUND TRUE)
+ message(STATUS "Found MongoDB: ${MongoDB_INCLUDE_DIR}, ${MongoDB_LIBRARIES}")
+ else(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
+ set(MongoDB_FOUND FALSE)
+ if (MongoDB_FIND_REQUIRED)
+ message(FATAL_ERROR "MongoDB not found.")
+ else (MongoDB_FIND_REQUIRED)
+ message(STATUS "MongoDB not found.")
+ endif (MongoDB_FIND_REQUIRED)
+ endif(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
+
+ mark_as_advanced(MongoDB_INCLUDE_DIR MongoDB_LIBRARIES)
+
+endif(MongoDB_INCLUDE_DIR AND MongoDB_LIBRARIES)
View
30 modules/mongo/CMakeLists.txt
@@ -1,17 +1,21 @@
-LOCATE_LIBRARY(LIBMONGOCLIENT "dbclient.h" "mongoclient" "mongo" "mongo/client")
+find_package (MongoDB)
-ADD_LIBRARY(mongodb MODULE
- mongo)
+IF (MongoDB_FOUND)
+ LOCATE_LIBRARY(LIBMONGOCLIENT "dbclient.h" "mongoclient" "mongo" "mongo/client")
-TARGET_LINK_LIBRARIES(mongodb
- cocaine-common
- boost_thread-mt
- mongoclient)
+ ADD_LIBRARY(mongodb MODULE
+ mongo)
-SET_TARGET_PROPERTIES(mongodb PROPERTIES
- PREFIX ""
- SUFFIX ".cocaine-module")
+ TARGET_LINK_LIBRARIES(mongodb
+ cocaine-common
+ boost_thread-mt
+ mongoclient)
-INSTALL(TARGETS mongodb
- LIBRARY DESTINATION lib/cocaine
- COMPONENT runtime)
+ SET_TARGET_PROPERTIES(mongodb PROPERTIES
+ PREFIX ""
+ SUFFIX ".cocaine-module")
+
+ INSTALL(TARGETS mongodb
+ LIBRARY DESTINATION lib/cocaine
+ COMPONENT runtime)
+ENDIF()
Please sign in to comment.
Something went wrong with that request. Please try again.