You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To cleanly separate the library and subproject code, the outer `CMakeList.txt` only defines the library itself while the tests and other subprojects are self-contained in their own directories.
51
-
During development it is usually convenient to [build all subprojects at once](#build-everything-at-once).
The documentation is automatically built and [published](https://thelartians.github.io/ModernCppStarter) whenever a [GitHub Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository)is created.
103
-
To manually build documentation, call the following command.
The test and standalone subprojects include the [tools.cmake](cmake/tools.cmake) file which is used to import additional tools on-demand through CMake configuration arguments.
136
-
The following are currently supported.
133
+
目前支持以下功能:
137
134
138
135
#### Sanitizers
139
136
140
-
Sanitizers can be enabled by configuring CMake with `-DUSE_SANITIZER=<Address | Memory | MemoryWithOrigins | Undefined | Thread | Leak | 'Address;Undefined'>`.
Static Analyzers can be enabled by setting `-DUSE_STATIC_ANALYZER=<clang-tidy | iwyu | cppcheck>`, or a combination of those in quotation marks, separated by semicolons.
145
-
By default, analyzers will automatically find configuration files such as `.clang-format`.
146
-
Additional arguments can be passed to the analyzers by setting the `CLANG_TIDY_ARGS`, `IWYU_ARGS` or `CPPCHECK_ARGS` variables.
Glob is considered bad because any changes to the source file structure [might not be automatically caught](https://cmake.org/cmake/help/latest/command/file.html#filesystem) by CMake's builders and you will need to manually invoke CMake on changes.
173
-
I personally prefer the `GLOB` solution for its simplicity, but feel free to change it to explicitly listing sources.
184
+
根据类型,将这些组件移到单独的存储库中,并引用库的特定提交或版本,这样做可能更有意义。
174
185
175
-
> I want create additional targets that depend on my library. Should I modify the main CMakeLists to include them?
186
+
这样做的优点在于,可以独立地改进和更新各个库和组件。
176
187
177
-
Avoid including derived projects from the libraries CMakeLists (even though it is a common sight in the C++ world), as this effectively inverts the dependency tree and makes the build system hard to reason about.
178
-
Instead, create a new directory or project with a CMakeLists that adds the library as a dependency (e.g. like the [standalone](standalone/CMakeLists.txt) directory).
179
-
Depending type it might make sense move these components into a separate repositories and reference a specific commit or version of the library.
180
-
This has the advantage that individual libraries and components can be improved and updated independently.
这也应该允许用户使用他们最喜欢的外部 C++ 依赖管理器(如 vcpkg 或 Conan)与项目一起使用。
183
193
184
-
[CPM.cmake](https://github.com/TheLartians/CPM.cmake) should be invisible to library users as it's a self-contained CMake Script.
185
-
If problems do arise, users can always opt-out by defining the CMake or env variable [`CPM_USE_LOCAL_PACKAGES`](https://github.com/cpm-cmake/CPM.cmake#options), which will override all calls to `CPMAddPackage` with the according `find_package` call.
186
-
This should also enable users to use the project with their favorite external C++ dependency manager, such as vcpkg or Conan.
194
+
> 我可以在离线状态下配置和构建我的项目吗?
187
195
188
-
> Can I configure and build my project offline?
196
+
构建项目不需要互联网连接,但在使用 CPM 时,缺少的依赖项会在配置时下载。
189
197
190
-
No internet connection is required for building the project, however when using CPM missing dependencies are downloaded at configure time.
191
-
To avoid redundant downloads, it's highly recommended to set a CPM.cmake cache directory, e.g.: `export CPM_SOURCE_CACHE=$HOME/.cache/CPM`.
192
-
This will enable shallow clones and allow offline configurations dependencies are already available in the cache.
> Can I use CPack to create a package installer for my project?
201
+
> 我可以使用 CPack 为我的项目创建包安装程序吗?
195
202
196
-
As there are a lot of possible options and configurations, this is not (yet) in the scope of this template. See the [CPack documentation](https://cmake.org/cmake/help/latest/module/CPack.html)for more information on setting up CPack installers.
-[**ModernCppStarter & PVS-Studio Static Code Analyzer**](https://github.com/viva64/pvs-studio-cmake-examples/tree/master/modern-cpp-starter): Official instructions on how to use the ModernCppStarter with the PVS-Studio Static Code Analyzer.
205
-
-[**cpp-best-practices/gui_starter_template**](https://github.com/cpp-best-practices/gui_starter_template/): A popular C++ starter project, created in 2017.
206
-
-[**filipdutescu/modern-cpp-template**](https://github.com/filipdutescu/modern-cpp-template): A recent starter using a more traditional approach for CMake structure and dependency management.
207
-
-[**vector-of-bool/pitchfork**](https://github.com/vector-of-bool/pitchfork/): Pitchfork is a Set of C++ Project Conventions.
0 commit comments