Skip to content

owent/atframe_utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,276 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atframe_utils

cxx utils code

ci-badge codecov badge

CI Job Matrix

Target System Toolchain Note
Linux GCC -
Linux GCC With MbedTLS
Linux Clang With libc++
MinGW64 GCC Static linking
MinGW64 GCC Dynamic linking
Windows Visual Studio 2022 Static linking
Windows Visual Studio 2022 Dynamic linking
macOS AppleClang With libc++

Usage

  • require cmake 3.24.0 or upper
  • require gcc 7.1+/clang 7+/apple clang 12.0+/MSVC(VS2022+)
# clone and make build directory
git clone --single-branch --depth=1 -b master https://github.com/atframework/atframe_utils.git
mkdir atframe_utils/build && cd atframe_utils/build

# run cmake
# cmake <atframe_utils dir> [options...]
cmake .. -DPROJECT_ENABLE_SAMPLE=YES -DPROJECT_ENABLE_UNITTEST=YES -DPROJECT_ENABLE_TOOLS=ON #  -DCMAKE_INSTALL_PREFIX=<install prefix>

# build
cmake --build . # using clang or gcc
# cmake --build . --config RelWithDebInfo # using MSVC

# run unit test
ctest . -V

# run unit test
cmake --build . --target INSTALL # using clang or gcc
# cmake --build . --config RelWithDebInfo --target INSTALL # using MSVC

Clangd 配置参考

本仓库默认使用 build_jobs_cmake_tools 作为编译数据库目录(由 CMake 生成 compile_commands.json)。建议保持与当前设置一致:

.clangd(可选)

CompileFlags:
	CompilationDatabase: build_jobs_cmake_tools

Index:
	Background: Build

Diagnostics:
	UnusedIncludes: Strict

VS Code settings

{
	"C_Cpp.intelliSenseEngine": "disabled",
	"clangd.enable": true,
	"clangd.arguments": [
		"--compile-commands-dir=${workspaceFolder}/build_jobs_cmake_tools",
		"--background-index",
		"--clang-tidy",
		"--completion-style=detailed",
		"--header-insertion=iwyu",
		"-j=8"
	]
}

MSVC + clangd --query-driver 推荐配置

当使用 MSVC 工具链时,建议显式配置 --query-driver 以便 clangd 正确读取 MSVC 的系统头与内置宏:

{
	"clangd.arguments": [
		// 使用环境变量(推荐,VS 开发者命令行会注入 VCToolsInstallDir)
		"--query-driver=${env:VCToolsInstallDir}bin/Hostx64/x64/cl.exe",

		// 通配符版本(多个版本时会选择第一个匹配项)
		"--query-driver=C:/Program Files/Microsoft Visual Studio/*/Community/VC/Tools/MSVC/*/bin/Hostx64/x64/cl.exe"
	]
}

显式指定 C++ 标准(CMake 配置)

如果需要固定 __cplusplus 版本,可通过 CMake 统一指定标准(示例:C++20):

{
	"cmake.configureSettings": {
		"CMAKE_CXX_STANDARD": "20",
		"CMAKE_CXX_STANDARD_REQUIRED": "ON"
	}
}

说明:只有在 MSVC 下 clangd 不识别 -std:c++latest/std:c++latest 时,才需要使用以上方式固定标准。使用 CMAKE_CXX_STANDARD 通常兼容性更好;--query-driver 不影响单独打开的 .h 文件,仅影响带编译命令的翻译单元。两者可二选一使用。

Other options

Option Description
BUILD_SHARED_LIBS=YES|NO [default=NO] Build dynamic library
LIBUNWIND_ENABLED=YES|NO [default=NO] Enable and using libunwind for callstack unwind
LOG_WRAPPER_ENABLE_LUA_SUPPORT=YES|NO [default=YES] Enable lua support for log system
LOG_WRAPPER_CHECK_LUA=YES|NO [default=YES] Enable checking for lua support
LOG_WRAPPER_ENABLE_STACKTRACE=YES|NO [default=YES] Enable stack trace for log system
ENABLE_MIXEDINT_MAGIC_MASK=0-8 [default=0] Set mixed int mask
CRYPTO_DISABLED=YES|NO [default=NO] Disable crypto and DH/ECDH support
CRYPTO_USE_OPENSSL=YES|NO [default=NO] Using openssl for crypto and DH/ECDH support, and close auto detection
CRYPTO_USE_MBEDTLS=YES|NO [default=NO] Using mbedtls for crypto and DH/ECDH support, and close auto detection

About

cxx utils code

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors