diff --git a/README.en.md b/README.en.md index 206895f..4b1b02e 100644 --- a/README.en.md +++ b/README.en.md @@ -1,4 +1,5 @@ # of_cmake_config +[中文](README.md) | [英文](README.en.md) #### Description This project is used to generate CMakeLists.txt for OpenFOAM project. @@ -13,4 +14,8 @@ This project is used to generate CMakeLists.txt for OpenFOAM project. #### Instructions 1. Activate OpenFOAM environment -2. In project root path, run `ofCmakeConfig` +2. In project root path, + - run `ofCmakeConfig` to generate `CMakeLists.txt` + - or run `occ`, which is a wrapper of `ofCmakeConfig` script, to generate `CMakeLists.txt` and `compile_commands.json`. + +[video demo](demo/occ_demo.mp4) \ No newline at end of file diff --git a/README.md b/README.md index 31cb8a0..c302851 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # of_cmake_config +[中文](README.md) | [英文](README.en.md) #### 介绍 本项目用于生成OpenFOAM项目的CMakeLists.txt @@ -13,4 +14,13 @@ #### 使用说明 0. 激活OpenFOAM环境 -1. 在项目根目录下, 运行 `ofCmakeConfig` +1. 在项目根目录下, + - 运行 `ofCmakeConfig`,生成`CMakeLists.txt` + - 或运行`occ`,其包装了`ofCmakeConfig`,除了生成`CMakeLists.txt`,还会调用cmake,生成`compile_commands.json`。 + + +#### 测试环境 +- `vscode` + `clangd` +- `vim` + `coc-clangd` + +[视频演示](demo/occ_demo.mp4) diff --git a/demo/occ_demo.mp4 b/demo/occ_demo.mp4 new file mode 100644 index 0000000..1fd4074 Binary files /dev/null and b/demo/occ_demo.mp4 differ diff --git a/install b/install index 0521094..6ee4979 100755 --- a/install +++ b/install @@ -5,8 +5,9 @@ if [ -d $objDir ] then cwd=`pwd` chmod +x ./ofCmakeConfig - rm -f $objDir/ofCmakeConfig + rm -f $objDir/ofCmakeConfig $objDir/occ ln -s $cwd/ofCmakeConfig $objDir/ + ln -s $cwd/occ $objDir/ echo "installed ofCmakeConfig" else echo "please active OpenFOAM environment" diff --git a/occ b/occ new file mode 100644 index 0000000..f3c07fd --- /dev/null +++ b/occ @@ -0,0 +1,4 @@ +#!/bin/bash +ofCmakeConfig +rm -r build && mkdir build +cmake -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . \ No newline at end of file diff --git a/ofCmakeConfig b/ofCmakeConfig index 7318863..190f233 100755 --- a/ofCmakeConfig +++ b/ofCmakeConfig @@ -3,12 +3,6 @@ Script="${0##*/}" # Need 'Script' for wmakeFunctions messages scriptsDir="${0%/*}"/scripts # wmake/scripts directory . "$scriptsDir"/wmakeFunctions # Source wmake functions -# TODO: 检查当前路径是否是CMAKE_SOURCE_DIR -# 其中包含.vscode, CMakeLists.txt -# ... - -# TODO: 根据OF环境变量,设置安装目录 - printInfo() { if [ -f "$WM_DIR"/makefiles/info ] @@ -40,8 +34,6 @@ link_flags_extra="-Xlinker $link_flags_extra" OF_compile_flags=`printInfo "cxxflags"` OF_compile_flags="$OF_compile_flags -iquote." OF_link_flags="$OF_compile_flags $link_flags_extra" -# echo OF_compile_flags: $OF_compile_flags -# echo OF_link_flags: $OF_link_flags OF_project_name=`cat Make/files | grep EXE | grep -oP '(?<=/).*$'` OF_typestr="add_executable" @@ -51,10 +43,7 @@ then OF_typestr="add_library" fi -# echo OF_testCaseDir: '${CMAKE_SORCE_DIR}/testCase' OF_sources=`cat Make/files | grep -oP '.*\.C'` -# echo OF_sources: $OF_sources -# update OF_typestr if [ $OF_typestr = "add_executable" ] then OF_typestr="$OF_typestr(\${project_name} \${OF_sources})" @@ -79,57 +68,6 @@ OF_includeDir=`echo $OF_includeDir | sed 's/ /\n/g'` OF_linkLib=`echo $s | sed 's/ /\n/g' | grep -E '^-l' | sort | uniq |grep -oP '(?<=-l).*'` OF_linkDir=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib OF_linkDir=`echo "$OF_linkDir $FOAM_USER_LIBBIN" | sed 's/ /\n/g'` -# echo OF_linkLib: $OF_linkLib -# echo OF_linkDir: $OF_linkDir - -# 写入文件 .vscode/of-gdb.sh -mkdir -p .vscode -cat > .vscode/of-gdb.sh < .vscode/launch.json << EOF -{ - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Launch", - "type": "cppdbg", - "request": "launch", - // Resolved by CMake Tools: - "program": "\${command:cmake.launchTargetPath}", - "args": [], - "stopAtEntry": true, - "cwd": "\${workspaceFolder}/testCase", - "environment": [ - { - // add the directory where our target was built to the PATHs - // it gets resolved by CMake Tools: - "name": "PATH", - "value": "\${env:PATH}:\${command:cmake.getLaunchTargetDirectory}" - }, - { - "name": "OTHER_VALUE", - "value": "Something something" - } - ], - "externalConsole": false, - "MIMode": "gdb", - "miDebuggerPath": "\${workspaceFolder}/.vscode/of-gdb.sh", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} -EOF -chmod +x .vscode/of-gdb.sh # 写入文件 CMakeLists.txt cat > CMakeLists.txt <