Skip to content

Commit

Permalink
opencascade: Add release 7.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanDugueperoux2 committed Nov 12, 2024
1 parent e61c92d commit 2de9c54
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 201 deletions.
277 changes: 103 additions & 174 deletions recipes/opencascade/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

required_conan_version = ">=1.53.0"


class OpenCascadeConan(ConanFile):
name = "opencascade"
description = "A software development platform providing services for 3D " \
Expand All @@ -31,27 +30,13 @@ class OpenCascadeConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"with_ffmpeg": [True, False],
"with_freeimage": [True, False],
"with_openvr": [True, False],
"with_rapidjson": [True, False],
"with_draco": [True, False],
"with_tk": [True, False],
"with_tbb": [True, False],
"with_opengl": [True, False],
"extended_debug_messages": [True, False],
"with_samples": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_ffmpeg": False,
"with_freeimage": False,
"with_openvr": False,
"with_rapidjson": False,
"with_draco": False,
"with_tk": False,
"with_tbb": False,
"with_opengl": True,
"extended_debug_messages": False,
"with_samples": False
}
Expand Down Expand Up @@ -93,27 +78,24 @@ def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.with_tk:
self.requires("tk/8.6.10")
self.requires("freetype/2.13.2")
if self.options.with_opengl:
self.requires("opengl/system")
self.requires("freeimage/3.18.0")
# See https://github.com/conan-io/conan-center-index/pull/23138/files
self.requires("libpng/1.6.44", override=True)
self.requires("openvr/1.16.8")
self.requires("opengl/system")
self.requires("rapidjson/cci.20230929")
self.requires("draco/1.5.6")
self.requires("tk/8.6.10")
self.requires("onetbb/2021.12.0")

if self._is_linux:
self.requires("fontconfig/2.13.93")
self.requires("xorg/system")
# TODO: add vtk support?
if self.options.with_ffmpeg:
self.requires("ffmpeg/6.1")
if self.options.with_freeimage:
self.requires("freeimage/3.18.0")
if self.options.with_openvr:
self.requires("openvr/1.16.8")
if self.options.with_rapidjson:
self.requires("rapidjson/cci.20230929")
if self.options.get_safe("with_draco"):
self.requires("draco/1.5.6")
if self.options.with_tbb:
self.requires("onetbb/2021.10.0")

if self.options.with_samples:
self.requires("qt/6.7.1")

Expand All @@ -134,15 +116,10 @@ def source(self):

def generate(self):
tc = CMakeToolchain(self)
if Version(self.version) < "7.7.0":
# Inject C++ standard from profile since we have removed hardcoded C++ standard from upstream build files
if not valid_min_cppstd(self, self._min_cppstd):
tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd
if not valid_min_cppstd(self, self._min_cppstd):
tc.cache_variables["BUILD_CPP_STANDARD"] = "C++"+self._min_cppstd
else:
if not valid_min_cppstd(self, self._min_cppstd):
tc.cache_variables["BUILD_CPP_STANDARD"] = "C++"+self._min_cppstd
else:
tc.cache_variables["BUILD_CPP_STANDARD"] = "C++"+str(self.settings.compiler.cppstd)
tc.cache_variables["BUILD_CPP_STANDARD"] = "C++"+str(self.settings.compiler.cppstd)

tc.cache_variables["BUILD_LIBRARY_TYPE"] = "Shared" if self.options.shared else "Static"
tc.cache_variables["INSTALL_TEST_CASES"] = False
Expand Down Expand Up @@ -173,15 +150,15 @@ def generate(self):
tc.cache_variables["BUILD_ENABLE_FPE_SIGNAL_HANDLER"] = False
tc.cache_variables["BUILD_DOC_Overview"] = False

tc.cache_variables["USE_FREEIMAGE"] = self.options.with_freeimage
tc.cache_variables["USE_OPENVR"] = self.options.with_openvr
tc.cache_variables["USE_FFMPEG"] = self.options.with_ffmpeg
tc.cache_variables["USE_TBB"] = self.options.with_tbb
tc.cache_variables["USE_RAPIDJSON"] = self.options.with_rapidjson
if Version(self.version) >= "7.6.0":
tc.cache_variables["USE_DRACO"] = self.options.with_draco
tc.cache_variables["USE_TK"] = self.options.with_tk
tc.cache_variables["USE_OPENGL"] = self.options.with_opengl

tc.cache_variables["USE_FREEIMAGE"] = True
tc.cache_variables["USE_OPENVR"] = True
tc.cache_variables["USE_OPENGL"] = True
tc.cache_variables["USE_RAPIDJSON"] = True
tc.cache_variables["USE_DRACO"] = True
# tc.cache_variables["USE_TK"] = True
tc.cache_variables["USE_TBB"] = True

