Browse Source

Tweaking VTK find_package

iss7
Trevor Irons 5 years ago
parent
commit
8ec7d62b41
2 changed files with 96 additions and 106 deletions
  1. 53
    47
      CMake/SuperBuild.cmake
  2. 43
    59
      CMakeLists.txt

+ 53
- 47
CMake/SuperBuild.cmake View File

@@ -1,6 +1,5 @@
1
-include(ExternalProject)
2
-
3 1
 project (SuperBuild CXX C)
2
+include(ExternalProject)
4 3
 
5 4
 if (Eigen3_FOUND)
6 5
     message( STATUS "Eigen was found ${eigen_DIR}" )
@@ -16,66 +15,73 @@ else()
16 15
 		#BUILD_COMMAND     ""
17 16
 		#INSTALL_COMMAND     ""
18 17
     )
19
-    #message("Source dir of myExtProj = ${SOURCE_DIR}")   
20
-    #ExternalProject_Get_property(EIGEN SOURCE_DIR)
21
-    #message("Source dir of myExtProj = ${SOURCE_DIR}")   
22
- 
23
-    # Are these necessary?
24
-    #include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3/")
25
-    #set (Eigen3_DIR  "${CMAKE_INSTALL_PREFIX}/include/eigen3" CACHE  PATH "" FORCE )
26
-    
27
-    #find_package (Eigen3 3.3 NO_MODULE REQUIRED)
28
-    #if (eigen3_FOUND)
29
-    #    message( STATUS "Eigen was found!!!!!!!!!!!!!! ${eigen_DIR}" )
30
-    #endif()
31 18
 endif()
32 19
 
33
-
34 20
 if (yaml-cpp_FOUND)
35 21
     message( STATUS "YAML-CPP was found ${yaml-cpp_FOUND}" )
36
-    #message( STATUS "YAML-CPP PATH ${yaml-cpp_PATH}" )
37
-    #message( STATUS "YAML-CPP DIR ${yaml-cpp_DIR}" )
38
-    #message( STATUS "YAML-CPP INCLUDE DIR ${yaml-cpp_INCLUDE_DIR}" )
39
-    #message( STATUS "YAML-CPP LIBRARIES ${YAML_CPP_LIBRARIES}" )
40
-    #message( STATUS "YAML-CPP LIBRARY ${yaml-cpp_LIBRARY}" )
41 22
 else()
42 23
     message( STATUS "YAML-CPP WAS NOT FOUND, BUILDING" )
