Skip to content

Commit ce7fdcc

Browse files
committed
build-deps - use OCC_INSTALL_DIR instead of includes/libs path
1 parent e503dad commit ce7fdcc

4 files changed

Lines changed: 32 additions & 30 deletions

File tree

cmake/FindOpenCASCADE.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ if(NOT OCC_INCLUDE_DIR AND NOT OCC_LIBRARY_DIR)
3636

3737
find_package(OpenCASCADE CONFIG REQUIRED)
3838
message(STATUS "Found OpenCASCADE config: ${OpenCASCADE_DIR}")
39+
40+
if(OpenCASCADE_VERSION VERSION_LESS "7.9.0")
41+
# Bug in OCCT cmake configs < 7.9.0 - missing linked library.
42+
list(APPEND OpenCASCADE_LIBRARIES WSOCK32.lib)
43+
endif()
44+
3945
return()
4046
endif()
4147

win/build-deps.cmd

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ IF DEFINED PYTHON_VERSION (
186186
)
187187

188188
:: VERSION DERIVATIONS
189-
set OCC_INCLUDE_DIR=%INSTALL_DIR%\opencascade-%OCCT_VERSION%\inc>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
190-
set OCC_LIBRARY_DIR=%INSTALL_DIR%\opencascade-%OCCT_VERSION%\win%ARCH_BITS%\lib>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
191189
IF "%IFCOS_INSTALL_PYTHON%"=="TRUE" (
192190
set PYTHONHOME=%DEPS_DIR%\python.%PYTHON_VERSION%\tools
193191
)
@@ -197,8 +195,6 @@ IF "%IFCOS_INSTALL_PYTHON%"=="TRUE" (
197195
:: executed by jumping (using goto) to different labels.
198196
if defined GEN_SHORTHAND echo GEN_SHORTHAND=%GEN_SHORTHAND%>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
199197
echo HDF5_VERSION=%HDF5_VERSION%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
200-
echo OCC_INCLUDE_DIR=%OCC_INCLUDE_DIR%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
201-
echo OCC_LIBRARY_DIR=%OCC_LIBRARY_DIR%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
202198
IF "%IFCOS_INSTALL_PYTHON%"=="TRUE" (
203199
echo PYTHONHOME=%PYTHONHOME%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
204200
)
@@ -481,9 +477,13 @@ call :MarkInstallation
481477
SET OCCT_VER=V%OCCT_VERSION:.=_%
482478

483479
set DEPENDENCY_NAME=OpenCASCADE
484-
set OCCT_DEPENDENCY_INSTALL_NAME=opencascade-%OCCT_VERSION%
480+
:: `new-layout` suffix can be removed on the next OCCT version update
481+
:: it's needed to separate legacy layout installation from the new one.
482+
set OCCT_DEPENDENCY_INSTALL_NAME=opencascade-%OCCT_VERSION%-new-layout
485483
set DEPENDENCY_INSTALL_NAME=%OCCT_DEPENDENCY_INSTALL_NAME%
484+
set DEPENDENCY_INSTALL_DIR=%INSTALL_DIR%\%DEPENDENCY_INSTALL_NAME%
486485
set NEXT_DEPENDENCY_LABEL=Python
486+
echo OCC_INSTALL_DIR=%DEPENDENCY_INSTALL_DIR%>>"%~dp0\%BUILD_DEPS_CACHE_PATH%"
487487

488488
call :CheckInstallation
489489
if %ERRORLEVEL%==200 GOTO %NEXT_DEPENDENCY_LABEL%
@@ -525,7 +525,10 @@ findstr IfcOpenShell "%DEPENDENCY_DIR%\CMakeLists.txt">NUL
525525
if not %ERRORLEVEL%==0 goto :Error
526526

527527
cd "%DEPENDENCY_DIR%"
528-
call :RunCMake -DINSTALL_DIR="%INSTALL_DIR%\%DEPENDENCY_INSTALL_NAME%" -DBUILD_LIBRARY_TYPE="Static" -DCMAKE_DEBUG_POSTFIX=d ^
528+
:: TODO: remove CMAKE_DEBUG_POSTFIX setting later.
529+
:: Temporarily explicitly set `CMAKE_DEBUG_POSTFIX` to empty to override it's perviously being set to `d`.
530+
:: OCCT don't need it, since it's layout is separating debug and release build by different folders.
531+
call :RunCMake -DINSTALL_DIR="%DEPENDENCY_INSTALL_DIR%" -DBUILD_LIBRARY_TYPE="Static" -DCMAKE_DEBUG_POSTFIX="" ^
529532
-DBUILD_MODULE_Draw=0 -D3RDPARTY_FREETYPE_DIR="%INSTALL_DIR%\freetype"
530533
if not %ERRORLEVEL%==0 goto :Error
531534

@@ -538,28 +541,23 @@ IF %ARCH_BITS%==32 (
538541

539542
call :BuildSolution "%DEPENDENCY_DIR%\%BUILD_DIR%\OCCT.sln" %BUILD_CFG%
540543
if not %ERRORLEVEL%==0 goto :Error
544+
545+
:: If `inc` is present in installation folder, then installation takes much longer
546+
:: See https://github.com/Open-Cascade-SAS/OCCT/issues/901
547+
powershell -c "$path = '%DEPENDENCY_INSTALL_DIR%\inc'; if (Test-Path $path) { Remove-Item -Recurse -Force $path }"
541548
call :InstallCMakeProject "%DEPENDENCY_DIR%\%BUILD_DIR%" %BUILD_CFG%
542549
if not %ERRORLEVEL%==0 goto :Error
550+
551+
:: Fix upstream bug in cmake config file with unescaped quotes preventing configuration.
552+
:: The issue is fixed in 7.9.0+.
553+
:: See https://github.com/Open-Cascade-SAS/OCCT/pull/373
554+
powershell -c "$path='%DEPENDENCY_INSTALL_DIR%\cmake\OpenCASCADEConfig.cmake'; (Get-Content $path) -replace '/wd\"(\d+)\"','/wd$1' | Set-Content $path"
555+
if not %ERRORLEVEL%==0 goto :Error
556+
543557
call :MarkInstallation
544558

545559
SET COMPILE_WITH_WPO=FALSE
546560

547-
:: Use a single lib directory for release and debug libraries as is done with OCE
548-
if not exist "%OCC_LIBRARY_DIR%". mkdir "%OCC_LIBRARY_DIR%"
549-
:: NOTE OCCT (at least occt-V7_0_0-9059ca1) directory creation code is hardcoded and doesn't seem handle future VC versions
550-
set OCCT_VC_VER=%VC_VER%
551-
IF %OCCT_VC_VER% GTR 14 (
552-
set OCCT_VC_VER=14
553-
)
554-
move /y "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\win%ARCH_BITS%\vc%OCCT_VC_VER%\libi\*.*" "%OCC_LIBRARY_DIR%"
555-
move /y "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\win%ARCH_BITS%\vc%OCCT_VC_VER%\libd\*.*" "%OCC_LIBRARY_DIR%"
556-
move /y "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\win%ARCH_BITS%\vc%OCCT_VC_VER%\lib\*.*" "%OCC_LIBRARY_DIR%"
557-
rmdir /s /q "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\win%ARCH_BITS%\vc%OCCT_VC_VER%"
558-
:: Removed unneeded bits
559-
rmdir /s /q "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\data"
560-
rmdir /s /q "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\samples"
561-
del "%INSTALL_DIR%\opencascade-%OCCT_VERSION%\*.bat"
562-
563561
:Python
564562
set DEPENDENCY_NAME=Python %PYTHON_VERSION%
565563
set DEPENDENCY_DIR=N/A

win/run-cmake.bat

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ if not defined BOOST_INSTALL_DIR (
8989
set BOOST_INSTALL_DIR=%DEPS_DIR%\boost_1_86_0\stage\%GEN_SHORTHAND%
9090
)
9191

92-
if not defined OCC_INCLUDE_DIR set OCC_INCLUDE_DIR=%INSTALL_DIR%\oce\include\oce
93-
if not defined OCC_LIBRARY_DIR set OCC_LIBRARY_DIR=%INSTALL_DIR%\oce\Win%ARCH_BITS%\lib
9492
set OPENCOLLADA_INSTALL_DIR=%INSTALL_DIR%\OpenCOLLADA
9593
set LIBXML2_INCLUDE_DIR=%DEPS_DIR%\OpenCOLLADA\Externals\LibXML\include
9694
set LIBXML2_LIBRARIES=%INSTALL_DIR%\OpenCOLLADA\lib\opencollada\xml.lib
@@ -133,8 +131,10 @@ echo.
133131
call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:"
134132
echo BOOST_INSTALL_DIR = %BOOST_INSTALL_DIR%
135133
echo BOOST_LIBRARYDIR = %BOOST_LIBRARYDIR%
134+
:: OCC_INCLUDE_DIR / OCC_LIBRARY_DIR are legacy vars, they're not defined by build-deps.cmd anymore.
136135
echo OCC_INCLUDE_DIR = %OCC_INCLUDE_DIR%
137136
echo OCC_LIBRARY_DIR = %OCC_LIBRARY_DIR%
137+
echo OCC_INSTALL_DIR = %OCC_INSTALL_DIR%
138138
echo OPENCOLLADA_INSTALL_DIR = %OPENCOLLADA_INSTALL_DIR%
139139
echo LIBXML2_INCLUDE_DIR = %LIBXML2_INCLUDE_DIR%
140140
echo LIBXML2_LIBRARIES = %LIBXML2_LIBRARIES%
@@ -171,6 +171,7 @@ set CMAKE_PREFIX_PATH=%HDF5_INSTALL_DIR%;%OPENCOLLADA_INSTALL_DIR%;%SWIG_INSTALL
171171
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROCKSDB_INSTALL_DIR%;%ZSTD_INSTALL_DIR%
172172
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%BOOST_INSTALL_DIR%;%CCACHE_INSTALL_DIR%
173173
set CMake_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%USD_INSTALL_DIR%;%TBB_INSTALL_DIR%
174+
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%OCC_INSTALL_DIR%
174175

175176
:: Not fully supported - not available from install-ifcopenshell
176177
:: and some logs are still showing Visual Studio generators.

win/utils/tools.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ function mark_based_on_artifacts {
5050
}
5151
}
5252
elseif ($dependency_name -eq "OpenCASCADE") {
53-
if ($env:BUILD_CFG -eq "Debug") {
54-
$artifact = "win64\lib\TKerneld.lib"
55-
}
56-
else {
57-
$artifact = "win64\lib\TKernel.lib"
58-
}
53+
# New OCCT folder layout was introduced after marker files were added,
54+
# so installation don't need artifact-based detection.
55+
return
5956
}
6057
elseif ($dependency_name -eq "rocksdb") {
6158
if ($env:BUILD_CFG -eq "Debug") {

0 commit comments

Comments
 (0)