1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0031742: Configuration - Add batch files for cmake build

The scripts cmake_gen.bat and cmake_gen.sh have been added to facilitate batch building of OCCT correspondingly on Windows and Linux platforms.

The files build.bat and install.bat are copied to the build directory by cmake configure procedure to enable batch building and installation on Windows platform.
This commit is contained in:
msv 2020-04-01 19:13:46 +03:00 committed by bugmaster
parent b3da9c3ede
commit a75f5cdd86
7 changed files with 336 additions and 0 deletions

View File

@ -930,6 +930,9 @@ if (WIN32)
OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}") OCCT_CONFIGURE ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}")
# install env script # install env script
install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}") install (FILES "${CMAKE_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}")
# copy build.bat and install.bat scripts to CMake binary folder
OCCT_COPY_FILE_OR_DIR ("adm/templates/build.bat" "${CMAKE_BINARY_DIR}")
OCCT_COPY_FILE_OR_DIR ("adm/templates/install.bat" "${CMAKE_BINARY_DIR}")
else() else()
set (SUB_ENV_NAME "env.${SCRIPT_EXT}") set (SUB_ENV_NAME "env.${SCRIPT_EXT}")
set (SUB_ENV_BUILD_NAME "env.install.${SCRIPT_EXT}") set (SUB_ENV_BUILD_NAME "env.install.${SCRIPT_EXT}")

View File

@ -0,0 +1,46 @@
rem Environment configuration template for cmake_gen.bat (to be renamed as cmake_gen_custom.bat)
set "OCCT3RDPARTY=%SrcRoot%\..\3rdparty"
set VS=14
set VSDATA=2015
rem Leave VSPLATFORM empty to build for x86 platform
set VSPLATFORM=Win64
rem ------------------------------------
rem Uncomment to customize building steps
rem ------------------------------------
rem set "BUILD_DIR=build-vs%VS%-%VSPLATFORM%"
rem set "INSTALL_DIR=%SrcRoot%\install"
rem set BUILD_DOC_Overview=OFF
rem set BUILD_Inspector=OFF
rem set BUILD_LIBRARY_TYPE=Shared
rem set BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
rem set BUILD_WITH_DEBUG=OFF
rem set BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
rem set BUILD_USE_PCH=OFF
rem Use semicolon-separated list of toolkits if you want to disable all modules
rem and build only some toolkits.
rem set BUILD_ADDITIONAL_TOOLKITS=
rem Set a directory recognized as a patch for OCCT.
rem set BUILD_PATCH=
rem set BUILD_MODULE_ApplicationFramework=ON
rem set BUILD_MODULE_DataExchange=ON
rem set BUILD_MODULE_Draw=ON
rem set BUILD_MODULE_ModelingAlgorithms=ON
rem set BUILD_MODULE_ModelingData=ON
rem set BUILD_MODULE_Visualization=ON
rem set USE_D3D=OFF
rem set USE_FFMPEG=OFF
rem set USE_FREEIMAGE=OFF
rem set USE_GLES2=OFF
rem set USE_RAPIDJSON=OFF
rem set USE_TBB=OFF
rem set USE_VTK=OFF

View File

@ -0,0 +1,42 @@
# Environment configuration template for cmake_gen.sh (to be renamed as cmake_gen_custom.sh)
OCCT3RDPARTY="$SrcRoot/../3rdparty"
FREETYPE_DIR="$OCCT3RDPARTY/freetype-2.7.1"
# ------------------------------------
# Uncomment to customize building steps
# ------------------------------------
#BUILD_DIR=build
#INSTALL_DIR="$SrcRoot/install"
#BUILD_DOC_Overview=OFF
#BUILD_Inspector=OFF
#BUILD_LIBRARY_TYPE=Shared
#BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
#BUILD_WITH_DEBUG=OFF
#BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
# Use semicolon-separated list of toolkits if you want to disable all modules
# and build only some toolkits.
#BUILD_ADDITIONAL_TOOLKITS=
# Set a directory recognized as a patch for OCCT.
#BUILD_PATCH=
#BUILD_MODULE_ApplicationFramework=ON
#BUILD_MODULE_DataExchange=ON
#BUILD_MODULE_Draw=ON
#BUILD_MODULE_ModelingAlgorithms=ON
#BUILD_MODULE_ModelingData=ON
#BUILD_MODULE_Visualization=ON
#USE_FFMPEG=OFF
#USE_FREEIMAGE=OFF
#USE_GLES2=OFF
#USE_RAPIDJSON=OFF
#USE_TBB=OFF
#USE_VTK=OFF
# This is to add any additional arguments to cmake
#AUX_ARGS=

