]> Creatis software - clitk.git/blob - superbuild/CMakeLists.txt
Change cmake flags vot VTK5.10 in travis file
[clitk.git] / superbuild / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 cmake_policy(VERSION 2.8)
3
4 # set a default build type if it is undefined, then make sure it goes in the cache
5 if(NOT CMAKE_BUILD_TYPE)
6   set(CMAKE_BUILD_TYPE Release)
7 endif()
8 set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Build configuration type" FORCE)
9 set(build_type ${CMAKE_BUILD_TYPE})
10
11 #=========================================================
12 macro(DD in)
13     message(${in}=${${in}})
14 endmacro(DD)
15 #=========================================================
16
17 project(SuperBuild_VV)
18
19 if(MSVC)
20   set(CMAKE_C_FLAGS_DEBUG          "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "" FORCE)
21   set(CMAKE_C_FLAGS_MINSIZEREL     "/MT /O1 /Ob1 /D NDEBUG" CACHE STRING "" FORCE)
22   set(CMAKE_C_FLAGS_RELEASE        "/MT /O2 /Ob2 /D NDEBUG" CACHE STRING "" FORCE)
23   set(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG" CACHE STRING "" FORCE)
24
25   set(CMAKE_CXX_FLAGS_DEBUG          "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "" FORCE)
26   set(CMAKE_CXX_FLAGS_MINSIZEREL     "/MT /O1 /Ob1 /D NDEBUG" CACHE STRING "" FORCE)
27   set(CMAKE_CXX_FLAGS_RELEASE        "/MT /O2 /Ob2 /D NDEBUG" CACHE STRING "" FORCE)
28   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG" CACHE STRING "" FORCE)
29 endif(MSVC)
30
31 include(ExternalProject)
32
33 set(base "${CMAKE_BINARY_DIR}")
34 set_property(DIRECTORY PROPERTY EP_BASE ${base})
35 set(source_prefix ${base}/Source)
36 set(build_prefix ${base}/Build)
37 set(install_prefix ${base}/Install)
38
39 find_package(Git REQUIRED)
40
41 if( 1 EQUAL 1)
42 #=========================================================
43 # QT
44 if(WIN32)
45 set(QtWinSpecFiles "${source_prefix}/qt/mkspecs/win32-msvc2003/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2005/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2008/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2010/qmake.conf")
46 set(WINPATCH "sed -i \"s/\\-MD/-MT/g\" ${QtWinSpecFiles}")
47 else()
48 set(WINPATCH "")
49 endif()
50 ExternalProject_Add(
51   QT
52   SOURCE_DIR ${source_prefix}/qt
53   GIT_REPOSITORY git://code.qt.io/qt/qt.git
54   GIT_TAG v4.8.6
55   PATCH_COMMAND ${WINPATCH}
56   CONFIGURE_COMMAND ${source_prefix}/qt/configure -confirm-license
57                                                   -static
58                                                   -fast
59                                                   -opensource
60                                                   -release
61                                                   -prefix ${build_prefix}/QT
62                                                   -nomake examples
63                                                   -nomake demos
64                                                   -qt-libpng
65                                                   -no-libtiff
66                                                   -no-libjpeg
67                                                   -no-libmng
68                                                   -no-glib
69   INSTALL_COMMAND ""
70 )
71 set(qmake_executable "${build_prefix}/QT/bin/qmake")
72 set(VTK_DEPEND_QT QT)
73
74 else()
75   find_package(qt4 REQUIRED)
76   set(VTK_DEPEND_QT "")
77 endif()
78 #=========================================================
79
80 #=========================================================
81 # VTK
82 set(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")
83 if(MSVC)
84   set(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${VTK_CMAKE_CXX_STANDARD_LIBRARIES} Imm32.lib Winmm.lib Ws2_32.lib")
85 endif(MSVC)
86 ExternalProject_Add(
87   VTK
88   DEPENDS ${VTK_DEPEND_QT}
89   SOURCE_DIR ${source_prefix}/vtk
90   GIT_REPOSITORY git://vtk.org/VTK.git
91   GIT_TAG release-5.10
92   INSTALL_COMMAND ""
93   CMAKE_ARGS
94     -DQT_QMAKE_EXECUTABLE:FILEPATH=${qmake_executable}
95     -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
96     -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
97     -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
98     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
99     -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
100     -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
101     -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
102     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
103     -DCMAKE_INSTALL_PREFIX:PATH=${install_prefix}/${proj}
104     -DCMAKE_BUILD_TYPE:STRING=${build_type}
105     -DBUILD_SHARED_LIBS:BOOL=OFF
106     -DBUILD_EXAMPLES:BOOL=OFF
107     -DBUILD_TESTING:BOOL=OFF
108     -DVTK_USE_QT:BOOL=ON
109     -DVTK_USE_QVTK_QTOPENGL:BOOL=ON
110     -DCMAKE_CXX_STANDARD_LIBRARIES:STRING=${VTK_CMAKE_CXX_STANDARD_LIBRARIES}
111 )
112 set(VTK_DIR ${build_prefix}/VTK)
113 #=========================================================
114
115 #=========================================================
116 # GDCM
117    ExternalProject_Add(
118    GDCM
119    SOURCE_DIR ${source_prefix}/gdcm
120    GIT_REPOSITORY git://git.code.sf.net/p/gdcm/gdcm
121    GIT_TAG v2.2.4
122    INSTALL_COMMAND ""
123    CMAKE_ARGS
124    -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
125    -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
126    -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
127    -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
128    -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
129    -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
130    -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
131    -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
132    -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX}
133    -DCMAKE_BUILD_TYPE:STRING=${build_type}
134 )
135 set(GDCM_DIR ${build_prefix}/GDCM)
136 #=========================================================
137
138 #=========================================================
139 # ITK
140 ExternalProject_Add(
141   ITK
142   SOURCE_DIR ${source_prefix}/itk
143   GIT_REPOSITORY git://itk.org/ITK.git
144   GIT_TAG v4.5.2
145   INSTALL_COMMAND ""
146   CMAKE_ARGS
147     -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
148     -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
149     -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
150     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
151     -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
152     -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
153     -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
154     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
155     -DCMAKE_INSTALL_PREFIX:PATH=${install_prefix}/${proj}
156     -DCMAKE_BUILD_TYPE:STRING=${build_type}
157     -DBUILD_SHARED_LIBS:BOOL=OFF
158     -DBUILD_EXAMPLES:BOOL=OFF
159     -DBUILD_TESTING:BOOL=OFF
160 )
161 set(ITK_DIR ${build_prefix}/ITK)
162 #=========================================================
163
164 #=========================================================
165 # VV
166 set(VV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
167 if(MSVC)
168   set(VV_CMAKE_CXX_FLAGS "${VV_CMAKE_CXX_FLAGS} /bigobj")
169 endif(MSVC)
170
171 set(VV_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
172 if(CMAKE_COMPILER_IS_GNUCXX)
173   set(VV_CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
174 endif(CMAKE_COMPILER_IS_GNUCXX)
175
176 set(MAKE_COMMAND "make")
177 if(MSVC)
178   set(MAKE_COMMAND "nmake")
179 endif(MSVC)
180
181 ExternalProject_Add(
182   VV
183   DEPENDS ${VTK_DEPEND_QT} VTK ITK GDCM
184   SOURCE_DIR ${source_prefix}/vv
185   GIT_REPOSITORY git://git.creatis.insa-lyon.fr/clitk
186   INSTALL_DIR ${install_prefix}
187   INSTALL_COMMAND  make install
188   CMAKE_ARGS
189     -DQT_QMAKE_EXECUTABLE:FILEPATH=${qmake_executable}
190     -DGDCM_DIR:PATH=${GDCM_DIR}
191     -DITK_DIR:PATH=${ITK_DIR}
192     -DVTK_DIR:PATH=${VTK_DIR}
193     -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
194     -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
195     -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
196     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
197     -DCMAKE_CXX_FLAGS_DEBUG:STRING=${CMAKE_CXX_FLAGS_DEBUG}
198     -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${CMAKE_CXX_FLAGS_MINSIZEREL}
199     -DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}
200     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
201     -DCMAKE_CXX_FLAGS:STRING=${VV_CMAKE_CXX_FLAGS}
202     -DCMAKE_EXE_LINKER_FLAGS:STRING=${VV_CMAKE_EXE_LINKER_FLAGS}
203     -DCMAKE_INSTALL_PREFIX:PATH=${install_prefix}/${proj}
204     -DCMAKE_BUILD_TYPE:STRING=${build_type}
205     -DBUILD_SHARED_LIBS:BOOL=OFF
206     -DBUILD_TESTING:BOOL=OFF
207 )
208 #=========================================================
209