43
-    message( STATUS "CMAKE BUILD TYPE ${CMAKE_BUILD_TYPE}" )
44
-    message( STATUS "CMAKE CXX COMPILER ${CMAKE_CXX_COMPILER}" )
45
-#    if ( ${CMAKE_C_COMPILER} )
46
-#        message( STATUS "Compiling Yaml with Cxx COMPILER ${CMAKE_CXX_COMPILER}" )
47
-#	    ExternalProject_Add(YAML_CPP
48
-#		GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
49
-#		GIT_TAG   "yaml-cpp-0.6.1" # "master" 
50
-#		UPDATE_COMMAND ""
51
-#		PATCH_COMMAND ""
52
-#    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
53
-#    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
54
-#                   -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
55
-#                   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 
56
-#    	           -DYAML_CPP_BUILD_TESTS=OFF
57
-#                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
58
-#                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 
59
-#                   -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 
60
-#        )
61
-#    else()
62
-	    ExternalProject_Add(YAML_CPP
63
-		GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
64
-		GIT_TAG "master" # "yaml-cpp-0.6.2" # "master" 
65
-		UPDATE_COMMAND ""
66
-		PATCH_COMMAND ""
67
-    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
68
-    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
24
+    ExternalProject_Add(YAML_CPP
25
+        GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
26
+        GIT_TAG "master" # "yaml-cpp-0.6.2" # "master" 
27
+        UPDATE_COMMAND ""
28
+        PATCH_COMMAND ""
29
+        PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
30
+        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
69 31
                    -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
70 32
                    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 
71 33
     	           -DYAML_CPP_BUILD_TESTS=OFF
72 34
                    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
73 35
                    -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 
74 36
                    -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 
37
+    )
38
+endif()
39
+
40
+if ( LEMMA_VTK8_SUPPORT )
41
+    find_package(VTK 8)
42
+#   find_package(VTK 8.9 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
43
+#           vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
44
+#           vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
45
+    #find_package(VTK 8 NO_MODULE) 
46
+            #vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
47
+            #vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
48
+    if ( NOT VTK_FOUND OR  VTK_VERSION VERSION_GREATER "8.2.0" )
49
+        #message(FATAL_ERROR "VTK 8 was found, but the wrong one! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} ) 
50
+        #endif()
51
+        #if ( VTK_VERSION VERSION_GREATER "8.20.0" ) # or VTK_DIR-NOTFOUND)
52
+        #message( AUTHOR_WARNING  "VTK > 8.20.0 was found! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} )
53
+        #message( FATAL_ERROR  "VTK > 8.20.0 was found! Version found: " ${VTK_VERSION}, ${VTK_USE_FILE} )
54
+        message( STATUS  "VTK > 8.20.0 was found! Version found: " ${VTK_VERSION}, ${VTK_USE_FILE} )
55
+        message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
56
+        ExternalProject_Add(VTK8
57
+        GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
58
+        GIT_TAG  "v8.2.0"
59
+        PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
60
+        CMAKE_ARGS
61
+            -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
62
+            -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
63
+            -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
64
+            -DBUILD_SHARED_LIBS:BOOL=ON /
65
+            -DBUILD_EXAMPLES:BOOL=OFF /
66
+            -DBUILD_TESTING:BOOL=OFF /
67
+            -DVTK_Group_Web:BOOL=OFF /
68
+            -DModule_vtkImagingMath:BOOL=ON /
69
+            LOG_DOWNLOAD 0 /
70
+            LOG_UPDATE 0
75 71
         )
76
-#    endif()
72
+    endif()
73
+    if (VTK_FOUND AND VTK_VERSION VERSION_LESS_EQUAL "8.20.0")
74
+        #message(STATUS "VTK 8 was found! " ${VTK_VERSION}, ${VTK_USE_FILE} ) 
75
+        message(STATUS "VTK 8.2 was found! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} )
76
+        set(volumeRenderer volumerenderer.cxx)
77
+        #include(${VTK_USE_FILE}) 
78
+        add_definitions(-DLEMMAUSEVTK)
79
+    else()
80
+    endif()
81
+
77 82
 endif()
78 83
 
84
+
79 85
 if (LEMMA_ENABLE_TESTING)
80 86
     if (CXXTEST_FOUND)
81 87
         message( STATUS "CxxTest was found" )

+ 43
- 59
CMakeLists.txt View File

@@ -37,8 +37,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
37 37
   message(STATUS "Setting build type to 'Debug' as none was specified.")
38 38
   set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
39 39
   # Set the possible values of build type for cmake-gui
40
-  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
41
-    "MinSizeRel" "RelWithDebInfo")
40
+  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 
41
+    "Debug" 
42
+    "Release"
43
+    "MinSizeRel" 
44
+    "RelWithDebInfo"
45
+  )
42 46
 endif()
43 47
 
44 48
 # If CMAKE_BUILD_TYPE is not specified, assume Release. 
@@ -51,7 +55,6 @@ option ( LEMMA_BUILD_EXAMPLES       "Compile example Lemma applications" OFF )
51 55
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
52 56
 option ( LEMMA_BUILD_DOCUMENTATION  "Build Doxygen man pages" OFF )
53 57
 
54
-#option (LEMMA_VTK7_SUPPORT "VTK 7.x library for visualisation and grids" OFF)
55 58
 option (LEMMA_VTK8_SUPPORT "VTK 8.x library for visualisation and grids" OFF)