83
adm/scripts/cmake_gen.bat Normal file
View File

@ -0,0 +1,83 @@
@echo off
rem Auxiliary script for semi-automated building of OCCT using cmake.
rem cmake_custom.bat should be configured with VS version and path to 3rd-parties.
rem OCCT3RDPARTY must be specified as mandatory dependency.
setlocal
set "SrcRoot=%~dp0..\.."
set VS=14
set VSDATA=2015
set VSPLATFORM=Win64
set "BUILD_DIR=build-vs%VS%-%VSPLATFORM%"
set "INSTALL_DIR=%SrcRoot%\install"
set BUILD_ADDITIONAL_TOOLKITS=
set BUILD_DOC_Overview=OFF
set BUILD_Inspector=OFF
set BUILD_LIBRARY_TYPE=Shared
set BUILD_PATCH=
set BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
set BUILD_WITH_DEBUG=OFF
set BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
set BUILD_USE_PCH=OFF
set BUILD_MODULE_ApplicationFramework=ON
set BUILD_MODULE_DataExchange=ON
set BUILD_MODULE_Draw=ON
set BUILD_MODULE_ModelingAlgorithms=ON
set BUILD_MODULE_ModelingData=ON
set BUILD_MODULE_Visualization=ON
set USE_D3D=OFF
set USE_FFMPEG=OFF
set USE_FREEIMAGE=OFF
set USE_GLES2=OFF
set USE_RAPIDJSON=OFF
set USE_TBB=OFF
set USE_VTK=OFF
if exist "%~dp0cmake_custom.bat" call "%~dp0cmake_custom.bat"
if not "%VSPLATFORM%"=="" set "arch_compile=Visual Studio %VS% %VSDATA% %VSPLATFORM%"
if "%VSPLATFORM%"=="" set "arch_compile=Visual Studio %VS% %VSDATA%"
set "INSTALL_DIR=%INSTALL_DIR:\=/%"
set "OCCT3RDPARTY=%OCCT3RDPARTY:\=/%"
set "BUILD_DIR=%SrcRoot%\%BUILD_DIR%"
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
pushd "%BUILD_DIR%"
cmake -G "%arch_compile%" ^
-D 3RDPARTY_DIR:STRING="%OCCT3RDPARTY%" ^
-D BUILD_ADDITIONAL_TOOLKITS:STRING="%BUILD_ADDITIONAL_TOOLKITS%" ^
-D BUILD_DOC_Overview:BOOL=%BUILD_DOC_Overview% ^
-D BUILD_Inspector:BOOL=%BUILD_Inspector% ^
-D BUILD_LIBRARY_TYPE:STRING=%BUILD_LIBRARY_TYPE% ^
-D BUILD_MODULE_ApplicationFramework:BOOL=%BUILD_MODULE_ApplicationFramework% ^
-D BUILD_MODULE_DataExchange:BOOL=%BUILD_MODULE_DataExchange% ^
-D BUILD_MODULE_Draw:BOOL=%BUILD_MODULE_Draw% ^
-D BUILD_MODULE_FoundationClasses:BOOL=ON ^
-D BUILD_MODULE_ModelingAlgorithms:BOOL=%BUILD_MODULE_ModelingAlgorithms% ^
-D BUILD_MODULE_ModelingData:BOOL=%BUILD_MODULE_ModelingData% ^
-D BUILD_MODULE_Visualization:BOOL=%BUILD_MODULE_Visualization% ^
-D BUILD_PATCH:PATH="%BUILD_PATCH%" ^
-D BUILD_RELEASE_DISABLE_EXCEPTIONS:BOOL=%BUILD_RELEASE_DISABLE_EXCEPTIONS% ^
-D BUILD_WITH_DEBUG:BOOL=%BUILD_WITH_DEBUG% ^
-D BUILD_ENABLE_FPE_SIGNAL_HANDLER:BOOL=%BUILD_ENABLE_FPE_SIGNAL_HANDLER% ^
-D BUILD_USE_PCH:BOOL=%BUILD_USE_PCH% ^
-D INSTALL_DIR:PATH="%INSTALL_DIR%" ^
-D USE_D3D:BOOL=%USE_D3D% ^
-D USE_FFMPEG:BOOL=%USE_FFMPEG% ^
-D USE_FREEIMAGE:BOOL=%USE_FREEIMAGE% ^
-D USE_GLES2:BOOL=%USE_GLES2% ^
-D USE_RAPIDJSON:BOOL=%USE_RAPIDJSON% ^
-D USE_TBB:BOOL=%USE_TBB% ^
-D USE_VTK:BOOL=%USE_VTK% ^
"%SrcRoot%"
popd
endlocal

