comparison OrthancFramework/Resources/CMake/MongooseConfiguration.cmake @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/CMake/MongooseConfiguration.cmake@0c2a8d5e0097
children 05b8fd21089c
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 if (STATIC_BUILD OR NOT USE_SYSTEM_MONGOOSE)
2 SET(MONGOOSE_SOURCES_DIR ${CMAKE_BINARY_DIR}/mongoose)
3
4 if (IS_DIRECTORY "${MONGOOSE_SOURCES_DIR}")
5 set(FirstRun OFF)
6 else()
7 set(FirstRun ON)
8 endif()
9
10 if (0)
11 # Use Mongoose 3.1
12 DownloadPackage(
13 "e718fc287b4eb1bd523be3fa00942bb0"
14 "http://orthanc.osimis.io/ThirdPartyDownloads/mongoose-3.1.tgz"
15 "${MONGOOSE_SOURCES_DIR}")
16
17 add_definitions(-DMONGOOSE_USE_CALLBACKS=0)
18 set(MONGOOSE_PATCH ${ORTHANC_ROOT}/Resources/Patches/mongoose-3.1-patch.diff)
19
20 else()
21 # Use Mongoose 3.8
22 DownloadPackage(
23 "7e3296295072792cdc3c633f9404e0c3"
24 "http://orthanc.osimis.io/ThirdPartyDownloads/mongoose-3.8.tgz"
25 "${MONGOOSE_SOURCES_DIR}")
26
27 add_definitions(-DMONGOOSE_USE_CALLBACKS=1)
28 set(MONGOOSE_PATCH ${ORTHANC_ROOT}/Resources/Patches/mongoose-3.8-patch.diff)
29 endif()
30
31 # Patch mongoose
32 execute_process(
33 COMMAND ${PATCH_EXECUTABLE} -N mongoose.c
34 INPUT_FILE ${MONGOOSE_PATCH}
35 WORKING_DIRECTORY ${MONGOOSE_SOURCES_DIR}
36 RESULT_VARIABLE Failure
37 )
38
39 if (Failure AND FirstRun)
40 message(FATAL_ERROR "Error while patching a file")
41 endif()
42
43 include_directories(
44 ${MONGOOSE_SOURCES_DIR}
45 )
46
47 set(MONGOOSE_SOURCES
48 ${MONGOOSE_SOURCES_DIR}/mongoose.c
49 )
50
51
52 if (ENABLE_SSL)
53 add_definitions(
54 -DNO_SSL_DL=1
55 )
56 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
57 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
58 link_libraries(dl)
59 endif()
60
61 else()
62 add_definitions(
63 -DNO_SSL=1 # Remove SSL support from mongoose
64 )
65 endif()
66
67
68 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
69 if (CMAKE_COMPILER_IS_GNUCXX)
70 # This is a patch for MinGW64
71 add_definitions(-D_TIMESPEC_DEFINED=1)
72 endif()
73 endif()
74
75 source_group(ThirdParty\\Mongoose REGULAR_EXPRESSION ${MONGOOSE_SOURCES_DIR}/.*)
76
77 else()
78 CHECK_INCLUDE_FILE_CXX(mongoose.h HAVE_MONGOOSE_H)
79 if (NOT HAVE_MONGOOSE_H)
80 message(FATAL_ERROR "Please install the mongoose-devel package")
81 endif()
82
83 CHECK_LIBRARY_EXISTS(mongoose mg_start "" HAVE_MONGOOSE_LIB)
84 if (NOT HAVE_MONGOOSE_LIB)
85 message(FATAL_ERROR "Please install the mongoose-devel package")
86 endif()
87
88 if (SYSTEM_MONGOOSE_USE_CALLBACKS)
89 add_definitions(-DMONGOOSE_USE_CALLBACKS=1)
90 else()
91 add_definitions(-DMONGOOSE_USE_CALLBACKS=0)
92 endif()
93
94 link_libraries(mongoose)
95 endif()