# Relocatable shared libs on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
Expand Down Expand Up @@ -256,51 +233,38 @@ def _patch_sources(self):
f"set (CSF_FREETYPE \"{freetype_libs}\")",
)
# tk
if self.options.with_tk:
deps_targets.append("tk::tk")
replace_in_file(self, cmakelists, "OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/tk\")", "find_package(tk REQUIRED)")
tk_libs = " ".join(self.dependencies["tk"].cpp_info.aggregated_components().libs)
csf_tk_libs = f"set (CSF_TclTkLibs \"{tk_libs}\")"
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs \"tk86\")", csf_tk_libs)
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs Tk)", csf_tk_libs)
if Version(self.version) >= "7.6.0":
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs \"tk8.6\")", csf_tk_libs)
else:
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs \"tk8.6\")", csf_tk_libs)
deps_targets.append("tk::tk")
replace_in_file(self, cmakelists, "OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/tk\")", "find_package(tk REQUIRED)")
tk_libs = " ".join(self.dependencies["tk"].cpp_info.aggregated_components().libs)
csf_tk_libs = f"set (CSF_TclTkLibs \"{tk_libs}\")"
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs \"tk86\")", csf_tk_libs)
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs Tk)", csf_tk_libs)
replace_in_file(self, occt_csf_cmake, "set (CSF_TclTkLibs \"tk8.6\")", csf_tk_libs)
## fontconfig
if self._is_linux:
deps_targets.append("Fontconfig::Fontconfig")
fontconfig_libs = " ".join(self.dependencies["fontconfig"].cpp_info.aggregated_components().libs)
if Version(self.version) >= "7.6.0":
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_fontconfig \"fontconfig\")",
f"find_package(Fontconfig REQUIRED)\nset (CSF_fontconfig \"{fontconfig_libs}\")",
)
else:
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_fontconfig \"fontconfig\")",
f"find_package(Fontconfig REQUIRED)\nset (CSF_fontconfig \"{fontconfig_libs}\")",
)
## onetbb
if self.options.with_tbb:
deps_targets.append("TBB::tbb")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/tbb\")",
"find_package(TBB REQUIRED)",
)
tbb_libs = " ".join(self.dependencies["onetbb"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_TBB \"tbb tbbmalloc\")",
f"set (CSF_TBB \"{tbb_libs}\")",
"set (CSF_fontconfig \"fontconfig\")",
f"find_package(Fontconfig REQUIRED)\nset (CSF_fontconfig \"{fontconfig_libs}\")",
)
## onetbb
deps_targets.append("TBB::tbb")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/tbb\")",
"find_package(TBB REQUIRED)",
)
tbb_libs = " ".join(self.dependencies["onetbb"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_TBB \"tbb tbbmalloc\")",
f"set (CSF_TBB \"{tbb_libs}\")",
)
## ffmpeg
if self.options.with_ffmpeg:
deps_targets.append("ffmpeg::ffmpeg")
Expand All @@ -318,63 +282,58 @@ def _patch_sources(self):
f"set (CSF_FFmpeg \"{ffmpeg_libs}\")",
)
## freeimage
if self.options.with_freeimage:
deps_targets.append("freeimage::freeimage")
replace_in_file(
self, cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/freeimage\")",
"find_package(freeimage REQUIRED)",
)
freeimage_libs = " ".join(self.dependencies["freeimage"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_FreeImagePlus \"freeimage\")",
f"set (CSF_FreeImagePlus \"{freeimage_libs}\")",
)
deps_targets.append("freeimage::freeimage")
replace_in_file(
self, cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/freeimage\")",
"find_package(freeimage REQUIRED)",
)
freeimage_libs = " ".join(self.dependencies["freeimage"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_FreeImagePlus \"freeimage\")",
f"set (CSF_FreeImagePlus \"{freeimage_libs}\")",
)
## openvr
if self.options.with_openvr:
deps_targets.append("openvr::openvr")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/openvr\")",
"find_package(openvr REQUIRED)",
)
openvr_libs = " ".join(self.dependencies["openvr"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_OpenVR \"openvr_api\")",
f"set (CSF_OpenVR \"{openvr_libs}\")",
)
deps_targets.append("openvr::openvr")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/openvr\")",
"find_package(openvr REQUIRED)",
)
openvr_libs = " ".join(self.dependencies["openvr"].cpp_info.aggregated_components().libs)
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_OpenVR \"openvr_api\")",
f"set (CSF_OpenVR \"{openvr_libs}\")",
)
## rapidjson
if self.options.with_rapidjson:
deps_targets.append("rapidjson")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/rapidjson\")",
"find_package(RapidJSON REQUIRED)",
)
deps_targets.append("rapidjson")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/rapidjson\")",
"find_package(RapidJSON REQUIRED)",
)
## draco
if self.options.get_safe("with_draco"):
deps_targets.append("draco::draco")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/draco\")",
"find_package(draco REQUIRED)",
)
deps_targets.append("draco::draco")
replace_in_file(
self,
cmakelists,
"OCCT_INCLUDE_CMAKE_FILE (\"adm/cmake/draco\")",
"find_package(draco REQUIRED)",
)
## opengl
replace_in_file(
self,
occt_csf_cmake,
"set (CSF_OpenGlLibs ",
"find_package(OpenGL)\n# set (CSF_OpenGlLibs ",
)
if self.options.with_opengl:
deps_targets.append("OpenGL::GL")
deps_targets.append("OpenGL::GL")

