# test-build-cpp **Repository Path**: joey-fudan/test-build-cpp ## Basic Information - **Project Name**: test-build-cpp - **Description**: test for https://gitee.com/joey-fudan/build-cpp - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-01-17 - **Last Updated**: 2025-04-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: Cpp ## README # Compile Result |Platform|Pass| |:-|-:| |macOS(13.6.2 arm64),cmake(3.31.3),Homebrew clang(19.1.7)|✔| |ubuntu(22.04 amd64),cmake(3.22),GCC(11.4.0)|✔| ## ubuntu compile setup Use gcc from apt. ## macOS compile setup Use llvm & lld from homebrew. When building from vscode, add the following to `.vscode/tasks.json` ```json { "version": "2.0.0", "tasks": [ { "label": "CMake: configure", "type": "shell", "command": "cmake", "args": [ "-S", ".", "-B", "build", "-DCMAKE_OSX_DEPLOYMENT_TARGET=13.7.0", // ignore lld warning "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", // generate cache for clangd "-DCMAKE_BUILD_TYPE=Debug", ], "options": { "cwd": "${workspaceFolder}", "env": { "CC": "/opt/homebrew/opt/llvm/bin/clang", "CXX": "/opt/homebrew/opt/llvm/bin/clang++", "LDFLAGS": "-L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/unwind -fuse-ld=lld", "PKG_CONFIG_PATH": "", } }, "group": "build", }, { "label": "CMake: build all", "type": "shell", "command": "cmake", "args": [ "--build", "build", ], "group": "build", } ] } ``` You can also setup `.clangd` in the project root path ```yaml CompileFlags: CompilationDatabase: build/ InlayHints: Enabled: No ``` When building from shell, add the env variables in the project root path ```shell export CC="/opt/homebrew/opt/llvm/bin/clang" export CXX="/opt/homebrew/opt/llvm/bin/clang++" export CFLAGS="-I$(pwd)/.build-tool/install/include" export CXXFLAGS="$CFLAGS" export LDFLAGS="-L$(pwd)/.build-tool/install/lib -L/opt/homebrew/opt/llvm/lib -L/opt/homebrew/opt/llvm/lib/unwind -fuse-ld=lld" export PKG_CONFIG_PATH="$(pwd)/.build-tool/install/lib/pkgconfig" ``` # Usage First, run `gSI` to pull down submodules, and then run `.build-tool/build.sh --all`. All the dependent libraries will be installed to `.build-tool/install`. Generate cmake binary directory: ```shell cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug ``` Build for the specific target(append `-j4` if want to speedup): ```shell cmake --build build --target main ``` or install/uninstall: ```shell cmake --build build --target install cmake --build build --target uninstall ``` or clean: ```shell cmake --build build --target clean ``` or all: ```shell cmake --build build ctest --test-dir build ```