86
adm/scripts/cmake_gen.sh Executable file
View File

@ -0,0 +1,86 @@
#!/bin/bash
# Auxiliary script for semi-automated building of OCCT using cmake.
# cmake_custom.sh should be configured with path to 3rd-parties.
# OCCT3RDPARTY and FREETYPE_DIR must be specified as mandatory dependencies.
ScriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
SrcRoot="${ScriptDir}/../.."
INSTALL_DIR="$SrcRoot/install"
BUILD_DIR=build
DEB=
CMAKE_BUILD_TYPE=Release
if [ "$1" = "-d" ]; then
DEB=d
BUILD_DIR=${BUILD_DIR}-deb
CMAKE_BUILD_TYPE=Debug
fi
INSTALL_DIR_BIN=lin64/gcc/bin$DEB
INSTALL_DIR_LIB=lin64/gcc/lib$DEB
BUILD_ADDITIONAL_TOOLKITS=
BUILD_DOC_Overview=OFF
BUILD_Inspector=OFF
BUILD_LIBRARY_TYPE=Shared
BUILD_PATCH=
BUILD_RELEASE_DISABLE_EXCEPTIONS=ON
BUILD_WITH_DEBUG=OFF
BUILD_ENABLE_FPE_SIGNAL_HANDLER=ON
BUILD_MODULE_ApplicationFramework=ON
BUILD_MODULE_DataExchange=ON
BUILD_MODULE_Draw=ON
BUILD_MODULE_ModelingAlgorithms=ON
BUILD_MODULE_ModelingData=ON
BUILD_MODULE_Visualization=ON
USE_FFMPEG=OFF
USE_FREEIMAGE=OFF
USE_GLES2=OFF
USE_RAPIDJSON=OFF
USE_TBB=OFF
USE_VTK=OFF
AUX_ARGS=
if [ -f "${ScriptDir}/cmake_custom.sh" ]; then
. "${ScriptDir}/cmake_custom.sh"
fi
BUILD_DIR="$SrcRoot/$BUILD_DIR"
if [ ! -d "$BUILD_DIR" ]; then mkdir -p "$BUILD_DIR"; fi
pushd "$BUILD_DIR"
cmake -G "Unix Makefiles" \
-D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-D 3RDPARTY_DIR:PATH="$OCCT3RDPARTY" \
-D 3RDPARTY_FREETYPE_DIR:PATH="$FREETYPE_DIR" \
-D BUILD_ADDITIONAL_TOOLKITS:STRING="$BUILD_ADDITIONAL_TOOLKITS" \
-D BUILD_DOC_Overview:BOOL=$BUILD_DOC_Overview \
-D BUILD_Inspector:BOOL=$BUILD_Inspector \
-D BUILD_LIBRARY_TYPE:STRING=$BUILD_LIBRARY_TYPE \
-D BUILD_MODULE_ApplicationFramework:BOOL=$BUILD_MODULE_ApplicationFramework \
-D BUILD_MODULE_DataExchange:BOOL=$BUILD_MODULE_DataExchange \
-D BUILD_MODULE_Draw:BOOL=$BUILD_MODULE_Draw \
-D BUILD_MODULE_FoundationClasses:BOOL=ON \
-D BUILD_MODULE_ModelingAlgorithms:BOOL=$BUILD_MODULE_ModelingAlgorithms \
-D BUILD_MODULE_ModelingData:BOOL=$BUILD_MODULE_ModelingData \
-D BUILD_MODULE_Visualization:BOOL=$BUILD_MODULE_Visualization \
-D BUILD_PATCH:PATH="$BUILD_PATCH" \
-D BUILD_RELEASE_DISABLE_EXCEPTIONS:BOOL=$BUILD_RELEASE_DISABLE_EXCEPTIONS \
-D BUILD_WITH_DEBUG:BOOL=$BUILD_WITH_DEBUG \
-D BUILD_ENABLE_FPE_SIGNAL_HANDLER:BOOL=$BUILD_ENABLE_FPE_SIGNAL_HANDLER \
-D INSTALL_DIR:PATH="$INSTALL_DIR" \
-D INSTALL_DIR_LAYOUT:STRING=Windows \
-D INSTALL_DIR_BIN:STRING=$INSTALL_DIR_BIN \
-D INSTALL_DIR_LIB:STRING=$INSTALL_DIR_LIB \
-D USE_FFMPEG:BOOL=$USE_FFMPEG \
-D USE_FREEIMAGE:BOOL=$USE_FREEIMAGE \
-D USE_GLES2:BOOL=$USE_GLES2 \
-D USE_RAPIDJSON:BOOL=$USE_RAPIDJSON \
-D USE_TBB:BOOL=$USE_TBB \
-D USE_VTK:BOOL=$USE_VTK \
$AUX_ARGS "$SrcRoot"
popd