## Inject dependencies targets
replace_in_file(
Expand All @@ -385,56 +344,26 @@ def _patch_sources(self):
)

# Do not install pdb files
if Version(self.version) >= "7.6.0":
replace_in_file(
self,
occt_toolkit_cmake,
""" install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
CONFIGURATIONS Debug ${aReleasePdbConf} RelWithDebInfo
DESTINATION "${INSTALL_DIR_BIN}\\${OCCT_INSTALL_BIN_LETTER}")""",
"",
)
else:
replace_in_file(
self,
occt_toolkit_cmake,
""" install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
CONFIGURATIONS Debug RelWithDebInfo
DESTINATION "${INSTALL_DIR_BIN}\\${OCCT_INSTALL_BIN_LETTER}")""",
"",
)
# replace_in_file(
# self,
# occt_toolkit_cmake,
# """ install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
# CONFIGURATIONS Debug ${aReleasePdbConf} RelWithDebInfo
# DESTINATION "${INSTALL_DIR_BIN}\\${OCCT_INSTALL_BIN_LETTER}")""",
# "",
# )

# Honor fPIC option, compiler.cppstd and compiler.libcxx
replace_in_file(self, occt_defs_flags_cmake, "-fPIC", "")
if Version(self.version) < "7.8.0":
replace_in_file(self, occt_defs_flags_cmake, "-std=c++0x", "")
replace_in_file(self, occt_defs_flags_cmake, "-std=gnu++0x", "")
replace_in_file(self, occt_defs_flags_cmake, "-stdlib=libc++", "")
replace_in_file(self, occt_csf_cmake,
'set (CSF_ThreadLibs "pthread rt stdc++")',
'set (CSF_ThreadLibs "pthread rt")')

# No hardcoded link through #pragma
if Version(self.version) < "7.6.0":
replace_in_file(
self,
os.path.join(self.source_folder, "src", "Font", "Font_FontMgr.cxx"),
'#pragma comment (lib, "freetype.lib")',
"",
)
replace_in_file(
self,
os.path.join(self.source_folder, "src", "Draw", "Draw.cxx"),
'#pragma comment (lib, "tcl" STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib")\n'
'#pragma comment (lib, "tk" STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib")',
""
)

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.verbose = True
cmake.build()

def _replace_package_folder(self, source, target):
Expand Down Expand Up @@ -489,14 +418,14 @@ def _get_modules_from_source_code(self):
"CSF_fontconfig": {"externals": ["fontconfig::fontconfig"] if self._is_linux else []},
"CSF_XwLibs": {"externals": ["xorg::xorg"] if self._is_linux else []},
# Optional dependencies
"CSF_OpenGlLibs": {"externals": ["opengl::opengl"] if self.options.with_opengl else []},
"CSF_TclTkLibs": {"externals": ["tk::tk"] if self.options.with_tk else []},
"CSF_OpenGlLibs": {"externals": ["opengl::opengl"]},
"CSF_TclTkLibs": {"externals": ["tk::tk"]},
"CSF_FFmpeg": {"externals": ["ffmpeg::ffmpeg"] if self.options.with_ffmpeg else []},
"CSF_FreeImagePlus": {"externals": ["freeimage::freeimage"] if self.options.with_freeimage else []},
"CSF_OpenVR": {"externals": ["openvr::openvr"] if self.options.with_openvr else []},
"CSF_RapidJSON": {"externals": ["rapidjson::rapidjson"] if self.options.with_rapidjson else []},
"CSF_Draco": {"externals": ["draco::draco"] if self.options.get_safe("with_draco") else []},
"CSF_TBB": {"externals": ["onetbb::onetbb"] if self.options.with_tbb else []},
"CSF_FreeImagePlus": {"externals": ["freeimage::freeimage"]},
"CSF_OpenVR": {"externals": ["openvr::openvr"]},
"CSF_RapidJSON": {"externals": ["rapidjson::rapidjson"]},
"CSF_Draco": {"externals": ["draco::draco"]},
"CSF_TBB": {"externals": ["onetbb::onetbb"]},
"CSF_VTK": {},
# Android system libs
"CSF_androidlog": {"system_libs": ["log"] if self.settings.os == "Android" else []},
Expand Down
8 changes: 0 additions & 8 deletions recipes/opencascade/all/test_v1_package/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 2de9c54

Please sign in to comment.