Windows下编译SALOME
本文以笔记的形式记录在Windows下编译SALOME的流程。
零、环境
操作系统 | WIndows 10 |
Visual Studio | Visual Studio 2022 Community |
Visual Studio Code | 1.92.1 |
CMake | CMake-3.24.2 |
一、工具及依赖
1.1 VS Code
下载并安装Visual Studio Code, 同时安装以下插件,
Task Explorer Output Colorizer Git Extension Pack Git Graph Remote Developement Remote X11 Code Runner | |
Modern Fortran FORTRAN InstelliSense Fortran Breakpoint Support | |
C/C++ Extension Pack C++ TestMate | |
Python Extension Pack | |
C# Dev Kit | |
Extension Pack for Intel Software Developer Tools | |
Nsight Visual Studio Code Edition |
1.2 VCPKG
下载vcpkg到D:\,并完成配置
git clone https://github.com/Microsoft/vcpkg.git
cd D:\vcpkg
mkdir D:\vcpkg\binary-cache
mkdir D:\vcpkg\asset-cache
set "VCPKG_BINARY_SOURCES=clear;files,D:\vcpkg\binary-cache,readwrite"
set "X_VCPKG_ASSET_SOURCES=clear;x-azurl,file://D:/vcpkg/asset-cache,,readwrite"
bootstrap-vcpkg.bat
注意:限于从国外网站下载速度较慢,考虑使用代理,
set "HTTP_PROXY=http://192.168.X.X:7890"
set "HTTPS_PROXY=http://192.168.X.X:7890"
通过vcpkg可以方便的安装第三方库,常用命令如下表
安装package | vcpkg install <package-name> |
搜索package | vcpkg search <package-name> |
已安装package | vcpkg list |
然后,按照下表安装第三方依赖库
Package | Description |
python | vcpkg install python3 |
pthread | vcpkg install pthread |
cppunit | vcpkg install cppunit |
boost | vcpkg install boost |
qt | |
occ | |
vtk |
二、下载SALOME
由于SALOME每个模块采用了单独的Git仓库进行代码托管,因此,需要手动下载SALOME相关模块。
新建fetch-salome.sh文件,并添加以下内容,
git clone https://github.com/SalomePlatform/.github.git
git clone https://github.com/SalomePlatform/adao.git
git clone https://github.com/SalomePlatform/adao_interface.git
git clone https://github.com/SalomePlatform/blsurfplugin.git
git clone https://github.com/SalomePlatform/calculator.git
git clone https://github.com/SalomePlatform/common_geometry_lib.git
git clone https://github.com/SalomePlatform/component.git
git clone https://github.com/SalomePlatform/configuration.git
git clone https://github.com/SalomePlatform/datafiles.git
git clone https://github.com/SalomePlatform/documentation.git
git clone https://github.com/SalomePlatform/eficas.git
git clone https://github.com/SalomePlatform/eficas_tools.git
git clone https://github.com/SalomePlatform/geom.git
git clone https://github.com/SalomePlatform/ghs3dplugin.git
git clone https://github.com/SalomePlatform/gmshplugin.git
git clone https://github.com/SalomePlatform/gui.git
git clone https://github.com/SalomePlatform/hello.git
git clone https://github.com/SalomePlatform/hexablock.git
git clone https://github.com/SalomePlatform/hexablockplugin.git
git clone https://github.com/SalomePlatform/hexoticplugin.git
git clone https://github.com/SalomePlatform/homard.git
git clone https://github.com/SalomePlatform/hybridplugin.git
git clone https://github.com/SalomePlatform/jobmanager.git
git clone https://github.com/SalomePlatform/kernel.git
git clone https://github.com/SalomePlatform/libbatch.git
git clone https://github.com/SalomePlatform/med.git
git clone https://github.com/SalomePlatform/MEDCoupling_tutos.git
git clone https://github.com/SalomePlatform/medreader.git
git clone https://github.com/SalomePlatform/medcoupling.git
git clone https://github.com/SalomePlatform/meshbooleanplugin.git
git clone https://github.com/SalomePlatform/mmgplugin.git
git clone https://github.com/SalomePlatform/netgenplugin.git
git clone https://github.com/SalomePlatform/openturns_salome.git
git clone https://github.com/SalomePlatform/paravis.git
git clone https://github.com/SalomePlatform/paravisaddons_common.git
git clone https://github.com/SalomePlatform/pmml.git
git clone https://github.com/SalomePlatform/py2cpp.git
git clone https://github.com/SalomePlatform/pycalculator.git
git clone https://github.com/SalomePlatform/pyhello.git
git clone https://github.com/SalomePlatform/SALOME.git
git clone https://github.com/SalomePlatform/salome_bootstrap.git
git clone https://github.com/SalomePlatform/sat.git
git clone https://github.com/SalomePlatform/sat_salome.git
git clone https://github.com/SalomePlatform/shaper.git
git clone https://github.com/SalomePlatform/shaper_study.git
git clone https://github.com/SalomePlatform/smesh.git
git clone https://github.com/SalomePlatform/solverlab.git
git clone https://github.com/SalomePlatform/top_ii_vol.git
git clone https://github.com/SalomePlatform/yacs.git
git clone https://github.com/SalomePlatform/yacsgen.git
git clone https://github.com/SalomePlatform/ydefx.git
在fetch-salome.sh所在目录,右键启动Git Bash,然后运行上述脚本,下载相关模块代码,
sh ./fetch-salome.sh
注1:国内访问GitHub需要通过'https_proxy'环境变量设置网络代理。
export https_proxy=http://X.X.X.X:7890
三、编译salome_bootstrap
3.1 CMake配置
Variable | Value | |
ABS_APPLI_PATH | D:/YouQuan/CaeFrameworks/SALOME/VS2022SALOMEBOOTSTRAP | |
WRAP_PYTHON | OFF | |
PYTHON_EXECUTABLE | D:/vcpkg/installed/x64-windows/tools/python3/python.exe |
四、编译kernel
4.1 CMake配置
Variable | Value |
CMAKE_INSTALL_PREFIX | D:/YouQuan/CaeFrameworks/SALOME/VS2022KERNEL |
SALOME_LIGHT_ONLY | ON |
SALOME_BUILD_TESTS | OFF |
SALOME_BUILD_DOC | OFF |
PTHREAD_LIBRARIES | |
OMNIORB_ROOT_DIR | |
OMNIORB_LIBRARY_COS4 | |
OMNIORB_LIBRARY_COSDynamic4 | |
OMNIORB_LIBRARY_omniDynamic4 | |
OMNIORB_LIBRARY_omniORB4 | |
OMNIORB_LIBRARY_omnithread | |
CPPUNIT_LIBRARIES | |
五、编译gui
5.1 CMake配置
Variable | Value |
CMAKE_INSTALL_PREFIX | D:/YouQuan/CaeFrameworks/SALOME/VS2022/GUI |
附录Ⅰ:VS2022.bat
新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\VS2022.bat"文件,添加以下内容,
@echo off
:: SALOME SOURCES Root
set SALOME_SRCS_ROOT=%cd%
:: VCPKG Root
set VCPKG_ROOT=D:/vcpkg
:: Path to toolchain file supplied to CMake
set CMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake
set INCLUDE=%VCPKG_ROOT%/installed/x64-windows/include;%INCLUDE%
set LIB=%VCPKG_ROOT%/installed/x64-windows/debug/lib;%LIB%
:: Add the path of your MinGW-w64 bin folder to the Windows PATH environment variable
set PATH=%VCPKG_ROOT%/installed/x64-windows/debug/bin;%PATH%
:: Packages
set PYTHON_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
::set PYTHONINTERP_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set PTHREAD_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set CPPUNIT_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
set BOOST_ROOT_DIR=%VCPKG_ROOT%/installed/x64-windows
:: Modules
set CONFIGURATION_ROOT_DIR=%cd%/configuration
set CPPUNIT_ROOT_DIR=%MinGW64_ROOT%
:: Open VS Code in the current working folder
code .vscode/salome.code-workspace
附录Ⅱ: VS Code Multi-root workspaces
新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\salome.code-workspace"文件,添加以下内容,
{
"folders": [
{
"path": "../configuration"
},
{
"path": "../.github"
},
{
"path": "../adao"
},
{
"path": "../adao_interface"
},
{
"path": "../blsurfplugin"
},
{
"path": "../calculator"
},
{
"path": "../common_geometry_lib"
},
{
"path": "../component"
},
{
"path": "../datafiles"
},
{
"path": "../documentation"
},
{
"path": "../eficas"
},
{
"path": "../eficas_tools"
},
{
"path": "../geom"
},
{
"path": "../ghs3dplugin"
},
{
"path": "../gmshplugin"
},
{
"path": "../gui"
},
{
"path": "../hello"
},
{
"path": "../hexablock"
},
{
"path": "../hexablockplugin"
},
{
"path": "../hexoticplugin"
},
{
"path": "../homard"
},
{
"path": "../hybridplugin"
},
{
"path": "../jobmanager"
},
{
"path": "../kernel"
},
{
"path": "../libbatch"
},
{
"path": "../med"
},
{
"path": "../medcoupling"
},
{
"path": "../MEDCoupling_tutos"
},
{
"path": "../medreader"
},
{
"path": "../meshbooleanplugin"
},
{
"path": "../mmgplugin"
},
{
"path": "../netgenplugin"
},
{
"path": "../openturns_salome"
},
{
"path": "../paravis"
},
{
"path": "../paravisaddons_common"
},
{
"path": "../pmml"
},
{
"path": "../py2cpp"
},
{
"path": "../pycalculator"
},
{
"path": "../pyhello"
},
{
"path": "../SALOME"
},
{
"path": "../salome_bootstrap"
},
{
"path": "../sat"
},
{
"path": "../sat_salome"
},
{
"path": "../shaper"
},
{
"path": "../shaper_study"
},
{
"path": "../smesh"
},
{
"path": "../solverlab"
},
{
"path": "../top_ii_vol"
},
{
"path": "../yacs"
},
{
"path": "../yacsgen"
},
{
"path": "../ydefx"
},
{
"path": "."
}
],
"settings": {}
}
附录Ⅲ: c_cpp_properties.json
新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\c_cpp_properties.json"文件,添加以下内容,
{
"configurations": [
{
"name": "MSVC",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "MinGW-w64",
"includePath": [
"${workspaceFolder}/**",
"D:/msys64/mingw64/include"
],
"defines": [],
"compilerPath": "D:/msys64/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compilerPathInCppPropertiesJson": "D:/msys64/mingw64/bin/g++.exe",
"configurationProviderInCppPropertiesJson": "ms-vscode.cmake-tools",
"mergeConfigurations": false,
"browse": {
"path": [
"D:/msys64/mingw64/include",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
}
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
},
{
"name": "Linux-GCC",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
附录Ⅳ: cmake-kits.json
新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\.vscode\cmake-kits.json"文件,添加以下内容,
[
{
"name": "MinGW-64",
"compilers": {
"C": "D:\\msys64\\mingw64\\bin\\gcc.exe",
"CXX": "D:\\msys64\\mingw64\\bin\\g++.exe"
},
"isTrusted": true,
"environmentVariables": {
"CMT_MINGW_PATH": "C:\\msys64\\mingw64\\bin",
"MSYSTEM": "MINGW64",
"MSYSTEM_PREFIX": "/mingw64",
"PATH": "D:\\msys64\\mingw64\\bin;D:\\msys64\\usr\\bin;${env:PATH}"
},
"preferredGenerator": {
"name": "MinGW Makefiles"
}
},
{
"name": "GCC 11.4.0 x86_64-linux-gnu",
"compilers": {
"C": "/usr/bin/gcc",
"CXX": "/usr/bin/g++"
},
"isTrusted": true
},
{
"name": "Intel(R) oneAPI DPC++/C++ Compiler 2024.2.1",
"compilers": {
"C": "/opt/intel/oneapi/compiler/2024.2/bin/icx",
"CXX": "/opt/intel/oneapi/compiler/2024.2/bin/icpx"
},
"isTrusted": true
}
附录V: CMakeUserPresets.json
新建"D:\YouQuan\CaeFrameworks\SALOME\SOURCES\CMakeUserPresets.json"文件,添加以下内容,
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "mingw64",
"hidden": false,
"displayName": "MinGW-w64",
"description": "This build is using MinGW generator",
"generator": "MinGW Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_BUILD_TYPE": "Debug"
},
"environment": {
}
},
{
"name": "linux_gcc",
"hidden": false,
"displayName": "Linux GCC",
"description": "Default build using Unix Makefiles generator",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_C_COMPILER": "/usr/bin/gcc",
"CMAKE_CXX_COMPILER": "/usr/bin/g++",
"CMAKE_MAKE_PROGRAM": "/usr/bin/make",
"CMAKE_BUILD_TYPE": "Debug"
},
"environment": {
}
}
],
"buildPresets": [
{
"name": "mingw64",
"displayName": "MinGW-w64",
"configurePreset": "mingw64"
},
{
"name": "linux_gcc",
"displayName": "Linux GCC",
"configurePreset": "linux_gcc"
}
],
"testPresets": [
{
"name": "mingw64",
"displayName": "MinGW-w64",
"configurePreset": "mingw64"
},
{
"name": "linux_gcc",
"displayName": "Linux GCC",
"configurePreset": "linux_gcc"
}
]
}
参考资料
SALOME
VS Code Multi-root workspaces