Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VTK/9.0.1 - help needed! #3280

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6cd1ec1
First round
Oct 18, 2020
d5135a2
All files should be in place, with very raw adoption to conan-center …
Oct 18, 2020
fd99fd6
Fixes after applying conan-center hooks
Oct 19, 2020
156531b
First fixes in way to successful build
Oct 19, 2020
7c8d52c
First successful Win VS2019 Release local build, unfortunatelly with …
Oct 19, 2020
4211f48
Fixing test_package project
Oct 19, 2020
61ebafe
Fix HOOK errors
Oct 19, 2020
85609fa
Eliminating next HOOK errors. Status: Builds (with HOOK errors) succe…
Oct 19, 2020
14c305b
First fully successful Win Release build package and test!!!!
Oct 19, 2020
c098c80
Win local Debug build + test_package successful. No errors by HOOKs r…
Oct 19, 2020
36ba6ba
Polishing
Oct 20, 2020
9138937
Implement "cmake_find_package_multi" generator
Oct 20, 2020
18e1202
Fixing comments
Oct 20, 2020
636c5e0
Remove revision_mode = "scm" - make recipe more universal
Oct 20, 2020
799fa9a
Fix/Polish Mac
Oct 20, 2020
37ac2e3
Win and Mac should be fully functional with both "cmake" and "cmake_f…
Oct 20, 2020
9b14b7d
Dummy change to have signed commit
atrelinski Oct 20, 2020
6afdbef
Remove range in self.requires()
atrelinski Oct 20, 2020
1a13b9d
Update recipes/vtk/all/CMakeLists.txt
atrelinski Oct 20, 2020
00de05b
Polishing
Oct 20, 2020
643ea48
Fix version
Oct 22, 2020
ed108ac
Polishing
Oct 23, 2020
dfd1ed5
Try to adjust Lnx
Oct 23, 2020
02b7c02
Polishing
Oct 23, 2020
c5d946f
Wil Debug local successful
Oct 23, 2020
e375bc2
Polish
Oct 23, 2020
b3f1110
Polishing
Oct 24, 2020
a0dae91
Added VTK modules and groups
Oct 24, 2020
7943c19
Fix default for "Shared" option
Oct 24, 2020
a6982f1
Polish VTK defines
Oct 24, 2020
f8774a7
Removing Tk group - it does not exist in VTK 9.0.1
Oct 24, 2020
60a16f7
Add underscore to _groups and _modules
Oct 24, 2020
13eb35d
Fix list of modules for VTK 9.0.1
Oct 25, 2020
32a6117
Push to cci
Oct 25, 2020
917eb0e
Fixing Lnx trial
Oct 25, 2020
4530737
Boost for VTK verified (boost 1.74.0 fits VTK 9.0.1)
Oct 25, 2020
ac1fb92
Fix license
Oct 25, 2020
a8c36cc
Clean up recipe after successful Lnx build
Oct 25, 2020
facbe9a
Remove "apple-clang" < 10.0
Oct 26, 2020
bc26b6c
Clang 11 removed
Oct 26, 2020
e0f30b9
Remove test for "cmake_find_package_multi" generator
Oct 26, 2020
76e12b3
Eliminate shared apple-clang
Oct 26, 2020
18ec982
Try to fix Lnx
Oct 26, 2020
9bf7762
Remove MT builds (configurations) when vtk:shared=true is used
Oct 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions recipes/vtk/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 2.8)
project(conanvtk)

message(STATUS "Conan CMake Wrapper")
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
include(conanbuildinfo.cmake)
conan_basic_setup()

include_directories(${CMAKE_SOURCE_DIR}/source_subfolder)
add_subdirectory("source_subfolder")
10 changes: 10 additions & 0 deletions recipes/vtk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sources:
"9.0.1":
sha256: 9229bf40d4d9a9e4d8a118149cff031b5199cd2cd20df6c41e5da7cd1c7ad23d
url: https://github.com/Kitware/VTK/archive/v9.0.1.tar.gz
patches:
"8.2.0":
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
- patch_file: "patches/vtknetcdf_snprintf.patch"
base_path: "source_subfolder"
- patch_file: "patches/vtktiff_mangle.patch"
base_path: "source_subfolder"
176 changes: 176 additions & 0 deletions recipes/vtk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import os
import re
import shutil

