Skip to content

Commit

Permalink
[opencascade] Cleanup and fixes (#35119)
Browse files Browse the repository at this point in the history
* [opencascade] Use version for git ref

* [opencascade] Skip samples for debug

* [opencascade] Drop bin letter d

* [opencascade] Don't install scripts

* [opencascade] qt not supported by port

* [opencascade] Update header fixup

* [opencascade] Enable osx and arm

* [opencascade] No scripts, again

* [opencascade] License

* [opencascade] Revise deps

* [opencascade] No freetype on uwp

* Trace

* Fixup

* [opencascade] only export include/opencascade

because this is what upstream provides in OPENCASCADE_INCLUDE_DIRECTORY

* [opencascade] Revise dependency setup

* [opencascade] Keep vcpkg legacy include dir

* Fixup
  • Loading branch information
dg0yt authored Nov 22, 2023
1 parent 7965613 commit 11cbb6b
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 170 deletions.
112 changes: 112 additions & 0 deletions ports/opencascade/dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb6ab2db..e58b1afa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -596,7 +596,8 @@ if (CAN_USE_FREETYPE)
if (USE_FREETYPE)
message (STATUS "Info: FreeType is used by OCCT")
add_definitions (-DHAVE_FREETYPE)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
+ find_package(Freetype MODULE REQUIRED)
+ set(CSF_FREETYPE Freetype::Freetype)
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREETYPE")
OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
@@ -613,7 +614,9 @@ endif()
if (USE_VTK)
add_definitions (-DHAVE_VTK)
set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
+ find_package(VTK REQUIRED)
+ set(CSF_VTK VTK::CommonCore)
+ set(IS_VTK_9XX 1)
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")

@@ -629,7 +632,8 @@ endif()
if (CAN_USE_FREEIMAGE)
if (USE_FREEIMAGE)
add_definitions (-DHAVE_FREEIMAGE)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
+ find_package(freeimage CONFIG REQUIRED)
+ set(CSF_FreeImagePlus freeimage::FreeImagePlus)
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
@@ -730,7 +734,8 @@ endif()
if (NOT DEFINED ANDROID AND CAN_USE_TBB)
if (USE_TBB)
add_definitions (-DHAVE_TBB)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
+ find_package(TBB CONFIG REQUIRED)
+ set(CSF_TBB TBB::tbb TBB::tbbmalloc)
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
@@ -750,7 +755,8 @@ OCCT_IS_PRODUCT_REQUIRED (CSF_RapidJSON CAN_USE_RAPIDJSON)
if (CAN_USE_RAPIDJSON)
if (USE_RAPIDJSON)
add_definitions (-DHAVE_RAPIDJSON)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/rapidjson")
+ find_package(RapidJSON CONFIG REQUIRED)
+ set(CSF_RapidJSON rapidjson)
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake
index c9399159..f707e00f 100644
--- a/adm/cmake/occt_toolkit.cmake
+++ b/adm/cmake/occt_toolkit.cmake
@@ -475,11 +475,11 @@ else()
endif()
endif()

-if (BUILD_SHARED_LIBS OR EXECUTABLE_PROJECT)
+if (1)
if(IS_VTK_9XX)
string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
endif()
- target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
+ target_link_libraries (${PROJECT_NAME} PRIVATE ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
endif()

if (USE_QT)
diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in
index c926c499..3b6db678 100644
--- a/adm/templates/OpenCASCADEConfig.cmake.in
+++ b/adm/templates/OpenCASCADEConfig.cmake.in
@@ -4,6 +4,22 @@
#
# This file is configured by OpenCASCADE.
#
+include(CMakeFindDependencyMacro)
+if("@USE_FREEIMAGE@")
+ find_dependency(freeimage CONFIG)
+endif()
+if("@USE_FREETYPE@")
+ find_dependency(Freetype MODULE)
+endif()
+if("@USE_RAPIDJSON@")
+ find_package(RapidJSON CONFIG REQUIRED)
+endif()
+if("@USE_TBB@")
+ find_dependency(TBB CONFIG)
+endif()
+if("@USE_VTK@")
+ find_dependency(VTK REQUIRED)
+endif()

if(OpenCASCADE_ALREADY_INCLUDED)
return()
diff --git a/src/Standard/Standard_MMgrTBBalloc.cxx b/src/Standard/Standard_MMgrTBBalloc.cxx
index 8c7a2df1..8499e1af 100644
--- a/src/Standard/Standard_MMgrTBBalloc.cxx
+++ b/src/Standard/Standard_MMgrTBBalloc.cxx
@@ -18,7 +18,6 @@

// paralleling with Intel TBB
#ifdef HAVE_TBB
-#pragma comment (lib, "tbbmalloc.lib")
#include <tbb/scalable_allocator.h>
using namespace tbb;
#else
45 changes: 45 additions & 0 deletions ports/opencascade/drop-bin-letter-d.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d2c4e570..8eac318c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -244,7 +244,6 @@ set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)

set (BIN_LETTER "")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
- set (BIN_LETTER "d")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
set (BIN_LETTER "i")
endif()
@@ -917,6 +916,7 @@ if (WIN32)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
+ set (CMAKE_PDB_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
endif()

string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake
index 9fd3ec4c..dc9ff18b 100644
--- a/adm/cmake/occt_macros.cmake
+++ b/adm/cmake/occt_macros.cmake
@@ -609,7 +609,7 @@ macro (OCCT_INSERT_CODE_FOR_TARGET)
elseif (\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$\")
set (OCCT_INSTALL_BIN_LETTER \"i\")
elseif (\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\")
- set (OCCT_INSTALL_BIN_LETTER \"d\")
+ set (OCCT_INSTALL_BIN_LETTER \"\")
endif()")
endmacro()

diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index beb934f7..95cec74a 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -172,7 +172,6 @@ set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)

set (BIN_LETTER "")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
- set (BIN_LETTER "d")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
set (BIN_LETTER "i")
endif()
15 changes: 0 additions & 15 deletions ports/opencascade/fix-depend-freetype.patch

This file was deleted.

16 changes: 0 additions & 16 deletions ports/opencascade/fix-depend-vtk.patch

This file was deleted.

30 changes: 0 additions & 30 deletions ports/opencascade/fix-dependence.patch

This file was deleted.

18 changes: 0 additions & 18 deletions ports/opencascade/fix-find-tbb.patch

This file was deleted.

13 changes: 5 additions & 8 deletions ports/opencascade/install-include-dir.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4ec871..59e5134 100644
index a80e39e6..bb6ab2db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1246,6 +1246,14 @@ foreach (OCCT_MODULE ${OCCT_MODULES})
@@ -1273,6 +1273,11 @@ foreach (OCCT_MODULE ${OCCT_MODULES})
endforeach()
set (OCCT_MODULES_ENABLED ${OCCT_MODULES_ENABLED_SORTED})

+foreach (OCCT_LIBRARY ${OCCT_LIBRARIES})
+ target_include_directories(
+ ${OCCT_LIBRARY}
+ INTERFACE
+ $<INSTALL_INTERFACE:include>
+ $<INSTALL_INTERFACE:include/opencascade>)
+foreach (OCCT_LIBRARY IN LISTS OCCT_LIBRARIES)
+ target_include_directories(${OCCT_LIBRARY} INTERFACE $<INSTALL_INTERFACE:include/opencascade>) # OpenCASCADE_INCLUDE_DIR
+ target_include_directories(${OCCT_LIBRARY} INTERFACE $<INSTALL_INTERFACE:include>) # vcpkg lock-in
+endforeach()
+
# Add all targets to the build-tree export set
Expand Down
Loading

0 comments on commit 11cbb6b

Please sign in to comment.