?? English Version
Blow and change "mylib" to your name.
Or generate your project using the script: https://github.com/izvolov/mylib-gen
The assembly of this project, like any other project on the CMAKE assembly system, consists of two stages:
cmake -S путь/к/исходникам -B путь/к/сборочной/директории [опции ...]Read more about options.
cmake --build путь/к/сборочной/директории [--target target]Read more about assembly goals.
cmake -S ... -B ... -DMYLIB_COVERAGE=ON [прочие опции ...] Includes the purpose of coverage , with which you can start measuring the code covering with tests.
cmake -S ... -B ... -DMYLIB_TESTING=OFF [прочие опции ...] Provides the opportunity to turn off the assembly of modular tests and the goal of check . As a result, the code is turned off by the core coating with tests (see coating).
Testing is also automatically disconnected if the project is connected to another project as a sub -project using the add_subdirectory command.
cmake -S ... -B ... -DDOXYGEN_OUTPUT_LANGUAGE=English [прочие опции ...] It switches the language of documentation, which is generated by the doc goal to a given one. For a list of accessible languages, see the DOXYGEN system website.
By default, Russian is included.
cmake --build путь/к/сборочной/директории
cmake --build путь/к/сборочной/директории --target all If the goal is not indicated (which is equivalent to the goal all ), collects everything that is possible, and also causes the goal check .
cmake --build путь/к/сборочной/директории --target mylib_library Compiled by the library mylib_library . Included by default.
cmake --build путь/к/сборочной/директории --target mylib-unit-testsCompiles modular tests. Included by default.
cmake --build путь/к/сборочной/директории --target checkRunes the collected (collects, if not yet) modular tests. Included by default.
See also mylib-unit-tests .
cmake --build путь/к/сборочной/директории --target coverageAnalyzes advanced (launches, if not yet) modular tests for covering code with tests using the GCOVR program.
The goal is available only with the included MYLIB_COVERAGE option.
See also check .
cmake --build путь/к/сборочной/директории --target docRunes the generation of documentation for the code using the Doxygen system.
cmake --build путь/к/сборочной/директории --target wandboxFor this, the Wandbox service is used. Do not abuse this thing, the server is not rubber.
cmake -S путь/к/исходникам -B путь/к/сборочной/директории -DCMAKE_BUILD_TYPE=Debug -DMYLIB_COVERAGE=ON
cmake --build путь/к/сборочной/директории --target coverage --parallel 16cmake -S путь/к/исходникам -B путь/к/сборочной/директории -DMYLIB_TESTING=OFF -DCMAKE_INSTALL_PREFIX=путь/к/установойной/директории
cmake --build путь/к/сборочной/директории --target installcmake -S путь/к/исходникам -B путь/к/сборочной/директории -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++-8 -DCMAKE_PREFIX_PATH=путь/к/директории/куда/установлены/зависимости
cmake --build путь/к/сборочной/директории --parallel 4cmake -S путь/к/исходникам -B путь/к/сборочной/директории -DCMAKE_BUILD_TYPE=Release -DDOXYGEN_OUTPUT_LANGUAGE=English
cmake --build путь/к/сборочной/директории --target docOne of the options for using the module is to install it in the system.
cmake --build путь/к/сборочной/директории --target install After that, any other project, calling find_package command, gets the opportunity to use all libraries from the Mylib::
find_package (Mylib 1.0 REQUIRED)
add_executable (some_executable some.cpp sources .cpp)
target_link_libraries (some_executable PRIVATE Mylib::library) The Mylib::library needs to be connected when you need to stick with the libmylib_library library. If there are enough headlines, then it is worth using the Mylib::headers .
The project can also be connected to another project as a submodule using the add_subdirectory command.
In this case, Mylib::library and Mylib::headers will be available in a similar way.
CMAKE 3.14
CMAKE 3.14 is required because in previous versions the install(TARGETS ... EXPORT ...) incorrectly works in previous versions, namely, the default paths are not prescribed.
Doctest testing library
Testing can be turned off (see testing).
DOXYGEN
To switch the language in which the documentation will be generated, the option DOXYGEN_OUTPUT_LANGUAGE is provided.
Interpreter Jap Python 3
For automatic generation of an online sandwich.
With the help of CMAKE and a pair of good tools, you can provide static analysis with minimal body movements.
CMAKE has built -in support for a static analysis of CPPCHECK.
To do this, use the CMAKE_CXX_CPPCHECK option:
cmake -S путь/к/исходникам -B путь/к/сборочной/директории -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_CPPCHECK= " cppcheck;--enable=all;-Iпуть/к/исходникам/include "After that, static analysis will automatically be launched each time during the compilation and cross -compound of the source. You do not need to do anything additional.
With the help of a wonderful scan-build tool, you can also start a static analysis in two scores:
scan-build cmake -S путь/к/исходникам -B путь/к/сборочной/директории -DCMAKE_BUILD_TYPE=Debug
scan-build cmake --build путь/к/сборочной/директории Here, unlike the case with CPPcheck, it is necessary to run the assembly through scan-build each time.