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