diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index a78e5916b0..627225e51b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -413,29 +413,37 @@ if(HDF5_SUPPORT) ElSE() SET(HDF5_LIBRARY_DIR "${HDF5_LIBRARY_DIR}" CACHE FILEPATH "HDF5 library files") ENDIF() - - - MESSAGE(STATUS HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIR}") - IF(WIN32) - # An additional lib- prefix is added by HDF5 to denote static libraries - SET(HDF5_LIBRARIES - "${HDF5_LIBRARY_DIR}/libhdf5_cpp.lib" - "${HDF5_LIBRARY_DIR}/libhdf5.lib" - "${HDF5_LIBRARY_DIR}/libzlib.lib" - "${HDF5_LIBRARY_DIR}/libsz.lib" - "${HDF5_LIBRARY_DIR}/libaec.lib") - ELSE() - if (NOT HDF5_LIBRARIES) - SET(HDF5_LIBRARIES + + if (HDF5_LIBRARY_DIR) + # result of the HDF5 ctest package + + if (win32) + set(zlib_post lib) + set(lib_ext lib) + else() + set(lib_ext a) + endif() + + SET(HDF5_LIBRARIES + "${HDF5_LIBRARY_DIR}/libhdf5_cpp.${lib_ext}" + "${HDF5_LIBRARY_DIR}/libhdf5.${lib_ext}" + "${HDF5_LIBRARY_DIR}/libz${zlib_post}.${lib_ext}" + "${HDF5_LIBRARY_DIR}/libsz.${lib_ext}" + "${HDF5_LIBRARY_DIR}/libaec.${lib_ext}" + ) + endif() + + if (NOT HDF5_LIBRARIES) + # debian default + + SET(HDF5_LIBRARIES /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.a /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.a /usr/lib/x86_64-linux-gnu/libsz.a /usr/lib/x86_64-linux-gnu/libaec.a z dl - ) - endif() - # An additional lib- prefix is added by HDF5 to denote static libraries - ENDIF() + ) + endif() endif() IF(NOT CMAKE_BUILD_TYPE) diff --git a/nix/build-all.py b/nix/build-all.py index efd0983b4a..70bdb97fc8 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -96,8 +96,7 @@ SWIG_VERSION="3.0.12" #SWIG_VERSION="4.0.0" #OPENCOLLADA_VERSION="v1.6.63" OPENCOLLADA_VERSION="v1.6.68" - - +HDF5_VERSION="1.8.22" # binaries cp="cp" @@ -223,7 +222,7 @@ cecho(""" - How many compiler processes may be run in parallel. """) dependency_tree = { - 'IfcParse': ('boost', 'libxml2'), + 'IfcParse': ('boost', 'libxml2', 'hdf5'), 'IfcGeom': ('IfcParse', 'occ'), 'IfcConvert': ('IfcGeom', 'OpenCOLLADA', 'json'), 'OpenCOLLADA': ('libxml2', 'pcre'), @@ -235,7 +234,8 @@ dependency_tree = { 'python': (), 'occ': (), 'pcre': (), - 'json': () + 'json': (), + 'hdf5': () } def v(dep): @@ -348,7 +348,7 @@ def git_clone_or_pull_repository(clone_url, target_dir, revision=None): run([git, "checkout", revision], cwd=target_dir) -def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None, patch=None, additional_files={}, no_append_name=False): +def build_dependency(name, mode, build_tool_args, download_url, download_name, download_tool=download_tool_default, revision=None, patch=None, additional_files={}, no_append_name=False, **kwargs): """Handles building of dependencies with different tools (which are distinguished with the `mode` argument. `build_tool_args` is expected to be a list which is necessary in order to not mess up quoting of compiler and @@ -393,7 +393,8 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d else: raise RuntimeError("fix source for new download type") download_tarfile = tarfile.open(name=download_tarfile_path, mode="r:%s" % (compr,)) - extract_dir_name= os.path.commonprefix(download_tarfile.getnames()) # tarfile seriously doesn't have a function to retrieve the root directory more easily + # tarfile seriously doesn't have a function to retrieve the root directory more easily + extract_dir_name= os.path.commonprefix([x for x in download_tarfile.getnames() if x != "."]) #run([tar, "--exclude=\"*/*\"", "-tf", download_name], cwd=build_dir).strip() no longer works if extract_dir_name is None: extract_dir_name= run([bash, "-c", "tar -tf %s 2> /dev/null | head -n 1 | cut -f1 -d /" % (download_name,)], cwd=build_dir) @@ -412,8 +413,15 @@ def build_dependency(name, mode, build_tool_args, download_url, download_name, d except Exception as e: # Assert that the patch has already been applied run(["patch", "-p1", "--batch", "--reverse", "--dry-run", "-i", patch_abs], cwd=extract_dir) - - if mode != "bjam": + + if mode == "ctest": + run(["ctest", "-S", "HDF5config.cmake,BUILD_GENERATOR=Unix", "-C", BUILD_CFG, "-V", "-O", "hdf5.log"], cwd=extract_dir) + run([tar, "-xf", kwargs["ctest_result"] + ".tar.gz"], cwd=os.path.join(extract_dir, 'build')) + shutil.copytree( + os.path.join(extract_dir, "build", kwargs["ctest_result"], kwargs["ctest_result_path"]), + os.path.join(DEPS_DIR, "install", name) + ) + elif mode != "bjam": extract_build_dir = os.path.join(extract_dir, "build") if os.path.exists(extract_build_dir): shutil.rmtree(extract_build_dir) @@ -493,6 +501,18 @@ os.environ["LDFLAGS"] = LDFLAGS # @tfk: this is no longer needed # build_dependency(name="cmake-%s" % (CMAKE_VERSION,), mode="autoconf", build_tool_args=[], download_url="https://cmake.org/files/v%s" % (CMAKE_VERSION_2,), download_name="cmake-%s.tar.gz" % (CMAKE_VERSION,)) +if 'hdf5' in targets: + HDF5_MAJOR=".".join(HDF5_VERSION.split(".")[:-1]) + build_dependency( + name="hdf5-{HDF5_VERSION}".format(**locals()), + mode="ctest", + build_tool_args=[], + download_url="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{HDF5_MAJOR}/hdf5-{HDF5_VERSION}/src/".format(**locals()), + download_name="CMake-hdf5-{HDF5_VERSION}.tar.gz".format(**locals()), + ctest_result="HDF5-{HDF5_VERSION}-Linux".format(**locals()), + ctest_result_path="HDF_Group/HDF5/{HDF5_VERSION}".format(**locals()) + ) + if "json" in targets: json_url = "https://github.com/nlohmann/json/releases/download/{JSON_VERSION}/json.hpp".format(**locals()) json_install_path = "{DEPS_DIR}/install/json/nlohmann/json.hpp".format(**locals()) @@ -670,15 +690,18 @@ logger.info("\rConfiguring executables...") OFF_ON = ["OFF", "ON"] -cmake_args=[ - "-DUSE_MMAP=" "OFF", - "-DBUILD_EXAMPLES=" "OFF", - "-DBUILD_IFCPYTHON=" "OFF", - "-DBUILD_SHARED_LIBS=" +OFF_ON[not BUILD_STATIC], +exec_args=[ "-DBUILD_IFCGEOM=" +OFF_ON["IfcGeom" in targets], "-DBUILD_GEOMSERVER=" +OFF_ON["IfcGeomServer" in targets], "-DBUILD_CONVERT=" +OFF_ON["IfcConvert" in targets], + "-DBUILD_IFCPYTHON=" "OFF", "-DCMAKE_INSTALL_PREFIX=" "{DEPS_DIR}/install/ifcopenshell".format(**locals()), +] + +cmake_args=[ + "-DUSE_MMAP=" "OFF", + "-DBUILD_EXAMPLES=" "OFF", + "-DBUILD_SHARED_LIBS=" +OFF_ON[not BUILD_STATIC], "-DBOOST_ROOT=" "{DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()), "-DGLTF_SUPPORT=" "ON", "-DJSON_INCLUDE_DIR=" "{DEPS_DIR}/install/json".format(**locals()), @@ -717,7 +740,13 @@ if "libxml2" in targets: "-DLIBXML2_LIBRARIES=" "{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}".format(**locals()) ]) -run_cmake("", cmake_args, cmake_dir=CMAKE_DIR, cwd=executables_dir) +if "hdf5" in targets: + cmake_args.extend([ + "-DHDF5_INCLUDE_DIR=" "{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/include".format(**locals()), + "-DHDF5_LIBRARY_DIR=" "{DEPS_DIR}/install/hdf5-{HDF5_VERSION}/lib".format(**locals()) + ]) + +run_cmake("", exec_args + cmake_args, cmake_dir=CMAKE_DIR, cwd=executables_dir) logger.info("\rBuilding executables... ") @@ -753,19 +782,12 @@ if "IfcOpenShell-Python" in targets: os.environ["PYTHON_LIBRARY_BASENAME"]=os.path.basename(PYTHON_LIBRARY) run_cmake("", - cmake_args=[ - "-DBUILD_SHARED_LIBS=" "OFF" if BUILD_STATIC else "ON", - "-DBOOST_ROOT=" "{DEPS_DIR}/install/boost-{BOOST_VERSION}".format(**locals()), - "-DOCC_INCLUDE_DIR=" +occ_include_dir, - "-DOCC_LIBRARY_DIR=" +occ_library_dir, + cmake_args + [ "-DPYTHON_LIBRARY=" +PYTHON_LIBRARY, "-DPYTHON_EXECUTABLE=" +PYTHON_EXECUTABLE, "-DPYTHON_INCLUDE_DIR=" +PYTHON_INCLUDE, "-DSWIG_EXECUTABLE=" "{DEPS_DIR}/install/swig/bin/swig".format(**locals()), "-DCMAKE_INSTALL_PREFIX=" "{DEPS_DIR}/install/ifcopenshell/tmp".format(**locals()), - "-DLIBXML2_INCLUDE_DIR=" "{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/include/libxml2".format(**locals()), - "-DLIBXML2_LIBRARIES=" "{DEPS_DIR}/install/libxml2-{LIBXML2_VERSION}/lib/libxml2.{LIBRARY_EXT}".format(**locals()), - "-DCOLLADA_SUPPORT=OFF" ], cmake_dir=CMAKE_DIR, cwd=python_dir) logger.info("\rBuilding python %s%s wrapper... " % (PYTHON_VERSION, TAG))