diff --git a/.gitignore b/.gitignore index 378eac25d3..d5c72bc7a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ build +libmongoose.dylib +Makefile +MongooseConfig.cmake +CMakeFiles/cmake.check_cache +cmake_install.cmake +CMakeCache.txt +install_manifest.txt +CMakeFiles diff --git a/CMakeLists.txt b/CMakeLists.txt index 47c3b71fb6..bdd6243049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,8 @@ option (ENABLE_STATS option (ENABLE_REGEX_URL "Enable url regex matching dispatcher" OFF) -set (JSONCPP_DIR "${PROJECT_SOURCE_DIR}/../jsoncpp" - CACHE STRING "Json C++ directory") +option (SHAREDLIB + "Generate a shared library" OFF) set (SOURCES mongoose.c @@ -34,6 +34,7 @@ set (MONGOOSE_CPP "${PROJECT_SOURCE_DIR}/mongoose") include_directories ("${PROJECT_SOURCE_DIR}") + if (ENABLE_STATS) add_definitions("-DENABLE_STATS") endif (ENABLE_STATS) @@ -60,13 +61,19 @@ if (CPP_BINDING) ) if (HAS_JSONCPP) + IF(NOT JSONCPP_DIR) + message(STATUS "No path for jsonccp as been given") + set (JSONCPP_DIR "${PROJECT_SOURCE_DIR}/../jsoncpp") + ENDIF() + set (SOURCES ${SOURCES} ${MONGOOSE_CPP}/JsonResponse.cpp ${MONGOOSE_CPP}/JsonController.cpp ) - + message(STATUS "Using ${JSONCPP_DIR}/include and ${JSONCPP_DIR}/lib as jsoncpp path") include_directories ("${JSONCPP_DIR}/include/") + LINK_DIRECTORIES( ${LINK_DIRECTORIES} ${JSONCPP_DIR}/lib/) endif (HAS_JSONCPP) if (WEBSOCKET) @@ -95,11 +102,16 @@ if (WIN32) endif (WIN32) # Compiling library -add_library (mongoose ${SOURCES}) +if (SHAREDLIB) + add_library (mongoose SHARED ${SOURCES}) +else() + add_library (mongoose ${SOURCES}) +endif() + target_link_libraries (mongoose ${EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT}) if (HAS_JSONCPP) - target_link_libraries (mongoose json) + target_link_libraries (mongoose jsoncpp) endif (HAS_JSONCPP) if (EXAMPLES OR MAIN) @@ -113,7 +125,7 @@ if (MAIN) add_executable (main main.c) target_link_libraries (main mongoose) endif (MAIN) - + # Compiling tests if (EXAMPLES) add_executable (post examples/post.c)