from fnmatch import fnmatch
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
from conans import ConanFile, CMake, tools

class VTKConan(ConanFile):
name = "vtk"
version = "9.0.1"
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://vtk.org/"
license = "BSD license"
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
description = "Visualization Toolkit by Kitware"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
exports_sources = ["CMakeLists.txt", "patches/**"]
source_subfolder = "source_subfolder"
options = {"shared": [True, False], "qt": [True, False], "mpi": [True, False],
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
"fPIC": [True, False], "minimal": [True, False], "ioxml": [True, False],
"ioexport": [True, False], "mpi_minimal": [True, False]}
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
default_options = {"shared": False, "qt": False, "mpi": False, "fPIC": False,
"minimal": False, "ioxml": False, "ioexport": False, "mpi_minimal": False}
topics = ("conan", "VTK", "3D rendering", "2D plotting", "3D interaction", "3D manipulation",
"graphics", "image processing", "scientific visualization", "geometry modeling")
short_paths = True

version_split = version.split('.')
short_version = "{}.{}".format(version_split[0], version_split[1])
atrelinski marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("{}-{}".format(self.name, self.version), self.source_subfolder)

def requirements(self):
if self.options.qt:
self.requires("qt/5.15.1@bincrafters/stable")
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
self.options["qt"].shared = True
if tools.os_info.is_linux:
self.options["qt"].qtx11extras = True
atrelinski marked this conversation as resolved.
Show resolved Hide resolved

def _system_package_architecture(self):
if tools.os_info.with_apt:
if self.settings.arch == "x86":
return ':i386'
elif self.settings.arch == "x86_64":
return ':amd64'

if tools.os_info.with_yum:
if self.settings.arch == "x86":
return '.i686'
elif self.settings.arch == 'x86_64':
return '.x86_64'
return ""

def build_requirements(self):
pack_names = None
if not self.options.minimal and tools.os_info.is_linux:
if tools.os_info.with_apt:
pack_names = [
"freeglut3-dev",
"mesa-common-dev",
"mesa-utils-extra",
"libgl1-mesa-dev",
"libglapi-mesa",
"libsm-dev",
"libx11-dev",
"libxext-dev",
"libxt-dev",
"libglu1-mesa-dev"]

atrelinski marked this conversation as resolved.
Show resolved Hide resolved
if pack_names:
installer = tools.SystemPackageTool()
for item in pack_names:
installer.install(item + self._system_package_architecture())

def config_options(self):
if self.settings.compiler == "Visual Studio":
del self.options.fPIC

def _configure_cmake(self):
cmake = CMake(self)
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
cmake.definitions["BUILD_TESTING"] = "OFF"
cmake.definitions["BUILD_EXAMPLES"] = "OFF"
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared

if self.options.minimal:
cmake.definitions["VTK_Group_StandAlone"] = "OFF"
cmake.definitions["VTK_Group_Rendering"] = "OFF"
if self.options.ioxml:
cmake.definitions["Module_vtkIOXML"] = "ON"
if self.options.ioexport:
cmake.definitions["Module_vtkIOExport"] = "ON"
if self.options.qt:
cmake.definitions["VTK_Group_Qt"] = "ON"
cmake.definitions["VTK_QT_VERSION"] = "5"
cmake.definitions["VTK_BUILD_QT_DESIGNER_PLUGIN"] = "OFF"
if self.options.mpi:
cmake.definitions["VTK_Group_MPI"] = "ON"
cmake.definitions["Module_vtkIOParallelXML"] = "ON"
if self.options.mpi_minimal:
cmake.definitions["Module_vtkIOParallelXML"] = "ON"
cmake.definitions["Module_vtkParallelMPI"] = "ON"
atrelinski marked this conversation as resolved.
Show resolved Hide resolved

if self.settings.os == 'Macos':
self.env['DYLD_LIBRARY_PATH'] = os.path.join(self.build_folder, 'lib')
self.output.info("cmake build: %s" % self.build_folder)
atrelinski marked this conversation as resolved.
Show resolved Hide resolved

cmake.configure(build_folder='build')
return cmake

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
tools.patch(**patch)

cmake = self._configure_cmake()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake.install()

