comparison CMakeLists.txt @ 0:02f7a0400a91

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Feb 2015 13:45:35 +0100
parents
children fb9aca75eafd
comparison
equal deleted inserted replaced
-1:000000000000 0:02f7a0400a91
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 #
5 # This program is free software: you can redistribute it and/or
6 # modify it under the terms of the GNU Affero General Public License
7 # as published by the Free Software Foundation, either version 3 of
8 # the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19 cmake_minimum_required(VERSION 2.8)
20
21 project(OrthancPostgreSQL)
22
23 # Parameters of the build
24 set(STATIC_BUILD OFF CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
25 SET(STANDALONE_BUILD ON CACHE BOOL "Standalone build (all the resources are embedded, necessary for releases)")
26 set(ALLOW_DOWNLOADS OFF CACHE BOOL "Allow CMake to download packages")
27
28 # Advanced parameters to fine-tune linking against system libraries
29 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
30 set(USE_SYSTEM_GDCM ON CACHE BOOL "Use the system version of Grassroot DICOM (GDCM)")
31 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
32 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
33 set(USE_SYSTEM_LIBJPEG ON CACHE BOOL "Use the system version of libjpeg")
34 set(USE_SYSTEM_LIBPNG ON CACHE BOOL "Use the system version of libpng")
35 set(USE_SYSTEM_ZLIB ON CACHE BOOL "Use the system version of zlib")
36 set(USE_SYSTEM_SQLITE ON CACHE BOOL "Use the system version of SQLite")
37
38 # Distribution-specific settings
39 set(USE_GTEST_DEBIAN_SOURCE_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
40 mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE)
41
42 # Force static build when cross-compiling
43 if (CMAKE_CROSSCOMPILING)
44 set(STATIC_BUILD ON)
45 set(STANDALONE_BUILD ON)
46 endif()
47
48 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
49 SET(OS_LIBRARIES uuid rt dl)
50 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
51 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
52 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
53 SET(OS_LIBRARIES rpcrt4 ws2_32 secur32)
54 if (CMAKE_COMPILER_IS_GNUCXX)
55 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
56 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
57 endif()
58 endif ()
59
60 if (CMAKE_COMPILER_IS_GNUCXX)
61 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/Resources/VersionScript.map -Wl,--no-undefined")
62 endif()
63
64
65 include(CheckIncludeFiles)
66 include(CheckIncludeFileCXX)
67 include(CheckLibraryExists)
68 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
69 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
70
71 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
72 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GdcmConfiguration.cmake)
73 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
74 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
75 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibJpegConfiguration.cmake)
76 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
77 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
78 include(${CMAKE_SOURCE_DIR}/Resources/CMake/SQLiteConfiguration.cmake)
79
80 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JavaScriptLibraries.cmake)
81
82
83 # Check that the Orthanc SDK headers are available or download them
84 if (STATIC_BUILD)
85 set(ORTHANC_SDK_URL "http://orthanc.googlecode.com/hg") # TODO use 0.8.6 release
86 file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}/orthanc)
87 file(DOWNLOAD "${ORTHANC_SDK_URL}/Plugins/Include/OrthancCPlugin.h"
88 "${AUTOGENERATED_DIR}/orthanc/OrthancCPlugin.h" SHOW_PROGRESS)
89 if (${MSVC})
90 add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
91 file(DOWNLOAD "${ORTHANC_SDK_URL}/Resources/ThirdParty/VisualStudio/stdint.h"
92 "${AUTOGENERATED_DIR}/stdint.h" SHOW_PROGRESS)
93 endif()
94 else ()
95 CHECK_INCLUDE_FILE_CXX(orthanc/OrthancCPlugin.h HAVE_ORTHANC_H)
96 if (NOT HAVE_ORTHANC_H)
97 message(FATAL_ERROR "Please install the headers of the Orthanc plugins SDK")
98 endif()
99 endif()
100
101
102 if (STANDALONE_BUILD)
103 add_definitions(
104 -DORTHANC_STANDALONE=1
105 )
106 set(EMBEDDED_RESOURCES
107 WEB_VIEWER ${CMAKE_SOURCE_DIR}/WebApplication
108 )
109 else()
110 add_definitions(
111 -DORTHANC_STANDALONE=0
112 -DWEB_VIEWER_PATH="${CMAKE_SOURCE_DIR}/WebApplication/"
113 )
114 endif()
115
116 EmbedResources(
117 ORTHANC_EXPLORER ${CMAKE_SOURCE_DIR}/Resources/OrthancExplorer.js
118 JAVASCRIPT_LIBS ${JAVASCRIPT_LIBS_DIR}
119 ${EMBEDDED_RESOURCES}
120 )
121
122 add_definitions(
123 -DORTHANC_SQLITE_STANDALONE=1
124 )
125
126 set(CORE_SOURCES
127 ${BOOST_SOURCES}
128 ${JSONCPP_SOURCES}
129 ${SQLITE_SOURCES}
130 ${LIBJPEG_SOURCES}
131 ${ZLIB_SOURCES}
132 ${LIBPNG_SOURCES}
133
134 # Sources inherited from Orthanc core
135 ${CMAKE_SOURCE_DIR}/Orthanc/ChunkedBuffer.cpp
136 ${CMAKE_SOURCE_DIR}/Orthanc/Enumerations.cpp
137 ${CMAKE_SOURCE_DIR}/Orthanc/FileStorage/FilesystemStorage.cpp
138 ${CMAKE_SOURCE_DIR}/Orthanc/ImageFormats/ImageAccessor.cpp
139 ${CMAKE_SOURCE_DIR}/Orthanc/ImageFormats/ImageBuffer.cpp
140 ${CMAKE_SOURCE_DIR}/Orthanc/ImageFormats/ImageProcessing.cpp
141 ${CMAKE_SOURCE_DIR}/Orthanc/ImageFormats/PngWriter.cpp
142 ${CMAKE_SOURCE_DIR}/Orthanc/MultiThreading/SharedMessageQueue.cpp
143 ${CMAKE_SOURCE_DIR}/Orthanc/OrthancException.cpp
144 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/Connection.cpp
145 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/FunctionContext.cpp
146 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/Statement.cpp
147 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/StatementId.cpp
148 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/StatementReference.cpp
149 ${CMAKE_SOURCE_DIR}/Orthanc/SQLite/Transaction.cpp
150 ${CMAKE_SOURCE_DIR}/Orthanc/Toolbox.cpp
151 ${CMAKE_SOURCE_DIR}/Orthanc/Uuid.cpp
152 ${CMAKE_SOURCE_DIR}/Resources/ThirdParty/base64/base64.cpp
153
154 ${CMAKE_SOURCE_DIR}/Plugin/Cache/CacheManager.cpp
155 ${CMAKE_SOURCE_DIR}/Plugin/Cache/CacheScheduler.cpp
156 ${CMAKE_SOURCE_DIR}/Plugin/JpegWriter.cpp
157 ${CMAKE_SOURCE_DIR}/Plugin/ViewerToolbox.cpp
158 ${CMAKE_SOURCE_DIR}/Plugin/SeriesVolumeSorter.cpp
159 ${CMAKE_SOURCE_DIR}/Plugin/ViewerPrefetchPolicy.cpp
160 ${CMAKE_SOURCE_DIR}/Plugin/InstanceInformation.cpp
161 ${CMAKE_SOURCE_DIR}/Plugin/InstanceInformationAdapter.cpp
162 ${CMAKE_SOURCE_DIR}/Plugin/SeriesInformationAdapter.cpp
163 )
164
165 add_library(OrthancWebViewer
166 SHARED
167 ${CORE_SOURCES}
168 ${AUTOGENERATED_SOURCES}
169 ${CMAKE_SOURCE_DIR}/Plugin/Plugin.cpp
170
171 # The following files depend on GDCM
172 ${CMAKE_SOURCE_DIR}/Plugin/ParsedDicomImage.cpp
173 ${CMAKE_SOURCE_DIR}/Plugin/DecodedImageAdapter.cpp
174 )
175
176 if (STATIC_BUILD OR NOT USE_SYSTEM_GDCM)
177 add_dependencies(OrthancWebViewer GDCM)
178 endif()
179
180 target_link_libraries(OrthancWebViewer ${GDCM_LIBRARIES} ${OS_LIBRARIES})
181
182 install(
183 TARGETS OrthancWebViewer
184 RUNTIME DESTINATION lib # Destination for Windows
185 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
186 )
187
188 add_executable(UnitTests
189 ${CORE_SOURCES}
190 ${GTEST_SOURCES}
191 UnitTestsSources/UnitTestsMain.cpp
192 )
193
194 target_link_libraries(UnitTests ${OS_LIBRARIES})