Mercurial > hg > orthanc
annotate CMakeLists.txt @ 101:428784e59dcd
trying to use log4cplus
author | jodogne |
---|---|
date | Wed, 03 Oct 2012 11:44:46 +0200 |
parents | 27dc762e3dc8 |
children | 7593b57dc1bf |
rev | line source |
---|---|
12 | 1 cmake_minimum_required(VERSION 2.8) |
2 | |
57 | 3 project(Orthanc) |
12 | 4 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake) |
5 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake) | |
6 include(CheckIncludeFiles) | |
101 | 7 include(CheckIncludeFileCXX) |
12 | 8 |
9 SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)") | |
19 | 10 SET(STANDALONE_BUILD OFF CACHE BOOL "Standalone build (necessary for cross-compilation or binary releases)") |
23 | 11 SET(ENABLE_SSL ON CACHE BOOL "Include support for SSL") |
97 | 12 SET(DEBIAN_HARDENING OFF CACHE BOOL "Use Debian hardening flags") |
12 | 13 |
19 | 14 if (${CMAKE_CROSSCOMPILING}) |
15 SET(STANDALONE_BUILD ON) | |
16 endif() | |
17 | |
18 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
12 | 19 CHECK_INCLUDE_FILES(rpc.h HAVE_UUID_H) |
20 else() | |
21 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | |
22 endif() | |
23 | |
101 | 24 if (NOT HAVE_UUID_H) |
12 | 25 message(FATAL_ERROR "Please install the uuid-dev package") |
26 endif() | |
27 | |
28 | |
22 | 29 SET(THIRD_PARTY_SOURCES |
30 ${CMAKE_SOURCE_DIR}/Resources/md5/md5.c | |
24 | 31 ${CMAKE_SOURCE_DIR}/Resources/base64/base64.cpp |
22 | 32 ) |
26 | 33 |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
34 if (${ENABLE_SSL}) |
57 | 35 add_definitions(-DORTHANC_SSL_ENABLED=1) |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
36 include(${CMAKE_SOURCE_DIR}/Resources/CMake/OpenSslConfiguration.cmake) |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
37 else() |
57 | 38 add_definitions(-DORTHANC_SSL_ENABLED=0) |
29
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
39 endif() |
042ac60f5bf9
simplified build of curl
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
40 |
12 | 41 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake) |
42 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake) | |
101 | 43 include(${CMAKE_SOURCE_DIR}/Resources/CMake/Log4CPlusConfiguration.cmake) # Must be after DcmtkConfiguration |
12 | 44 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake) |
45 include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake) | |
46 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake) | |
47 include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake) | |
48 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake) | |
49 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake) | |
50 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake) | |
51 | |
52 | |
53 if (${CMAKE_COMPILER_IS_GNUCXX}) | |
26 | 54 set(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-implicit-function-declaration") |
55 # --std=c99 makes libcurl not to compile | |
56 # -pedantic gives a lot of warnings on OpenSSL | |
12 | 57 set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wno-long-long -Wno-variadic-macros") |
58 elseif (${MSVC}) | |
59 # http://stackoverflow.com/a/6510446 | |
60 foreach(flag_var | |
61 CMAKE_C_FLAGS_DEBUG | |
62 CMAKE_CXX_FLAGS_DEBUG | |
63 CMAKE_C_FLAGS_RELEASE | |
64 CMAKE_CXX_FLAGS_RELEASE | |
65 CMAKE_C_FLAGS_MINSIZEREL | |
66 CMAKE_CXX_FLAGS_MINSIZEREL | |
67 CMAKE_C_FLAGS_RELWITHDEBINFO | |
68 CMAKE_CXX_FLAGS_RELWITHDEBINFO) | |
69 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") | |
70 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") | |
71 endforeach(flag_var) | |
72 add_definitions( | |
73 -D_CRT_SECURE_NO_WARNINGS=1 | |
74 -D_CRT_SECURE_NO_DEPRECATE=1 | |
75 ) | |
76 include_directories(${CMAKE_SOURCE_DIR}/Resources/VisualStudio) | |
77 link_libraries(netapi32) | |
78 endif() | |
79 | |
80 | |
81 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | |
97 | 82 if (DEBIAN_HARDENING) |
83 execute_process( | |
84 COMMAND dpkg-buildflags --get CPPFLAGS | |
85 OUTPUT_VARIABLE DEBIAN_CPP_FLAGS | |
86 OUTPUT_STRIP_TRAILING_WHITESPACE) | |
87 execute_process( | |
88 COMMAND dpkg-buildflags --get CFLAGS | |
89 OUTPUT_VARIABLE DEBIAN_C_FLAGS | |
90 OUTPUT_STRIP_TRAILING_WHITESPACE) | |
91 execute_process( | |
92 COMMAND dpkg-buildflags --get CXXFLAGS | |
93 OUTPUT_VARIABLE DEBIAN_CXX_FLAGS | |
94 OUTPUT_STRIP_TRAILING_WHITESPACE) | |
95 execute_process( | |
96 COMMAND dpkg-buildflags --get LDFLAGS | |
97 OUTPUT_VARIABLE DEBIAN_LD_FLAGS | |
98 OUTPUT_STRIP_TRAILING_WHITESPACE) | |
99 | |
100 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DEBIAN_C_FLAGS} ${DEBIAN_CPP_FLAGS}") | |
101 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DEBIAN_CXX_FLAGS} ${DEBIAN_CPP_FLAGS}") | |
102 endif() | |
103 | |
12 | 104 add_definitions( |
105 -D_LARGEFILE64_SOURCE=1 | |
106 -D_FILE_OFFSET_BITS=64 | |
107 ) | |
97 | 108 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${DEBIAN_LD_FLAGS}") |
109 set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined ${DEBIAN_LD_FLAGS}") | |
110 set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${DEBIAN_LD_FLAGS}") | |
12 | 111 |
112 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html | |
113 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") | |
114 link_libraries(uuid pthread rt) | |
115 | |
116 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
117 add_definitions( | |
118 -DWINVER=0x0501 | |
119 -D_CRT_SECURE_NO_WARNINGS=1 | |
120 ) | |
121 link_libraries(rpcrt4 ws2_32) | |
122 endif() | |
123 | |
124 | |
125 if (${STATIC_BUILD}) | |
57 | 126 add_definitions(-DORTHANC_STATIC=1) |
12 | 127 else() |
57 | 128 add_definitions(-DORTHANC_STATIC=0) |
12 | 129 endif() |
130 | |
19 | 131 if (${STANDALONE_BUILD}) |
12 | 132 add_definitions( |
57 | 133 -DORTHANC_STANDALONE=1 |
12 | 134 ) |
135 | |
136 EmbedResources( | |
57 | 137 PREPARE_DATABASE OrthancServer/PrepareDatabase.sql |
138 ORTHANC_EXPLORER OrthancExplorer | |
12 | 139 ) |
140 | |
141 else() | |
142 add_definitions( | |
57 | 143 -DORTHANC_STANDALONE=0 |
144 -DORTHANC_PATH=\"${CMAKE_SOURCE_DIR}\" | |
12 | 145 ) |
146 | |
147 EmbedResources( | |
57 | 148 PREPARE_DATABASE OrthancServer/PrepareDatabase.sql |
12 | 149 ) |
150 endif() | |
151 | |
152 | |
153 add_library(CoreLibrary | |
154 STATIC | |
155 ${AUTOGENERATED_SOURCES} | |
156 ${THIRD_PARTY_SOURCES} | |
157 | |
158 Core/ChunkedBuffer.cpp | |
159 Core/Compression/BufferCompressor.cpp | |
160 Core/Compression/ZlibCompressor.cpp | |
81 | 161 Core/Compression/ZipWriter.cpp |
57 | 162 Core/OrthancException.cpp |
12 | 163 Core/DicomFormat/DicomArray.cpp |
164 Core/DicomFormat/DicomMap.cpp | |
165 Core/DicomFormat/DicomTag.cpp | |
79 | 166 Core/DicomFormat/DicomIntegerPixelAccessor.cpp |
12 | 167 Core/FileStorage.cpp |
168 Core/HttpServer/EmbeddedResourceHttpHandler.cpp | |
169 Core/HttpServer/FilesystemHttpHandler.cpp | |
170 Core/HttpServer/HttpHandler.cpp | |
171 Core/HttpServer/HttpOutput.cpp | |
172 Core/HttpServer/MongooseServer.cpp | |
173 Core/MultiThreading/BagOfRunnablesBySteps.cpp | |
174 Core/PngWriter.cpp | |
101 | 175 Core/Logging.cpp |
12 | 176 Core/SQLite/Connection.cpp |
177 Core/SQLite/FunctionContext.cpp | |
178 Core/SQLite/Statement.cpp | |
179 Core/SQLite/StatementId.cpp | |
180 Core/SQLite/StatementReference.cpp | |
181 Core/SQLite/Transaction.cpp | |
182 Core/Toolbox.cpp | |
183 Core/Uuid.cpp | |
184 | |
57 | 185 OrthancCppClient/HttpClient.cpp |
186 OrthancCppClient/HttpException.cpp | |
12 | 187 ) |
188 | |
189 add_library(ServerLibrary | |
57 | 190 OrthancServer/DicomProtocol/DicomFindAnswers.cpp |
191 OrthancServer/DicomProtocol/DicomServer.cpp | |
192 OrthancServer/DicomProtocol/DicomUserConnection.cpp | |
193 OrthancServer/FromDcmtkBridge.cpp | |
101 | 194 OrthancServer/Internals/DcmtkLogging.cpp |
57 | 195 OrthancServer/Internals/CommandDispatcher.cpp |
196 OrthancServer/Internals/FindScp.cpp | |
197 OrthancServer/Internals/MoveScp.cpp | |
198 OrthancServer/Internals/StoreScp.cpp | |
199 OrthancServer/OrthancInitialization.cpp | |
200 OrthancServer/OrthancRestApi.cpp | |
201 OrthancServer/ServerIndex.cpp | |
202 OrthancServer/ToDcmtkBridge.cpp | |
12 | 203 ) |
204 | |
205 # Ensure autogenerated code is built before building ServerLibrary | |
206 add_dependencies(ServerLibrary CoreLibrary) | |
207 | |
57 | 208 add_executable(Orthanc |
209 OrthancServer/main.cpp | |
12 | 210 ) |
211 | |
212 add_executable(UnitTests | |
213 ${GTEST_SOURCES} | |
214 UnitTests/main.cpp | |
215 UnitTests/SQLite.cpp | |
216 UnitTests/SQLiteChromium.cpp | |
217 UnitTests/Versions.cpp | |
81 | 218 UnitTests/Zip.cpp |
12 | 219 ) |
220 | |
57 | 221 TARGET_LINK_LIBRARIES(Orthanc ServerLibrary CoreLibrary) |
12 | 222 TARGET_LINK_LIBRARIES(UnitTests ServerLibrary CoreLibrary) |
223 | |
224 find_package(Doxygen) | |
225 if (DOXYGEN_FOUND) | |
226 configure_file( | |
57 | 227 ${CMAKE_SOURCE_DIR}/Resources/Orthanc.doxygen |
228 ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen | |
12 | 229 @ONLY) |
230 add_custom_target(doc | |
57 | 231 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Orthanc.doxygen |
12 | 232 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
233 COMMENT "Generating API documentation with Doxygen" VERBATIM | |
234 ) | |
235 endif(DOXYGEN_FOUND) |