56 59
 
57 60
 #option (CMAKE_CROSSCOMPILING "Target different arch than you are on" OFF)
@@ -64,6 +67,7 @@ SET (CMAKE_CROSSCOMPILING TRUE)
64 67
 ##########################################################################################
65 68
 ## Only look for packages where we build them...this makes finding VTK a problem though! #
66 69
 ########################################################################################## 
70
+
67 71
 if (CMAKE_CROSSCOMPILING)
68 72
     message ( STATUS "Performing SuperBuild") #, Only searching in install directory for components." )
69 73
     # Kind of hack-ish, CMake doesn't always find this. It's buried in Cross compilation, so, 
@@ -82,14 +86,15 @@ if (CMAKE_CROSSCOMPILING)
82 86
     #    UNSET( yaml-cpp_FOUND CACHE ) 
83 87
 
84 88
     #message( STATUS "........Looking for yaml-cpp in ${CMAKE_INSTALL_PREFIX}" )
85
-    
89
+    project (CHECKSUPERBUILD CXX)
86 90
     find_package (yaml-cpp 0.6 PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH ) # Serialisation of classes 
87 91
     find_package (Eigen3   3.3 PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH ) # Matrix/Vector & Math
88
-
92
+    find_package (VTK      8.2.0 EXACT PATHS ${CMAKE_INSTALL_PREFIX}  NO_DEFAULT_PATH ) # Visualization 
89 93
     #message( STATUS "yaml-cpp include dir ${YAML_CPP_INCLUDE_DIR}" )
90 94
 else()
91
-    find_package (Eigen3 3.3 QUIET)     # Matrix/Vector & Math
95
+    find_package (Eigen3   3.3 QUIET )  # Matrix/Vector & Math
92 96
     find_package (yaml-cpp 0.6 QUIET )  # Serialisation of classes 
97
+    find_package (VTK      8.2 QUIET )  # Visualization 
93 98
 endif()
94 99
 
95 100
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
@@ -117,6 +122,7 @@ endif()
117 122
 ## Optional Dependencies
118 123
 if ( NOT Eigen3_FOUND OR 
119 124
      NOT yaml-cpp_FOUND OR 
125
+     (LEMMA_VTK8_SUPPORT AND NOT VTK_FOUND) OR
120 126
      (LEMMA_ENABLE_TESTING AND NOT CxxTest_FOUND) )
121 127
     message ( STATUS "Missing hard dependencies have been found, these will be downloaded any compiled." )
122 128
     message ( STATUS "This necessitates a two step build." )
@@ -183,69 +189,47 @@ endif()
183 189
 # External Projects
184 190
 ###################
185 191
 
186
-# We don't build VTK, it is too heavy.
187
-#if ( LEMMA_VTK7_SUPPORT ) 
188
-#	#find_package(VTK 7 REQUIRED NO_MODULE)
189
-#	find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
192
+#if ( LEMMA_VTK8_SUPPORT ) 
193
+#	find_package(VTK 8) 
194
+#	find_package(VTK 8.9 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
190 195
 #			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
191 196
 #			vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
192
-#	set(volumeRenderer volumerenderer.cxx)
197
+	#find_package(VTK 8 NO_MODULE) 
198
+			#vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
199
+			#vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
200
+    #if ( ${VTK_MINOR_VERSION} != 2 )
201
+	#	message(FATAL_ERROR "VTK 8 was found! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} ) 
202
+    #endif()
203
+#    if (VTK_VERSION VERSION_GREATER "8.20.0")
204
+#		message( AUTHOR_WARNING  "VTK > 8.20.0 was found! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} ) 
205
+#    endif()
193 206
 #	if (VTK_FOUND)
194
-#		message(STATUS "VTK 7 was found! ") 
195
-#	        include(${VTK_USE_FILE}) 
196
-#		#add_compile_options(-DLEMMAUSEVTK)
197
-#		#target_compile_definitions( lemmacore PRIVATE LEMMAUSEVTK=1 )
198
-#		add_definitions(-DLEMMAUSEVTK) 
207
+#		#message(STATUS "VTK 8 was found! " ${VTK_VERSION}, ${VTK_USE_FILE} ) 
208
+#		message(STATUS "VTK 8 was found! " ${VTK_VERSION}, ${VTK_MINOR_VERSION}, ${VTK_USE_FILE} ) 
209
+#		set(volumeRenderer volumerenderer.cxx)
210
+#	    #include(${VTK_USE_FILE}) 
199 211
 #	else()
200
-#		ExternalProject_Add(VTK
212
+#		message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
213
+#		ExternalProject_Add(VTK8
201 214
 #  		GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
202
-#		GIT_TAG  "v7.1.1"
203
-#    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk7
204
-#  		CMAKE_ARGS
205
-#  	        -DBUILD_SHARED_LIBS:BOOL=ON
206
-#	        -DBUILD_EXAMPLES:BOOL=OFF
207
-#	        -DBUILD_TESTING:BOOL=OFF
208
-#		    -DVTK_Group_Web:BOOL=OFF
209
-#	        -DModule_vtkImagingMath:BOOL=ON
210
-#	  	    LOG_DOWNLOAD 0
215
+#		GIT_TAG  "v8.2.0"
216
+#    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
217
+#  		CMAKE_ARGS 
218
+#    	    -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
219
+#            -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
220
+#            -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
221
+#   	        -DBUILD_SHARED_LIBS:BOOL=ON /
222
+#	        -DBUILD_EXAMPLES:BOOL=OFF /
223
+#	        -DBUILD_TESTING:BOOL=OFF /
224
+#		    -DVTK_Group_Web:BOOL=OFF /
225
+#	        -DModule_vtkImagingMath:BOOL=ON /
226
+#	  	    LOG_DOWNLOAD 0 /
211 227
 #	  	    LOG_UPDATE 0
212 228
 #		)
213 229
 #	endif()
230
+#	add_definitions(-DLEMMAUSEVTK) 
214 231
 #endif()
215 232
 
216
-if ( LEMMA_VTK8_SUPPORT ) 
217
-	find_package(VTK 8.2 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
218
-			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
219
-			vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
220
-	#find_package(VTK 8 NO_MODULE) 
221
-			#vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkIOGeometry vtkInteractionStyle 
222
-			#vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
223
-	if (VTK_FOUND)
224
-		message(STATUS "VTK 8 was found! " ${VTK_VERSION}, ${VTK_USE_FILE} ) 
225
-		set(volumeRenderer volumerenderer.cxx)
226
-	    #include(${VTK_USE_FILE}) 
227
-	else()
228
-		message( STATUS "External build of VTK 8 has been added, this may take some time to build." )
229
-		ExternalProject_Add(VTK8
230
-  		GIT_REPOSITORY "https://gitlab.kitware.com/vtk/vtk.git"
231
-		GIT_TAG  "v8.2.0"
232
-    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/vtk8
233
-  		CMAKE_ARGS 
234
-    	    -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
235
-            -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
236
-            -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
237
-   	        -DBUILD_SHARED_LIBS:BOOL=ON /
238
-	        -DBUILD_EXAMPLES:BOOL=OFF /
239
-	        -DBUILD_TESTING:BOOL=OFF /
240
-		    -DVTK_Group_Web:BOOL=OFF /
241
-	        -DModule_vtkImagingMath:BOOL=ON /
242
-	  	    LOG_DOWNLOAD 0 /
243
-	  	    LOG_UPDATE 0
244
-		)
245
-	endif()
246
-	add_definitions(-DLEMMAUSEVTK) 
247
-endif()
248
-
249 233
 #######################
250 234
 # Lemma Configuration #
251 235
 #######################

Loading…
Cancel
Save