12
|
1 cmake_minimum_required(VERSION 2.8)
|
|
2
|
|
3 project(Palantir)
|
|
4 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
|
|
5 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
|
|
6 include(CheckIncludeFiles)
|
|
7
|
|
8 SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
|
19
|
9 SET(STANDALONE_BUILD OFF CACHE BOOL "Standalone build (necessary for cross-compilation or binary releases)")
|
23
|
10 SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL")
|
12
|
11
|
19
|
12 if (${CMAKE_CROSSCOMPILING})
|
|
13 SET(STANDALONE_BUILD ON)
|
|
14 endif()
|
|
15
|
|
16 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
12
|
17 CHECK_INCLUDE_FILES(rpc.h HAVE_UUID_H)
|
|
18 else()
|
|
19 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H)
|
|
20 endif()
|
|
21
|
|
22 if ("${HAVE_UUID_H}" STREQUAL "")
|
|
23 message(FATAL_ERROR "Please install the uuid-dev package")
|
|
24 endif()
|
|
25
|
|
26
|
22
|
27 SET(THIRD_PARTY_SOURCES
|
|
28 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
|
24
|
29 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
|
22
|
30 )
|
26
|
31
|
12
|
32 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
|
|
33 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
|
|
34 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
|
|
35 include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
|
|
36 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
|
|
37 include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
|
|
38 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
|
|
39 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
|
|
40 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
|
|
41
|
26
|
42 if (${ENABLE_SSL})
|
|
43 include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
|
|
44 endif()
|
|
45
|
12
|
46
|
|
47 if (${CMAKE_COMPILER_IS_GNUCXX})
|
26
|
48 set(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-implicit-function-declaration")
|
|
49 # --std=c99 makes libcurl not to compile
|
|
50 # -pedantic gives a lot of warnings on OpenSSL
|
12
|
51 set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wno-long-long -Wno-variadic-macros")
|
|
52 elseif (${MSVC})
|
|
53 # http://stackoverflow.com/a/6510446
|
|
54 foreach(flag_var
|
|
55 CMAKE_C_FLAGS_DEBUG
|
|
56 CMAKE_CXX_FLAGS_DEBUG
|
|
57 CMAKE_C_FLAGS_RELEASE
|
|
58 CMAKE_CXX_FLAGS_RELEASE
|
|
59 CMAKE_C_FLAGS_MINSIZEREL
|
|
60 CMAKE_CXX_FLAGS_MINSIZEREL
|
|
61 CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
62 CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
63 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
64 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
|
|
65 endforeach(flag_var)
|
|
66 add_definitions(
|
|
67 -D_CRT_SECURE_NO_WARNINGS=1
|
|
68 -D_CRT_SECURE_NO_DEPRECATE=1
|
|
69 )
|
|
70 include_directories(${CMAKE_SOURCE_DIR}/Resources/VisualStudio)
|
|
71 link_libraries(netapi32)
|
|
72 endif()
|
|
73
|
|
74
|
|
75 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
76 add_definitions(
|
|
77 -D_LARGEFILE64_SOURCE=1
|
|
78 -D_FILE_OFFSET_BITS=64
|
|
79 )
|
|
80 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
|
|
81 set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined")
|
|
82 set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
|
|
83
|
|
84 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html
|
|
85 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
|
86 link_libraries(uuid pthread rt)
|
|
87
|
|
88 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
89 add_definitions(
|
|
90 -DWINVER=0x0501
|
|
91 -D_CRT_SECURE_NO_WARNINGS=1
|
|
92 )
|
|
93 link_libraries(rpcrt4 ws2_32)
|
|
94 endif()
|
|
95
|
|
96
|
|
97 if (${STATIC_BUILD})
|
|
98 add_definitions(-DPALANTIR_STATIC=1)
|
|
99 else()
|
|
100 add_definitions(-DPALANTIR_STATIC=0)
|
|
101 endif()
|
|
102
|
19
|
103 if (${STANDALONE_BUILD})
|
12
|
104 add_definitions(
|
19
|
105 -DPALANTIR_STANDALONE=1
|
12
|
106 )
|
|
107
|
|
108 EmbedResources(
|
|
109 PREPARE_DATABASE PalantirServer/PrepareDatabase.sql
|
|
110 PALANTIR_EXPLORER PalantirExplorer
|
|
111 )
|
|
112
|
|
113 else()
|
|
114 add_definitions(
|
19
|
115 -DPALANTIR_STANDALONE=0
|
12
|
116 -DPALANTIR_PATH=\"${CMAKE_SOURCE_DIR}\"
|
|
117 )
|
|
118
|
|
119 EmbedResources(
|
|
120 PREPARE_DATABASE PalantirServer/PrepareDatabase.sql
|
|
121 )
|
|
122 endif()
|
|
123
|
|
124
|
|
125 add_library(CoreLibrary
|
|
126 STATIC
|
|
127 ${AUTOGENERATED_SOURCES}
|
|
128 ${THIRD_PARTY_SOURCES}
|
|
129
|
|
130 Core/ChunkedBuffer.cpp
|
|
131 Core/Compression/BufferCompressor.cpp
|
|
132 Core/Compression/ZlibCompressor.cpp
|
|
133 Core/PalantirException.cpp
|
|
134 Core/DicomFormat/DicomArray.cpp
|
|
135 Core/DicomFormat/DicomMap.cpp
|
|
136 Core/DicomFormat/DicomTag.cpp
|
|
137 Core/FileStorage.cpp
|
|
138 Core/HttpServer/EmbeddedResourceHttpHandler.cpp
|
|
139 Core/HttpServer/FilesystemHttpHandler.cpp
|
|
140 Core/HttpServer/HttpHandler.cpp
|
|
141 Core/HttpServer/HttpOutput.cpp
|
|
142 Core/HttpServer/MongooseServer.cpp
|
|
143 Core/MultiThreading/BagOfRunnablesBySteps.cpp
|
|
144 Core/PngWriter.cpp
|
|
145 Core/SQLite/Connection.cpp
|
|
146 Core/SQLite/FunctionContext.cpp
|
|
147 Core/SQLite/Statement.cpp
|
|
148 Core/SQLite/StatementId.cpp
|
|
149 Core/SQLite/StatementReference.cpp
|
|
150 Core/SQLite/Transaction.cpp
|
|
151 Core/Toolbox.cpp
|
|
152 Core/Uuid.cpp
|
|
153
|
|
154 PalantirCppClient/HttpClient.cpp
|
|
155 PalantirCppClient/HttpException.cpp
|
|
156 )
|
|
157
|
|
158 add_library(ServerLibrary
|
|
159 PalantirServer/DicomIntegerPixelAccessor.cpp
|
|
160 PalantirServer/DicomProtocol/DicomFindAnswers.cpp
|
|
161 PalantirServer/DicomProtocol/DicomServer.cpp
|
|
162 PalantirServer/DicomProtocol/DicomUserConnection.cpp
|
|
163 PalantirServer/FromDcmtkBridge.cpp
|
|
164 PalantirServer/Internals/CommandDispatcher.cpp
|
|
165 PalantirServer/Internals/FindScp.cpp
|
|
166 PalantirServer/Internals/MoveScp.cpp
|
|
167 PalantirServer/Internals/StoreScp.cpp
|
|
168 PalantirServer/PalantirInitialization.cpp
|
|
169 PalantirServer/PalantirRestApi.cpp
|
|
170 PalantirServer/ServerIndex.cpp
|
|
171 PalantirServer/ToDcmtkBridge.cpp
|
|
172 PalantirServer/ToDcmtkBridge.cpp
|
|
173 PalantirServer/DicomIntegerPixelAccessor.cpp
|
|
174 )
|
|
175
|
|
176 # Ensure autogenerated code is built before building ServerLibrary
|
|
177 add_dependencies(ServerLibrary CoreLibrary)
|
|
178
|
|
179 add_executable(Palantir
|
|
180 PalantirServer/main.cpp
|
|
181 )
|
|
182
|
|
183 add_executable(UnitTests
|
|
184 ${GTEST_SOURCES}
|
|
185 UnitTests/main.cpp
|
|
186 UnitTests/SQLite.cpp
|
|
187 UnitTests/SQLiteChromium.cpp
|
|
188 UnitTests/Versions.cpp
|
|
189 )
|
|
190
|
|
191 TARGET_LINK_LIBRARIES(Palantir ServerLibrary CoreLibrary)
|
|
192 TARGET_LINK_LIBRARIES(UnitTests ServerLibrary CoreLibrary)
|
|
193
|
|
194 find_package(Doxygen)
|
|
195 if (DOXYGEN_FOUND)
|
|
196 configure_file(
|
|
197 ${CMAKE_SOURCE_DIR}/Resources/Palantir.doxygen
|
|
198 ${CMAKE_CURRENT_BINARY_DIR}/Palantir.doxygen
|
|
199 @ONLY)
|
|
200 add_custom_target(doc
|
|
201 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Palantir.doxygen
|
|
202 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
203 COMMENT "Generating API documentation with Doxygen" VERBATIM
|
|
204 )
|
|
205 endif(DOXYGEN_FOUND)
|