mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-16 19:47:04 +03:00
spelling fixes
This commit is contained in:
@@ -49,7 +49,7 @@ the sources in the +add_library+ call.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
As mentioned in the prevoius example, we pass the source files directly to the
|
||||
As mentioned in the previous example, we pass the source files directly to the
|
||||
+add_library+ call, as recommended for modern CMake.
|
||||
====
|
||||
|
||||
@@ -73,7 +73,7 @@ This will cause the included directory used in the following places:
|
||||
The meaning of scopes are:
|
||||
|
||||
* +PRIVATE+ - the directory is added to this target's include directories
|
||||
* +INTERFACE+ - the directory is added to the include directores for any targets that link this library.
|
||||
* +INTERFACE+ - the directory is added to the include directories for any targets that link this library.
|
||||
* +PUBLIC+ - As above, it is included int his library and also any targets that link this library.
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ target_link_libraries( hello_binary
|
||||
----
|
||||
|
||||
This tells CMake to link the hello_library against the hello_binary executable
|
||||
during link time. It will also propogate any include directries with +PUBLIC+ or +INTERFACE+ scope
|
||||
during link time. It will also propagate any include directories with +PUBLIC+ or +INTERFACE+ scope
|
||||
from the linked library target.
|
||||
|
||||
An example of this being called by the compiler is
|
||||
|
||||
@@ -39,7 +39,7 @@ target_compile_definitions(cmake_examples_compile_flags
|
||||
|
||||
This will cause the compiler to add the definition +-DEX3+ when compiling the target.
|
||||
|
||||
In the target was a library, and the scope +PUBLIC+ or +INTERFACE+ has been choosen the definition would also be included in any executables that link this target.
|
||||
In the target was a library, and the scope +PUBLIC+ or +INTERFACE+ has been chosen the definition would also be included in any executables that link this target.
|
||||
|
||||
For compiler options you can also use the +target_compile_options()+ link:https://cmake.org/cmake/help/v3.0/command/target_compile_options.html[function].
|
||||
|
||||
@@ -70,7 +70,7 @@ For more details, see https://cmake.org/cmake/help/v3.0/command/set.html[here]
|
||||
====
|
||||
|
||||
|
||||
Once set the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ will set a compler flag / definiton globally for all targets in this directory or any included sub-directories. This method is not recommended for general usage now and the +target_compile_definitions+ function is preferred.
|
||||
Once set the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ will set a compler flag / definition globally for all targets in this directory or any included sub-directories. This method is not recommended for general usage now and the +target_compile_definitions+ function is preferred.
|
||||
|
||||
### Set CMake Flags
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ Most modern CMake libraries link:https://cmake.org/cmake/help/v3.6/prop_tgt/IMPO
|
||||
The benefit of imported targets are that they can also populate include directories and linked libraries.
|
||||
|
||||
For example, starting from v3.5+ of CMake, the
|
||||
Boost module supports this. Similar to using your own ALIAS target for libraires, an +ALIAS+ in a module can make referencing found targets eaiser.
|
||||
Boost module supports this. Similar to using your own ALIAS target for libraires, an +ALIAS+ in a module can make referencing found targets easier.
|
||||
|
||||
In the case of Boost, all targets are exported using the `Boost::` identifier and then the name
|
||||
of the subsystem. For example you can use:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Ubuntu supports multiple versions of clang to be installed at the same time.
|
||||
# The tests need to determin the clang binary before calling cmake
|
||||
# The tests need to determine the clang binary before calling cmake
|
||||
clang_bin=`which clang`
|
||||
clang_xx_bin=`which clang++`
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ toc::[]
|
||||
|
||||
# Introduction
|
||||
|
||||
This example shows a common method to set the C++ Standard. This can be used with most versions of CMake. However, if you are targetting a recent version of CMake there are more convenient methods available.
|
||||
This example shows a common method to set the C++ Standard. This can be used with most versions of CMake. However, if you are targeting a recent version of CMake there are more convenient methods available.
|
||||
|
||||
The files in this tutorial are below:
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ project (hello_cpp11)
|
||||
# Add an executable
|
||||
add_executable(hello_cpp11 main.cpp)
|
||||
|
||||
# set the C++ standard to the approriate standard for using auto
|
||||
# set the C++ standard to the appropriate standard for using auto
|
||||
target_compile_features(hello_cpp11 PUBLIC cxx_auto_type)
|
||||
|
||||
# Print the list of known compile features for this version of CMake
|
||||
|
||||
@@ -6,7 +6,7 @@ set compile flags, create and link executables and libraries, and install them.
|
||||
The examples included are
|
||||
|
||||
- link:A-hello-cmake[hello-cmake]. A hello world example.
|
||||
- link:B-hello-headers[hello-headers]. A slightly more complicated hello world example, using seperate source and include folders.
|
||||
- link:B-hello-headers[hello-headers]. A slightly more complicated hello world example, using separate source and include folders.
|
||||
- link:C-static-library[static-library]. An example using a static library.
|
||||
- link:D-shared-library[shared-library]. An example using a shared library.
|
||||
- link:E-installing[installing]. Shows how to create a 'make install' target that will install binaries and libraries.
|
||||
|
||||
@@ -124,7 +124,7 @@ add_library(${PROJECT_NAME} INTERFACE)
|
||||
|
||||
When creating the target you can also include directories for that target using
|
||||
the +INTERFACE+ scope. The +INTERFACE+ scope is use to make target requirements that are used in any Libraries
|
||||
that link this target but not in the complation of the target itself.
|
||||
that link this target but not in the compilation of the target itself.
|
||||
|
||||
[source,cmake]
|
||||
----
|
||||
@@ -171,7 +171,7 @@ target_link_libraries(subbinary
|
||||
## Include directories from sub-projects
|
||||
|
||||
When adding the libraries from the sub-projects, starting from cmake v3, there is
|
||||
no need to add the projects include directores in the include directories of the
|
||||
no need to add the projects include directories in the include directories of the
|
||||
binary using them.
|
||||
|
||||
This is controlled by the scope in the `target_include_directories()` command when creating
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
= Code Generation
|
||||
|
||||
Code generation can be useful to create source code in different languages from a common description file. This can reduce the amount of manual code to write and increase inter-operability.
|
||||
Code generation can be useful to create source code in different languages from a common description file. This can reduce the amount of manual code to write and increase interoperability.
|
||||
|
||||
Examples showing code generation using variables from CMake and also using some common tools.
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ $ tree
|
||||
1 directory, 4 files
|
||||
----
|
||||
|
||||
By defaut these are output to +/tmp/scanbuildout/{run folder}+. You can change this using `scan-build -o /output/folder`.
|
||||
By default these are output to +/tmp/scanbuildout/{run folder}+. You can change this using `scan-build -o /output/folder`.
|
||||
|
||||
# Building the example
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ foreach(EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})
|
||||
list(APPEND EXCLUDE_PATTERN_ARGS "--exclude=${EXCLUDE_PATTERN}")
|
||||
endforeach()
|
||||
|
||||
# call the script to chech changed files in git
|
||||
# call the script to check changed files in git
|
||||
add_custom_target(format-check-changed
|
||||
COMMENT "Checking changed files in git"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
|
||||
@@ -142,7 +142,7 @@ def cli():
|
||||
description='Checks if files chagned in git match the .clang-format specification')
|
||||
parser.add_argument("--file-extensions", type=str,
|
||||
default=".cpp,.h,.cxx,.hxx,.hpp,.cc,.ipp",
|
||||
help="Comma seperated list of file extensions to check")
|
||||
help="Comma separated list of file extensions to check")
|
||||
parser.add_argument('--exclude', action='append', default=[],
|
||||
help='Will not match the files / directories with these in the name')
|
||||
parser.add_argument('--clang-format-bin', type=str, default="clang-format",
|
||||
|
||||
@@ -61,7 +61,7 @@ $ wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \
|
||||
|
||||
## Adding Custom Package Modules
|
||||
|
||||
As with the previous example I use a custom module to find CppCheck. This version is slightly different to the pervious one and
|
||||
As with the previous example I use a custom module to find CppCheck. This version is slightly different to the previous one and
|
||||
will automatically add a `make cppcheck-analysis` target.
|
||||
|
||||
[source,cmake]
|
||||
|
||||
@@ -41,7 +41,7 @@ if(CPPCHECK_BIN)
|
||||
set(CPPCHECK_THREADS_ARG "-j4" CACHE STRING "The number of threads to use")
|
||||
set(CPPCHECK_PROJECT_ARG "--project=${PROJECT_BINARY_DIR}/compile_commands.json")
|
||||
set(CPPCHECK_BUILD_DIR_ARG "--cppcheck-build-dir=${PROJECT_BINARY_DIR}/analysis/cppcheck" CACHE STRING "The build directory to use")
|
||||
# Don't show thise errors
|
||||
# Don't show these errors
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.cppcheck_suppressions")
|
||||
set(CPPCHECK_SUPPRESSIONS "--suppressions-list=${CMAKE_SOURCE_DIR}/.cppcheck_suppressions" CACHE STRING "The suppressions file to use")
|
||||
else()
|
||||
|
||||
@@ -23,7 +23,7 @@ macro(add_analysis _target _sources)
|
||||
set(ALL_ANALYSIS_TARGETS "${ALL_ANALYSIS_TARGETS}" PARENT_SCOPE)
|
||||
|
||||
# This is used to make the command run correctly on the command line.
|
||||
# The COMMAND argumetn expects a list and this does the change
|
||||
# The COMMAND argument expects a list and this does the change
|
||||
# I need to check which version works with 2.7
|
||||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VESION} GREATER 2.7)
|
||||
separate_arguments(tmp_args UNIX_COMMAND ${CPPCHECK_ARG})
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
find_program(CPPCHECK_BIN NAMES cppcheck)
|
||||
|
||||
#
|
||||
# Arugments are
|
||||
# Arguments are
|
||||
# -j use multiple threads (and thread count)
|
||||
# --quite only show errors / warnings etc
|
||||
# --error-exitcode The code to exit with if an error shows up
|
||||
# --enabled Comman seperated list of the check types. Can include warning,performance,style
|
||||
# --enabled Comma separated list of the check types. Can include warning,performance,style
|
||||
# Note nightly build on earth changes error-exitcode to 0
|
||||
set (CPPCHECK_THREADS "-j 4" CACHE STRING "The -j argument to have cppcheck use multiple threads / cores")
|
||||
|
||||
@@ -34,4 +34,4 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||
mark_as_advanced(
|
||||
CPPCHECK_BIN
|
||||
CPPCHECK_THREADS
|
||||
CPPCHECK_ARG)
|
||||
CPPCHECK_ARG)
|
||||
|
||||
@@ -1666,7 +1666,7 @@ namespace Catch {
|
||||
m_result( result )
|
||||
{}
|
||||
|
||||
// We don't actually need a virtual destructor, but many static analysers
|
||||
// We don't actually need a virtual destructor, but many static analyzers
|
||||
// complain if it's not here :-(
|
||||
virtual ~ITransientExpression();
|
||||
|
||||
@@ -2844,7 +2844,7 @@ public:
|
||||
|
||||
// The following functions create the actual matcher objects.
|
||||
// The user has to explicitly specify type to the function, because
|
||||
// infering std::function<bool(T const&)> is hard (but possible) and
|
||||
// inferring std::function<bool(T const&)> is hard (but possible) and
|
||||
// requires a lot of TMP.
|
||||
template<typename T>
|
||||
Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)> const& predicate, std::string const& description = "") {
|
||||
@@ -9248,7 +9248,7 @@ namespace Catch {
|
||||
if (strerror_s(buffer, errno)) {
|
||||
CATCH_RUNTIME_ERROR("Could not translate errno to a string");
|
||||
}
|
||||
CATCH_RUNTIME_ERROR("Coul dnot open the temp file: '" << m_buffer << "' because: " << buffer);
|
||||
CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -67,7 +67,7 @@ $ cd build
|
||||
$ conan install ..
|
||||
----
|
||||
|
||||
This will tell conan to read the +conanfile.txt+ from your root folder and install any required package configurations. If the package is not availabe in your package cache it will be downloaded.
|
||||
This will tell conan to read the +conanfile.txt+ from your root folder and install any required package configurations. If the package is not available in your package cache it will be downloaded.
|
||||
|
||||
As per our requires section, `conan install` will download a static library version of fmtlib along with all required headers. On my system with default configuration, this cached library is as follows:
|
||||
|
||||
@@ -210,4 +210,4 @@ make[1]: Leaving directory '/home/devuser/ws/build'
|
||||
|
||||
$ ./bin/third_party_include
|
||||
Hello, conan. This is fmtlib!
|
||||
----
|
||||
----
|
||||
|
||||
@@ -8,5 +8,5 @@ toc::[]
|
||||
Introduction
|
||||
------------
|
||||
|
||||
For C++ and CMake there is currently no universally accepted way of managing and packaging dependencies. However, in recent years there have been some new and interesting package management systems made available. While these are seperate systems to CMake, most of them have are designed to integrate directly into a CMake based build system.
|
||||
For C++ and CMake there is currently no universally accepted way of managing and packaging dependencies. However, in recent years there have been some new and interesting package management systems made available. While these are separate systems to CMake, most of them have are designed to integrate directly into a CMake based build system.
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ In this example the tag is created as follows
|
||||
|
||||
<docker user>/<repository>:<cmake version>
|
||||
|
||||
This will tag the container as belong to my repositry with the label of the container being the version of cmake installed.
|
||||
This will tag the container as belong to my repository with the label of the container being the version of cmake installed.
|
||||
|
||||
## Pre-build Images
|
||||
|
||||
|
||||
Reference in New Issue
Block a user