From 40daa0327c54a322172d766328a0a029e86588ff Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 2 Sep 2021 12:52:34 +0000 Subject: [PATCH] Update OCC --- .gitlab-ci.yml | 8 +- CMakeLists.txt | 11 ++- cmake/SuperBuild.cmake | 33 ++++--- cmake/cmake_modules/FindOpenCasCade.cmake | 106 ---------------------- cmake/external_projects/catch.cmake | 2 +- nglib/CMakeLists.txt | 2 +- tests/build_debug.sh | 1 + tests/catch/archive.cpp | 2 +- tests/catch/array.cpp | 2 +- tests/catch/main.cpp | 4 +- tests/catch/ranges.cpp | 2 +- tests/catch/symboltable.cpp | 2 +- tests/catch/utils.cpp | 2 +- tests/catch/version.cpp | 2 +- tests/dockerfile | 26 +++++- 15 files changed, 64 insertions(+), 141 deletions(-) delete mode 100644 cmake/cmake_modules/FindOpenCasCade.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b3ddbad..1af45b85 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,9 +58,6 @@ build_win: -DCHECK_RANGE=ON -DUSE_CGNS=ON -DUSE_OCC=ON - -DOCC_LIBRARY=C:/install_opencascade_7.4.0_static/win64/vc14/lib/TKernel.lib - -DOCC_INCLUDE_DIR=C:/install_opencascade_7.4.0_static/inc - -DOCC_LINK_FREETYPE=ON -DUSE_CCACHE=ON -DENABLE_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Release @@ -244,13 +241,10 @@ build_mac: -DUSE_NATIVE_ARCH=OFF -DUSE_CCACHE=ON -DENABLE_UNIT_TESTS=ON - -DCMAKE_OSX_DEPLOYMENT_TARGET=10.12 + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DUSE_CGNS=ON -DUSE_OCC=ON - -DOCC_LIBRARY=/usr/local/opt/opencascade-7.4.0/lib/libTKernel.a - -DOCC_INCLUDE_DIR=/usr/local/opt/opencascade-7.4.0/include/opencascade - -DOCC_LINK_FREETYPE=ON - make -j5 install test_mac: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e5ade9b..f7712b94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,9 +314,14 @@ install(TARGETS netgen_mpi netgen_metis ${NG_INSTALL_DIR}) ####################################################################### if (USE_OCC) - find_package(OpenCasCade REQUIRED) - add_definitions(-DOCCGEOMETRY -D_OCC64) - include_directories(${OCC_INCLUDE_DIR}) + find_package(OpenCasCade NAMES OpenCASCADE opencascade REQUIRED) + add_definitions(-DOCCGEOMETRY) + set(OCC_LIBRARIES ${OpenCASCADE_LIBRARIES}) + include_directories(${OpenCASCADE_INCLUDE_DIR}) + if(NOT OpenCASCADE_BUILD_SHARED_LIBS) + find_library( FREETYPE NAMES freetype ) + list(APPEND OCC_LIBRARIES ${FREETYPE}) + endif() endif (USE_OCC) ####################################################################### diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 79f136ab..c24b6319 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -16,7 +16,7 @@ macro(set_vars VAR_OUT) endmacro() ####################################################################### set (DEPS_DOWNLOAD_URL "https://github.com/NGSolve/ngsolve_dependencies/releases/download/v1.0.0" CACHE STRING INTERNAL) -set (OCC_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/occ_win64.zip" CACHE STRING INTERNAL) +set (OCC_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/occ75_win64.zip" CACHE STRING INTERNAL) set (TCLTK_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/tcltk_win64.zip" CACHE STRING INTERNAL) set (ZLIB_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/zlib_win64.zip" CACHE STRING INTERNAL) set (CGNS_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/cgns_win64.zip" CACHE STRING INTERNAL) @@ -65,19 +65,23 @@ endif (USE_PYTHON) ####################################################################### -if(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR) - ExternalProject_Add(win_download_occ - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tcl - URL ${OCC_DOWNLOAD_URL_WIN} - UPDATE_COMMAND "" # Disable update - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX} - LOG_DOWNLOAD 1 - ) - list(APPEND NETGEN_DEPENDENCIES win_download_occ) -endif(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR) +if(USE_OCC) + if(WIN32 AND NOT OCC_INCLUDE_DIR AND NOT OpenCASCADE_DIR) + ExternalProject_Add(win_download_occ + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tcl + URL ${OCC_DOWNLOAD_URL_WIN} + UPDATE_COMMAND "" # Disable update + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX} + LOG_DOWNLOAD 1 + ) + list(APPEND NETGEN_DEPENDENCIES win_download_occ) + else() + find_package(OpenCasCade NAMES OpenCASCADE opencascade REQUIRED) + endif() +endif(USE_OCC) ####################################################################### @@ -147,6 +151,7 @@ set_vars( NETGEN_CMAKE_ARGS BUILD_STUB_FILES BUILD_FOR_CONDA NG_COMPILE_FLAGS + OpenCasCade_DIR ) # propagate all variables set on the command line using cmake -DFOO=BAR diff --git a/cmake/cmake_modules/FindOpenCasCade.cmake b/cmake/cmake_modules/FindOpenCasCade.cmake deleted file mode 100644 index 8cb4319e..00000000 --- a/cmake/cmake_modules/FindOpenCasCade.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# Try to find OCC -# Once done this will define -# -# OCC_FOUND - system has OCC - OpenCASCADE -# OCC_INCLUDE_DIR - where the OCC include directory can be found -# OCC_LIBRARY_DIR - where the OCC library directory can be found -# OCC_LIBRARIES - Link this to use OCC - -if(WIN32) - find_path(OCC_INCLUDE_DIR Standard_Version.hxx PATH_SUFFIXES inc ../inc) - find_library(OCC_LIBRARY TKernel) -else(WIN32) - find_path(OCC_INCLUDE_DIR Standard_Version.hxx - /usr/include/opencascade - /usr/local/include/opencascade - /usr/include/oce - /usr/local/include/oce - /opt/opencascade/include - /opt/opencascade/inc - ) - find_library(OCC_LIBRARY TKernel - /usr/lib - /usr/local/lib - /opt/opencascade/lib - ) -endif(WIN32) - -if(OCC_LIBRARY AND NOT OCC_LIBRARY_DIR) - get_filename_component(OCC_LIBRARY_DIR ${OCC_LIBRARY} PATH) -endif(OCC_LIBRARY AND NOT OCC_LIBRARY_DIR) - -if(OCC_INCLUDE_DIR) - file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR - REGEX "#define OCC_VERSION_MAJOR.*" - ) - string(REGEX MATCH "[0-9]+" OCC_MAJOR ${OCC_MAJOR}) - file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MINOR - REGEX "#define OCC_VERSION_MINOR.*" - ) - string(REGEX MATCH "[0-9]+" OCC_MINOR ${OCC_MINOR}) - file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAINT - REGEX "#define OCC_VERSION_MAINTENANCE.*" - ) - string(REGEX MATCH "[0-9]+" OCC_MAINT ${OCC_MAINT}) - - set(OCC_VERSION_STRING "${OCC_MAJOR}.${OCC_MINOR}.${OCC_MAINT}") -endif(OCC_INCLUDE_DIR) - - -set(OCC_LIBRARY_NAMES - TKBO - TKBool - TKBRep - TKCAF - TKCDF - TKernel - TKG2d - TKG3d - TKGeomAlgo - TKGeomBase - TKHLR - TKIGES - TKLCAF - TKMath - TKMesh - TKOffset - TKPrim - TKService - TKShHealing - TKSTEP - TKSTEP209 - TKSTEPAttr - TKSTEPBase - TKSTL - TKTopAlgo - TKV3d - TKXCAF - TKXDEIGES - TKXDESTEP - TKXSBase - TKFillet -) - -if(OCC_LINK_FREETYPE) - set(OCC_LIBRARY_NAMES ${OCC_LIBRARY_NAMES} freetype) -endif(OCC_LINK_FREETYPE) - -if(OCC_VERSION_STRING VERSION_GREATER_EQUAL "7.3.0") - set(OCC_LIBRARY_NAMES ${OCC_LIBRARY_NAMES} TKVCAF) -endif() - -foreach( libname ${OCC_LIBRARY_NAMES} ) - find_library( ${libname} ${libname} ${OCC_LIBRARY_DIR} NO_DEFAULT_PATH) - set(OCC_LIBRARIES ${OCC_LIBRARIES} ${${libname}}) -endforeach() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(OCC REQUIRED_VARS OCC_INCLUDE_DIR VERSION_VAR OCC_VERSION_STRING ${OCC_LIBRARIY_NAMES}) - -if(OCC_FOUND) - message(STATUS "-- Found OpenCASCADE version: ${OCC_VERSION_STRING}") - message(STATUS "-- OpenCASCADE include directory: ${OCC_INCLUDE_DIR}") - message(STATUS "-- OpenCASCADE shared libraries directory: ${OCC_LIBRARY_DIR}") - message(STATUS "-- OpenCASCADE shared libraries :\n ${OCC_LIBRARIES}") -endif(OCC_FOUND) - diff --git a/cmake/external_projects/catch.cmake b/cmake/external_projects/catch.cmake index 0f79e6c7..57127b22 100644 --- a/cmake/external_projects/catch.cmake +++ b/cmake/external_projects/catch.cmake @@ -4,7 +4,7 @@ ExternalProject_Add( project_catch PREFIX ${CMAKE_BINARY_DIR}/catch GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.0.1 + GIT_TAG v2.13.7 TIMEOUT 10 UPDATE_COMMAND "" # ${GIT_EXECUTABLE} pull CONFIGURE_COMMAND "" diff --git a/nglib/CMakeLists.txt b/nglib/CMakeLists.txt index a7765e59..b0c0926f 100644 --- a/nglib/CMakeLists.txt +++ b/nglib/CMakeLists.txt @@ -31,7 +31,7 @@ endif(NOT WIN32) # target_link_libraries(nglib PRIVATE gen la gprim PUBLIC ngcore) target_link_libraries(nglib PUBLIC ngcore) -target_link_libraries( nglib PRIVATE ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} netgen_cgns ) +target_link_libraries( nglib PRIVATE ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} netgen_cgns ) if(USE_OCC AND NOT WIN32) target_link_libraries(nglib PUBLIC occ) diff --git a/tests/build_debug.sh b/tests/build_debug.sh index e779b381..202ae7a9 100755 --- a/tests/build_debug.sh +++ b/tests/build_debug.sh @@ -8,6 +8,7 @@ cmake \ -DUSE_OCC=ON \ -DCHECK_RANGE=ON \ -DUSE_CGNS=ON \ + -DCMAKE_INSTALL_PREFIX=/usr \ ../../src/netgen make -j12 make install diff --git a/tests/catch/archive.cpp b/tests/catch/archive.cpp index 96c2087c..ef3c1a5d 100644 --- a/tests/catch/archive.cpp +++ b/tests/catch/archive.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include <../core/ngcore.hpp> using namespace ngcore; using namespace std; diff --git a/tests/catch/array.cpp b/tests/catch/array.cpp index 6bcb808e..c21aa800 100644 --- a/tests/catch/array.cpp +++ b/tests/catch/array.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include using namespace ngcore; using namespace std; diff --git a/tests/catch/main.cpp b/tests/catch/main.cpp index de419564..ad4c8431 100644 --- a/tests/catch/main.cpp +++ b/tests/catch/main.cpp @@ -1,3 +1,3 @@ - #define CATCH_CONFIG_MAIN -#include +#define DO_NOT_USE_WMAIN +#include diff --git a/tests/catch/ranges.cpp b/tests/catch/ranges.cpp index b4559de0..aeca69b8 100644 --- a/tests/catch/ranges.cpp +++ b/tests/catch/ranges.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include #include diff --git a/tests/catch/symboltable.cpp b/tests/catch/symboltable.cpp index 5e6ecd2c..10bdff12 100644 --- a/tests/catch/symboltable.cpp +++ b/tests/catch/symboltable.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include <../core/ngcore.hpp> using namespace ngcore; using namespace std; diff --git a/tests/catch/utils.cpp b/tests/catch/utils.cpp index b5863510..74b6dd37 100644 --- a/tests/catch/utils.cpp +++ b/tests/catch/utils.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include using namespace ngcore; using namespace std; diff --git a/tests/catch/version.cpp b/tests/catch/version.cpp index 5655ab23..873636c2 100644 --- a/tests/catch/version.cpp +++ b/tests/catch/version.cpp @@ -1,5 +1,5 @@ -#include "catch.hpp" +#include #include <../core/ngcore.hpp> using namespace ngcore; using namespace std; diff --git a/tests/dockerfile b/tests/dockerfile index 152aab13..c79b1012 100644 --- a/tests/dockerfile +++ b/tests/dockerfile @@ -1,6 +1,30 @@ FROM ubuntu:20.10 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger -RUN apt-get update && apt-get -y install python3 python3-pip libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang libocct-data-exchange-dev libcgns-dev libhdf5-dev +RUN apt-get update && apt-get -y install \ + ccache \ + clang occt-misc \ + clang-tidy \ + cmake \ + g++ \ + git \ + libcgns-dev \ + libglu1-mesa-dev \ + libhdf5-dev \ + libocct-data-exchange-dev \ + libocct-draw-dev \ + libpython3-dev \ + libtbb-dev \ + libxi-dev \ + libxmu-dev \ + python3 \ + python3-distutils \ + python3-numpy \ + python3-pip \ + python3-pytest \ + python3-tk \ + tcl-dev \ + tk-dev + RUN python3 -m pip install pytest-check ADD . /root/src/netgen