# "$\package\lib\vtk" contains "hierarchy\conanvtk\" and a lot of *.txt files in it.
shutil.rmtree(os.path.join(self.package_folder, 'lib', 'vtk')) #
# "$\package\lib\cmake" contains a lot of *.cmake files. conan-center HOOK disallow *.cmake files in package.
shutil.rmtree(os.path.join(self.package_folder, 'lib', 'cmake'))
# Licences are created in "$\package\share\licenses\conanvtk\" while their must be in "$\package\licenses\"
os.rename(os.path.join(self.package_folder, 'share', 'licenses', 'conanvtk'), os.path.join(self.package_folder, 'licenses'))
shutil.rmtree(os.path.join(self.package_folder, 'share'))
atrelinski marked this conversation as resolved.
Show resolved Hide resolved

# GCC static linking require providing libraries in appropriate order.
# Below "order" is not necessary is correct (couldn't find the correct one), but it is used as good starting point.
def _sort_libs(self, libs):
if self.settings.compiler != "gcc":
return libs
libs_ordered = []
print('VTK libs before sort: ' + (';'.join(libs)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a self.output.info for the conan-ization of print

order = ['vtkViewsCore', 'vtkViewsContext2D', 'vtkRenderingVolumeOpenGL2', 'vtkRenderingContextOpenGL2', 'vtkRenderingContext2D', 'vtkRenderingVolume', 'vtkfreetype', 'vtkRenderingFreeType', 'vtkRenderingAnnotation', 'vtkInteractionWidgets', 'vtkInteractionStyle', 'vtkImagingMath', 'vtkImagingHybrid', 'vtkImagingGeneral', 'vtkImagingColor', 'vtkexpat', 'vtkIOXMLParser', 'vtkIOXML', 'vtkIOLegacy', 'vtkIOGeometry', 'vtkgl2ps', 'vtkglew', 'vtkRenderingOpenGL2', 'vtkRenderingGL2PSOpenGL2', 'vtktiff', 'vtkpng', 'vtkjpeg', 'vtkmetaio', 'vtkIOImage', 'vtkIOExport', 'vtkzlib', 'vtkIOCore', 'vtkFiltersModeling', 'vtkFiltersSources', 'vtkRenderingCore', 'vtkImagingSources', 'vtkFiltersHybrid', 'vtkFiltersGeometry', 'vtkalglib', 'vtkImagingCore', 'vtkImagingFourier', 'vtkFiltersStatistics', 'vtkFiltersGeneral', 'vtkFiltersExtraction', 'vtkFiltersCore', 'vtkDICOMParser', 'vtkCommonExecutionModel', 'vtkCommonComputationalGeometry', 'vtkCommonDataModel', 'vtkCommonSystem', 'vtkCommonTransforms', 'vtkCommonMath', 'vtkCommonMisc', 'vtkCommonCore', 'vtkCommonColor', 'vtksys']
for item in order:
for idx in range(len(libs)):
if item.lower() in libs[idx].lower():
value = libs.pop(idx)
libs_ordered.append(value)
break
libs_ordered = libs + libs_ordered # add unordered elements, if any
print('VTK libs ordered: ' + (';'.join(libs_ordered)))
return libs_ordered

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "VTK"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check what cmake modules vtk installs and recreate them using components?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madebr
Not sure what are You taking about.
Do You mean more or less what was done in Added VTK modules and groups commit?

Copy link
Contributor

@madebr madebr Oct 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the package method, at the line

tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake'))

you remove the cmake config scripts.
The hooks indeed do block XXX-config.cmake and FindXXX.cmake scripts.
But when a consumers needs VTK in his cmake script, he still want to do something like the following:

find_package(VTK CONFIG REQUIRED COMPONENTS Opt1 OPT2)
target_link_library(my_exe PRIVATE VTK::Opt1 VTK::Opt2)

Conan components allow to define these cmake imported targets (to a certain extent).

self.cpp_info.names["cmake_find_package_multi"] = "VTK"
libs = tools.collect_libs(self)
self.cpp_info.libs = self._sort_libs(libs)

# Adding system libs without 'lib' prefix and '.so' or '.so.X' suffix.
if self.settings.os == 'Linux':
self.cpp_info.system_libs.append('pthread')
self.cpp_info.system_libs.append('dl') # 'libvtksys-7.1.a' require 'dlclose', 'dlopen', 'dlsym' and 'dlerror' which on CentOS are in 'dl' library

if not self.options.shared and self.options.qt:
if self.settings.os == 'Windows':
self.cpp_info.system_libs.append('Ws2_32') # 'vtksys-9.0d.lib' require 'gethostbyname', 'gethostname', 'WSAStartup' and 'WSACleanup' which are in 'Ws2_32.lib' library
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.cpp_info.system_libs.append('Ws2_32') # 'vtksys-9.0d.lib' require 'gethostbyname', 'gethostname', 'WSAStartup' and 'WSACleanup' which are in 'Ws2_32.lib' library
self.cpp_info.system_libs.append('ws2_32') # 'vtksys-9.0d.lib' require 'gethostbyname', 'gethostname', 'WSAStartup' and 'WSACleanup' which are in 'Ws2_32.lib' library

self.cpp_info.system_libs.append('Psapi') # 'vtksys-9.0d.lib' require 'GetProcessMemoryInfo' which is in 'Psapi.lib' library
self.cpp_info.system_libs.append('dbghelp') # 'vtksys-9.0d.lib' require '__imp_SymGetLineFromAddr64', '__imp_SymInitialize' and '__imp_SymFromAddr' which are in 'dbghelp.lib' library

if self.settings.os == 'Macos':
self.cpp_info.frameworks.extend(["CoreFoundation"]) # 'libvtkRenderingOpenGL2-9.0.a' require '_CFRelease', '_CFRetain', '_objc_msgSend' and much more which are in 'CoreFoundation' library
self.cpp_info.frameworks.extend(["Cocoa"]) # 'libvtkRenderingOpenGL2-9.0.a' require '_CGWarpMouseCursorPosition' and more, 'libvtkRenderingUI-9.0.a' require '_OBJC_CLASS_$_NSApplication' and more, which are in 'Cocoa' library

# Why "vtknetcdf" and "vtknetcdfcpp" are treated exceptionally from all other modules?
# There are a lot of other *.h in subfolders, should they be directly exposed too?
self.cpp_info.includedirs = [
"include/vtk-%s" % self.short_version,
"include/vtk-%s/vtknetcdf/include" % self.short_version,
"include/vtk-%s/vtknetcdfcpp" % self.short_version
]
12 changes: 12 additions & 0 deletions recipes/vtk/all/patches/vtknetcdf_snprintf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt b/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
index daf4a218b84549340006df4e2775fff27a464780..af8c272e7b82f4eee5da69d296ac9eb0bd3547f3 100644
--- a/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
+++ b/ThirdParty/netcdf/vtknetcdf/CMakeLists.txt
@@ -143,6 +143,7 @@ check_symbol_exists("strdup" "string.h" HAVE_STRDUP)
check_symbol_exists("strlcat" "string.h" HAVE_STRLCAT)
check_symbol_exists("st_blocksize" "sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
check_symbol_exists("sysconf" "unistd.h" HAVE_SYSCONF)
+check_symbol_exists("snprintf" "stdio.h" HAVE_SNPRINTF)

set(HAVE_HDF5_H 1)
check_symbol_exists("H5free_memory" "vtk_hdf5.h" HDF5_HAS_H5FREE)
28 changes: 28 additions & 0 deletions recipes/vtk/all/patches/vtktiff_mangle.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/ThirdParty/tiff/vtktiff/libtiff/vtk_tiff_mangle.h b/ThirdParty/tiff/vtktiff/libtiff/vtk_tiff_mangle.h
index ef121abeab..9f6818d7bc 100644
--- a/ThirdParty/tiff/vtktiff/libtiff/vtk_tiff_mangle.h
+++ b/ThirdParty/tiff/vtktiff/libtiff/vtk_tiff_mangle.h
@@ -45,6 +45,7 @@
#define TIFFError vtktiff_TIFFError
#define TIFFErrorExt vtktiff_TIFFErrorExt
#define _TIFFerrorHandler vtktiff__TIFFerrorHandler
+#define _TIFFerrorHandlerExt vtktiff__TIFFerrorHandlerExt
#define _TIFFFax3fillruns vtktiff__TIFFFax3fillruns
#define TIFFFaxBlackCodes vtktiff_TIFFFaxBlackCodes
#define TIFFFaxBlackTable vtktiff_TIFFFaxBlackTable
@@ -134,6 +135,7 @@
#define TIFFNumberOfStrips vtktiff_TIFFNumberOfStrips
#define TIFFNumberOfTiles vtktiff_TIFFNumberOfTiles
#define TIFFOpen vtktiff_TIFFOpen
+#define TIFFOpenW vtktiff_TIFFOpenW
#define TIFFPredictorCleanup vtktiff_TIFFPredictorCleanup
#define TIFFPredictorInit vtktiff_TIFFPredictorInit
#define _TIFFprintAscii vtktiff__TIFFprintAscii
@@ -235,6 +237,7 @@
#define TIFFWarning vtktiff_TIFFWarning
#define TIFFWarningExt vtktiff_TIFFWarningExt
#define _TIFFwarningHandler vtktiff__TIFFwarningHandler
+#define _TIFFwarningHandlerExt vtktiff__TIFFwarningHandlerExt
#define TIFFWriteBufferSetup vtktiff_TIFFWriteBufferSetup
#define TIFFWriteCheck vtktiff_TIFFWriteCheck
#define TIFFWriteCustomDirectory vtktiff_TIFFWriteCustomDirectory
32 changes: 32 additions & 0 deletions recipes/vtk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.1.3) # 3.1.3 is first fully functional cross-platform version with Targets
project(test_vtk_package)

set(CMAKE_CXX_STANDARD 11)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} CONAN_PKG::vtk)

