comparison CMakeLists.txt @ 827:3d6f9b7d0add

precompiled headers in unit tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Jun 2014 11:49:09 +0200
parents f2509d3624f6
children 6c6e3c18799c
comparison
equal deleted inserted replaced
826:f2509d3624f6 827:3d6f9b7d0add
144 OrthancServer/OrthancFindRequestHandler.cpp 144 OrthancServer/OrthancFindRequestHandler.cpp
145 OrthancServer/OrthancMoveRequestHandler.cpp 145 OrthancServer/OrthancMoveRequestHandler.cpp
146 ) 146 )
147 147
148 148
149 149 set(ORTHANC_UNIT_TESTS_SOURCES
150 #####################################################################
151 ## Inclusion of third-party dependencies
152 #####################################################################
153
154 # Configuration of the standalone builds
155 if (CMAKE_CROSSCOMPILING)
156 # Cross-compilation implies the standalone build
157 SET(STANDALONE_BUILD ON)
158 endif()
159
160 # Prepare the third-party dependencies
161 SET(THIRD_PARTY_SOURCES
162 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
163 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
164 )
165
166 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake)
167 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
168 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
169 include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
170 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
171 include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
172 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
173 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
174 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
175 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
176
177
178 if (${ENABLE_SSL})
179 add_definitions(-DORTHANC_SSL_ENABLED=1)
180 include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
181 else()
182 add_definitions(-DORTHANC_SSL_ENABLED=0)
183 endif()
184
185
186
187 #####################################################################
188 ## Autogeneration of files
189 #####################################################################
190
191 # Prepare the embedded files
192 set(EMBEDDED_FILES
193 PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql
194 UPGRADE_DATABASE_3_TO_4 ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/Upgrade3To4.sql
195 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json
196 LUA_TOOLBOX ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Toolbox.lua
197 )
198
199 if (${STANDALONE_BUILD})
200 # We embed all the resources in the binaries for standalone builds
201 add_definitions(-DORTHANC_STANDALONE=1)
202 EmbedResources(
203 ${EMBEDDED_FILES}
204 ORTHANC_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/OrthancExplorer
205 ${DCMTK_DICTIONARIES}
206 )
207 else()
208 add_definitions(
209 -DORTHANC_STANDALONE=0
210 -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\"
211 )
212 EmbedResources(
213 ${EMBEDDED_FILES}
214 )
215 endif()
216
217
218
219 #####################################################################
220 ## Build the core of Orthanc
221 #####################################################################
222
223 # Setup precompiled headers for Microsoft Visual Studio
224 if (${MSVC})
225 set(ORTHANC_SOURCES ${ORTHANC_CORE_SOURCES} ${ORTHANC_SERVER_SOURCES})
226 ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS("PrecompiledHeaders.h" "Core/PrecompiledHeaders.cpp" ORTHANC_SOURCES)
227 list(APPEND ORTHANC_CORE_SOURCES "Core/PrecompiledHeaders.cpp")
228 endif()
229
230
231 add_definitions(
232 -DORTHANC_VERSION="${ORTHANC_VERSION}"
233 )
234
235 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
236 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
237 add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
238 endif()
239
240 add_library(CoreLibrary
241 STATIC
242 ${AUTOGENERATED_SOURCES}
243 ${THIRD_PARTY_SOURCES}
244 ${CURL_SOURCES}
245 ${ORTHANC_CORE_SOURCES}
246 )
247
248
249 #####################################################################
250 ## Build the Orthanc server
251 #####################################################################
252
253 add_library(ServerLibrary
254 STATIC
255 ${DCMTK_SOURCES}
256 ${ORTHANC_SERVER_SOURCES}
257 )
258
259 # Ensure autogenerated code is built before building ServerLibrary
260 add_dependencies(ServerLibrary CoreLibrary)
261
262 add_executable(Orthanc
263 OrthancServer/main.cpp
264 )
265
266 target_link_libraries(Orthanc ServerLibrary CoreLibrary)
267
268 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
269 target_link_libraries(Orthanc OpenSSL)
270 endif()
271
272 install(
273 TARGETS Orthanc
274 RUNTIME DESTINATION sbin
275 )
276
277
278
279 #####################################################################
280 ## Build the unit tests
281 #####################################################################
282
283 if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
284 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
285 else()
286 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=0)
287 endif()
288
289 add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1)
290 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
291 add_executable(UnitTests
292 ${GTEST_SOURCES}
293 UnitTestsSources/DicomMap.cpp 150 UnitTestsSources/DicomMap.cpp
294 UnitTestsSources/FileStorage.cpp 151 UnitTestsSources/FileStorage.cpp
295 UnitTestsSources/FromDcmtk.cpp 152 UnitTestsSources/FromDcmtk.cpp
296 UnitTestsSources/MemoryCache.cpp 153 UnitTestsSources/MemoryCache.cpp
297 UnitTestsSources/Png.cpp 154 UnitTestsSources/Png.cpp
302 UnitTestsSources/Versions.cpp 159 UnitTestsSources/Versions.cpp
303 UnitTestsSources/Zip.cpp 160 UnitTestsSources/Zip.cpp
304 UnitTestsSources/Lua.cpp 161 UnitTestsSources/Lua.cpp
305 UnitTestsSources/MultiThreading.cpp 162 UnitTestsSources/MultiThreading.cpp
306 UnitTestsSources/UnitTestsMain.cpp 163 UnitTestsSources/UnitTestsMain.cpp
164 )
165
166
167
168 #####################################################################
169 ## Inclusion of third-party dependencies
170 #####################################################################
171
172 # Configuration of the standalone builds
173 if (CMAKE_CROSSCOMPILING)
174 # Cross-compilation implies the standalone build
175 SET(STANDALONE_BUILD ON)
176 endif()
177
178 # Prepare the third-party dependencies
179 SET(THIRD_PARTY_SOURCES
180 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c
181 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp
182 )
183
184 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleLogConfiguration.cmake)
185 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
186 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
187 include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
188 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
189 include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
190 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
191 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
192 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
193 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
194
195
196 if (${ENABLE_SSL})
197 add_definitions(-DORTHANC_SSL_ENABLED=1)
198 include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake)
199 else()
200 add_definitions(-DORTHANC_SSL_ENABLED=0)
201 endif()
202
203
204
205 #####################################################################
206 ## Autogeneration of files
207 #####################################################################
208
209 # Prepare the embedded files
210 set(EMBEDDED_FILES
211 PREPARE_DATABASE ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/PrepareDatabase.sql
212 UPGRADE_DATABASE_3_TO_4 ${CMAKE_CURRENT_SOURCE_DIR}/OrthancServer/Upgrade3To4.sql
213 CONFIGURATION_SAMPLE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Configuration.json
214 LUA_TOOLBOX ${CMAKE_CURRENT_SOURCE_DIR}/Resources/Toolbox.lua
215 )
216
217 if (${STANDALONE_BUILD})
218 # We embed all the resources in the binaries for standalone builds
219 add_definitions(-DORTHANC_STANDALONE=1)
220 EmbedResources(
221 ${EMBEDDED_FILES}
222 ORTHANC_EXPLORER ${CMAKE_CURRENT_SOURCE_DIR}/OrthancExplorer
223 ${DCMTK_DICTIONARIES}
224 )
225 else()
226 add_definitions(
227 -DORTHANC_STANDALONE=0
228 -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\"
229 )
230 EmbedResources(
231 ${EMBEDDED_FILES}
232 )
233 endif()
234
235
236
237 #####################################################################
238 ## Build the core of Orthanc
239 #####################################################################
240
241 # Setup precompiled headers for Microsoft Visual Studio
242 if (${MSVC})
243 set(ORTHANC_SOURCES
244 ${ORTHANC_CORE_SOURCES}
245 ${ORTHANC_SERVER_SOURCES}
246 ${ORTHANC_UNIT_TESTS_SOURCES}
247 )
248 ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS("PrecompiledHeaders.h" "Core/PrecompiledHeaders.cpp" ORTHANC_SOURCES)
249 list(APPEND ORTHANC_CORE_SOURCES "Core/PrecompiledHeaders.cpp")
250 endif()
251
252
253 add_definitions(
254 -DORTHANC_VERSION="${ORTHANC_VERSION}"
255 )
256
257 list(LENGTH OPENSSL_SOURCES OPENSSL_SOURCES_LENGTH)
258 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
259 add_library(OpenSSL STATIC ${OPENSSL_SOURCES})
260 endif()
261
262 add_library(CoreLibrary
263 STATIC
264 ${AUTOGENERATED_SOURCES}
265 ${THIRD_PARTY_SOURCES}
266 ${CURL_SOURCES}
267 ${ORTHANC_CORE_SOURCES}
268 )
269
270
271 #####################################################################
272 ## Build the Orthanc server
273 #####################################################################
274
275 add_library(ServerLibrary
276 STATIC
277 ${DCMTK_SOURCES}
278 ${ORTHANC_SERVER_SOURCES}
279 )
280
281 # Ensure autogenerated code is built before building ServerLibrary
282 add_dependencies(ServerLibrary CoreLibrary)
283
284 add_executable(Orthanc
285 OrthancServer/main.cpp
286 )
287
288 target_link_libraries(Orthanc ServerLibrary CoreLibrary)
289
290 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
291 target_link_libraries(Orthanc OpenSSL)
292 endif()
293
294 install(
295 TARGETS Orthanc
296 RUNTIME DESTINATION sbin
297 )
298
299
300
301 #####################################################################
302 ## Build the unit tests
303 #####################################################################
304
305 if (UNIT_TESTS_WITH_HTTP_CONNEXIONS)
306 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=1)
307 else()
308 add_definitions(-DUNIT_TESTS_WITH_HTTP_CONNEXIONS=0)
309 endif()
310
311 add_definitions(-DORTHANC_BUILD_UNIT_TESTS=1)
312 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
313 add_executable(UnitTests
314 ${GTEST_SOURCES}
315 ${ORTHANC_UNIT_TESTS_SOURCES}
307 ) 316 )
308 target_link_libraries(UnitTests ServerLibrary CoreLibrary) 317 target_link_libraries(UnitTests ServerLibrary CoreLibrary)
309 318
310 if (${OPENSSL_SOURCES_LENGTH} GREATER 0) 319 if (${OPENSSL_SOURCES_LENGTH} GREATER 0)
311 target_link_libraries(UnitTests OpenSSL) 320 target_link_libraries(UnitTests OpenSSL)