38
adm/templates/build.bat Normal file
View File

@ -0,0 +1,38 @@
@echo off
setlocal
rem Setup environment
call "%~dp0env.bat" %1 %2 %3
rem Define path to project file
set "PRJFILE=%~dp0OCCT.sln"
if "%VCVER%" == "vc8" (
call "%VS80COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc9" (
call "%VS90COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc10" (
call "%VS100COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc11" (
call "%VS110COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc12" (
call "%VS120COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc14" (
call "%VS140COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc141" (
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc142" (
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
) else (
echo Error: wrong VS identifier
exit /B
)
set BUILDCONFIG=Release
if "%CASDEB%"=="i" set BUILDCONFIG=RelWithDebInfo
if "%CASDEB%"=="d" set BUILDCONFIG=Debug
if "%ARCH%"=="32" set PLATFORM=win32
if "%ARCH%"=="64" set PLATFORM=x64
msbuild "%PRJFILE%" /m /fl /flp:LogFile="build_%BUILDCONFIG%.log" /p:Configuration=%BUILDCONFIG% /p:Platform=%PLATFORM% /p:BuildProjectReferences=false
endlocal

38
adm/templates/install.bat Normal file
View File

@ -0,0 +1,38 @@
@echo off
setlocal
rem Setup environment
call "%~dp0env.bat" %1 %2 %3
rem Define path to project file
set "PRJFILE=%~dp0INSTALL.vcxproj"
if "%VCVER%" == "vc8" (
call "%VS80COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc9" (
call "%VS90COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc10" (
call "%VS100COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc11" (
call "%VS110COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc12" (
call "%VS120COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc14" (
call "%VS140COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc141" (
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc142" (
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
) else (
echo Error: wrong VS identifier
exit /B
)
set BUILDCONFIG=Release
if "%CASDEB%"=="i" set BUILDCONFIG=RelWithDebInfo
if "%CASDEB%"=="d" set BUILDCONFIG=Debug
if "%ARCH%"=="32" set PLATFORM=win32
if "%ARCH%"=="64" set PLATFORM=x64
msbuild "%PRJFILE%" /m /fl /flp:LogFile="install_%BUILDCONFIG%.log" /p:Configuration=%BUILDCONFIG% /p:Platform=%PLATFORM% /p:BuildProjectReferences=false
endlocal