Skip to content

Commit

Permalink
vcpkg: Adds optional dependency on opencascade
Browse files Browse the repository at this point in the history
I had to copy the opencascade port files from vcpkg to
* remove the default-dependency on freetype
* patch a typo where a number was being quoted in a CMake file
  • Loading branch information
kennyweiss committed Oct 9, 2024
1 parent b6ac8de commit f5c930e
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/vcpkg_ports/axom/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ set(_umpire_dep [=[
set(UMPIRE_DIR "@CURRENT_INSTALLED_DIR@" CACHE PATH "")
]=])


set(_opencascade_dep [=[

set(OPENCASCADE_DIR "@CURRENT_INSTALLED_DIR@" CACHE PATH "")
]=])

set(_openmp_dep [=[

# Setup OpenMP; fix MSVC linker error about unknown flag
Expand Down Expand Up @@ -198,7 +204,7 @@ else()
file(APPEND ${_hc_file}.in "${_conduit_dep_off}")
endif()

foreach(_dep lua mfem openmp raja umpire)
foreach(_dep lua mfem openmp raja umpire opencascade)
if(${_dep} IN_LIST FEATURES)
file(APPEND ${_hc_file}.in "${_${_dep}_dep}")
else()
Expand Down
11 changes: 11 additions & 0 deletions scripts/vcpkg_ports/axom/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lua",
"mfem",
"openmp",
"opencascade",
"raja"
],
"features": {
Expand All @@ -24,6 +25,16 @@
"description": "mfem functionality for axom",
"dependencies" : ["mfem"]
},
"opencascade": {
"description": "opencascade functionality for axom",
"dependencies": [
{
"name": "opencascade",
"default-features": false,
"features": []
}
]
},
"raja": {
"description": "raja functionality for axom",
"dependencies": ["raja"]
Expand Down
89 changes: 89 additions & 0 deletions scripts/vcpkg_ports/opencascade/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
string(REPLACE "." "_" VERSION_STR "V${VERSION}")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Open-Cascade-SAS/OCCT
REF "${VERSION_STR}"
SHA512 af176cbd105c49949282c16bb6e30f69167bc6c00a50e0ae69aea555815d47ac3c4540c233e596c5add7cb846c2b33d7be267d8e02472286e758b662b4a652ab
HEAD_REF master
PATCHES
dependencies.patch
drop-bin-letter-d.patch
fix-pdb-find.patch
fix-install-prefix-path.patch
install-include-dir.patch
)

if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
set(BUILD_TYPE "Shared")
else()
set(BUILD_TYPE "Static")
endif()

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
freeimage USE_FREEIMAGE
freetype USE_FREETYPE
rapidjson USE_RAPIDJSON
samples INSTALL_SAMPLES
tbb USE_TBB
vtk USE_VTK
)

### BEGIN AXOM PATCH

# replace a quoted number in a flag -- /wd"26812" with /wd26812
set(_file "${SOURCE_PATH}/adm/cmake/occt_defs_flags.cmake")
file(READ "${_file}" _filedata)
string(REPLACE [[/wd\"26812\"]] [[/wd26812]] _filedata "${_filedata}")
file(WRITE "${_file}" "${_filedata}")
### END AXOM PATCH


# We turn off BUILD_MODULE_Draw as it requires TCL 8.6 and TK 8.6 specifically which conflicts with vcpkg only having TCL 9.0
# And pre-built ActiveTCL binaries are behind a marketing wall :(
# We use the Unix install layout for Windows as it matches vcpkg
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DBUILD_LIBRARY_TYPE=${BUILD_TYPE}
-DBUILD_MODULE_Draw=OFF
-DBUILD_DOC_Overview=OFF
-DBUILD_MODULE_DETools=OFF
-DINSTALL_DIR_LAYOUT=Unix
-DINSTALL_DIR_DOC=share/trash
-DINSTALL_DIR_SCRIPT=share/trash # not relocatable
-DINSTALL_TEST_CASES=OFF
-DUSE_TK=OFF
OPTIONS_DEBUG
-DINSTALL_SAMPLES=OFF
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/opencascade)

#make occt includes relative to source_file
file(GLOB extra_headers
LIST_DIRECTORIES false
RELATIVE "${CURRENT_PACKAGES_DIR}/include/opencascade"
"${CURRENT_PACKAGES_DIR}/include/opencascade/*.h"
)
list(JOIN extra_headers "|" extra_headers)
file(GLOB files "${CURRENT_PACKAGES_DIR}/include/opencascade/*.[hgl]xx")
foreach(file_name IN LISTS files)
file(READ "${file_name}" filedata)
string(REGEX REPLACE "(# *include) <([a-zA-Z0-9_]*[.][hgl]xx|${extra_headers})>" [[\1 "\2"]] filedata "${filedata}")
file(WRITE "${file_name}" "${filedata}")
endforeach()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/opencascade/samples/qt")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/trash")

vcpkg_install_copyright(
FILE_LIST
"${SOURCE_PATH}/LICENSE_LGPL_21.txt"
"${SOURCE_PATH}/OCCT_LGPL_EXCEPTION.txt"
)
73 changes: 73 additions & 0 deletions scripts/vcpkg_ports/opencascade/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "opencascade",
"version": "7.8.0",
"description": "Open CASCADE Technology (OCCT) is an open-source software development platform for 3D CAD, CAM, CAE.",
"homepage": "https://github.com/Open-Cascade-SAS/OCCT",
"license": "LGPL-2.1-only",
"supports": "!xbox",
"dependencies": [
{
"name": "angle",
"platform": "uwp"
},
{
"name": "opengl",
"platform": "!(android | ios | uwp | wasm32)"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"default-features": [],
"features": {
"freeimage": {
"description": "Enable optional usage of freeimage",
"dependencies": [
"freeimage"
]
},
"freetype": {
"description": "Use of freetype",
"supports": "!uwp",
"dependencies": [
"fontconfig",
{
"name": "freetype",
"default-features": false
}
]
},
"rapidjson": {
"description": "Enable optional usage of rapidjson",
"dependencies": [
"rapidjson"
]
},
"samples": {
"description": "Enable optional samples"
},
"tbb": {
"description": "Enable optional usage of tbb",
"dependencies": [
"tbb"
]
},
"vtk": {
"description": "Enable optional usage of vtk",
"dependencies": [
{
"name": "vtk",
"default-features": false,
"features": [
"opengl"
]
}
]
}
}
}

0 comments on commit f5c930e

Please sign in to comment.