Skip to content

Commit

Permalink
Add 'occt' package (#295)
Browse files Browse the repository at this point in the history
* Add 'occt' package

* fix include order.

* Build shared libs by default

* dummy commit to occt...

* try to install additional dependency for linux...

* try with sudo...

* try to source it...

* debug...

* debug2

* debug...

* debug...

* debug2

* debug3

* add osx

* add another package...

* bugfix

* add more packages...

* try freetype on osx...

* build static libs by default...

* fix sha

* enable osx again

* use an older version of osx pipeline...

* remove extra comma

* enable everything...

* windows debug...

* use latest patched occt

* fix example for windows...

* fix.

* dummy commit to trigger ci

* only release ci build on windows

* fix

* use latest patched occt

* build windows ci unconditionally.

* dummy edit to trigger build.

* fix windows build of example by linking with ws2_32

* use cpp-pm repository.

* remove build matrix

* address change request
  • Loading branch information
craffael committed Nov 2, 2020
1 parent 181f4d9 commit d186762
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ hunter_default_version(nlohmann_fifo_map VERSION 0.0.0-0dfbf5d-p1)
hunter_default_version(nlohmann_json VERSION 3.8.0)
hunter_default_version(nng VERSION 1.1.1)
hunter_default_version(nsync VERSION 1.14-p1)
hunter_default_version(occt VERSION 7.4.0-p0)
hunter_default_version(odb VERSION 2.4.0)
hunter_default_version(odb-boost VERSION 2.4.0)
hunter_default_version(odb-compiler VERSION 2.4.0)
Expand Down
20 changes: 20 additions & 0 deletions cmake/projects/occt/ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Install additional dependencies:

if [ "$(uname)" == "Darwin" ]; then
# OSX
:
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# GNU/Linux
sudo apt-get update
sudo apt-get install mesa-common-dev libgl1-mesa-dev libxmu-dev libxi-dev
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
# Windows x32
:
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
# Windows x64
:
fi


# Run normal build script:
source ./.github/workflows/ci/build.sh
33 changes: 33 additions & 0 deletions cmake/projects/occt/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

include(hunter_add_version)
include(hunter_cacheable)
include(hunter_download)
include(hunter_pick_scheme)
include(hunter_cmake_args)

hunter_add_version(
PACKAGE_NAME
occt
VERSION
7.4.0-p0
URL
"https://github.com/cpp-pm/OCCT/archive/v7.4.0-p0.tar.gz"
SHA1
537bb3eeaff198b1733e49e857c19429bf2f7781
)

hunter_cmake_args(
occt
CMAKE_ARGS
BUILD_MODULE_Draw=Off
BUILD_DOC_Overview=Off
)


hunter_pick_scheme(DEFAULT url_sha1_cmake)
hunter_cacheable(occt)
hunter_download(PACKAGE_NAME occt)
31 changes: 31 additions & 0 deletions docs/packages/pkg/occt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. spelling::

occt

.. index::
single: math ; occt

.. _pkg.occt:

occt
====
OpenCascade Community Technology

- `Official <https://dev.opencascade.org/>`__
- `Hunterized <https://github.com/cpp-pm/occt>`__
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/occt/CMakeLists.txt>`__
- Added by `craffael <https://github.com/craffael>`__ (`pr-295 <https://github.com/cpp-pm/hunter/pull/295>`__)

.. literalinclude:: /../examples/occt/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }

.. note::

* OpenCascade consists of a number of modules. This Hunterized version supports all modules except
the `Draw Test Harness <https://www.opencascade.com/doc/occt-7.4.0/overview/html/technical_overview.html#OCCT_TOVW_SECTION_8>`__.
* To build shared versions of occt (recommended), please use :ref:`HUNTER_BUILD_SHARED_LIBS=ON <hunter build shared libs>`
or build with :ref:`toolchain with PIC <simple toolchains>`.
* On Ubuntu, make sure that you have installed the following system packages: :code:`mesa-common-dev`, :code:`libgl1-mesa-dev`, :code:`libxmu-dev`, :code:`libxi-dev`

23 changes: 23 additions & 0 deletions examples/occt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2016-2020, Rahul Sheth, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.2)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-occt)

# DOCUMENTATION_START {
hunter_add_package(occt)
find_package(OpenCASCADE CONFIG REQUIRED)

add_executable(boo boo.cpp)
target_link_libraries(boo occt::TKFillet occt::TKOffset occt::TKBool occt::TKBO occt::TKShHealing occt::TKPrim occt::TKTopAlgo occt::TKBRep occt::TKGeomAlgo occt::TKGeomBase occt::TKG3d occt::TKG2d occt::TKMath occt::TKernel)
if(APPLE OR (UNIX AND NOT ANDROID))
target_link_libraries(boo pthread)
elseif(WIN32)
target_link_libraries(boo ws2_32)
endif()
# DOCUMENTATION_END }
16 changes: 16 additions & 0 deletions examples/occt/boo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <GC_MakeSegment.hxx>
#include <gp_Pnt.hxx>
#include <Standard_Failure.hxx>

int main() {
try {
gp_Pnt a(0, 0, 0);
gp_Pnt b(1, 0, 0);

Handle(Geom_TrimmedCurve) edge = GC_MakeSegment(a, b);
}
catch (const Standard_Failure& e) {
std::cout << e.GetMessageString() << std::endl;
return 1;
}
}

0 comments on commit d186762

Please sign in to comment.