Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/compilation jsoncpp path #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
build
libmongoose.dylib
Makefile
MongooseConfig.cmake
CMakeFiles/cmake.check_cache
cmake_install.cmake
CMakeCache.txt
install_manifest.txt
CMakeFiles
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -60,13 +61,19 @@ if (CPP_BINDING)
)

if (HAS_JSONCPP)
IF(NOT JSONCPP_DIR)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you do this test? You removed the set above

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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down