C++23 gcc15.1 希望有一个CMake历程进行学习!
-
目前我在Ubuntu20.04上使用上了最新的GCC15.1,体验了了import std; 等新的语法,现在我想学习如何通过CMake组件一个工程,有没有大佬能够出个教学。目前环境为CMake4.0.2(最新,据说支持了import std;的c++23),gcc 15.1,系统 Ubuntu20.04。
-
晚些我看能不能搞个cmake的c++23工程模板...
-
模板已经准备好了, 我添加到xlings里一下
-
你好你好,请问这个xlings怎么看
-
@HeiseCurtain 已经添加到xlings的模板库里了, 可以安装xlings(项目模板创建/环境配置/软件安装工具) 后使用下面命令进行 自动创建模板项目 和 配置相关依赖
xlings new hello --template cpp23-cmake-helloworld
其中hello是可以修改的项目名
-
你好我想下载一个模板看一看,我在windows下载了这个hello,但是里面什么都没有,没有main.cpp。这是tree。
文件夹 PATH 列表
卷序列号为 BC1C-4DEA
C:.
└─hello
├─book
│ ├─book
│ │ ├─css
│ │ ├─FontAwesome
│ │ │ ├─css
│ │ │ └─fonts
│ │ └─fonts
│ └─src
└─dslings
├─exercises
└─tests -
此回复已被删除!
-
能不能先贴一个CMakeLists参考以下/感谢!!!
-
@HeiseCurtain 因为xlings代码更新了, 应该需要重新执行一下xlings的安装命令(不用清除本地缓存)更新, 然后更新索引才能检测到新添加的模板
curl -fsSL https://d2learn.org/xlings-install.sh | bash
xim --update index
xlings new hello --template cpp23-cmake-helloworld
或者你直接在github上浏览项目模板也可以: https://github.com/d2learn/xlings-project-templates/tree/main/cpp23/cmake/helloworld
-
注: 需要使用ninja工具链, 目前不支持make
cmake_minimum_required(VERSION 4.0.2) # https://github.com/Kitware/CMake/blob/master/Help/dev/experimental.rst set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457") set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_MODULE_STD 1) project(HelloWorld LANGUAGES CXX) add_executable(helloworld src/main.cpp)
-
非常感谢!!!