# From oryginal recipe
# if(UNIX AND NOT APPLE)
# TARGET_LINK_LIBRARIES(${PROJECT_NAME} m)
# endif()


#############################
# Below is working test for "cmake_find_package_multi" generator (above is for "cmake" generator).
#
# cmake_minimum_required(VERSION 3.1.3) # 3.1.3 is first fully functional cross-platform version with Targets
#
# set(CMAKE_CXX_STANDARD 11)
#
# project(test_vtk_package)
#
# find_package(VTK REQUIRED CONFIG)
#
# add_executable(${PROJECT_NAME} test_package.cpp)
# target_link_libraries(${PROJECT_NAME} VTK::VTK)
#

17 changes: 17 additions & 0 deletions recipes/vtk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from conans import ConanFile, CMake, tools, RunEnvironment

class TestVTKConan(ConanFile):
settings = "os", "compiler", "arch", "build_type"
generators = "cmake" # Replace "cmake" by "cmake_find_package_multi" to test multi

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
# Replace "bin" by "Debug" on Win or by "." (dot) on Mac for "cmake_find_package_multi"
bin_path = os.path.join("bin", "test_vtk_package")
# Lnx: self.run("LD_LIBRARY_PATH=%s %s" % (os.environ.get('LD_LIBRARY_PATH', ''), bin_path), run_environment=True)
self.run(bin_path, run_environment=True)
atrelinski marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 31 additions & 0 deletions recipes/vtk/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <vtkSortDataArray.h>
#include <vtkDoubleArray.h>
#include <vtkIntArray.h>
#include <vtkSmartPointer.h>

int main(int, char *[])
{
vtkSmartPointer<vtkDoubleArray> valueArray = vtkSmartPointer<vtkDoubleArray>::New();
valueArray->InsertNextValue(20.0);
valueArray->InsertNextValue(10.0);
valueArray->InsertNextValue(30.0);

vtkSmartPointer<vtkIntArray> keyArray = vtkSmartPointer<vtkIntArray>::New();
keyArray->InsertNextValue(1);
keyArray->InsertNextValue(0);
keyArray->InsertNextValue(2);

std::cout << "Unsorted: " << valueArray->GetValue(0) << " "
<< valueArray->GetValue(1) << " "
<< valueArray->GetValue(2) << std::endl;

// Sort the array
vtkSmartPointer<vtkSortDataArray> sortDataArray = vtkSmartPointer<vtkSortDataArray>::New();
sortDataArray->Sort(keyArray, valueArray);

std::cout << "Sorted: " << valueArray->GetValue(0) << " "
<< valueArray->GetValue(1) << " "
<< valueArray->GetValue(2) << std::endl;

return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/vtk/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"9.0.1":
folder: all