Some updates from AmpGen work
This commit is contained in:
parent
e589556d29
commit
1ddf77ac2f
@ -1,3 +1,21 @@
|
||||
# Adding features
|
||||
|
||||
This section covers adding common features to your CMake project. You'll learn how to add a variety of options commonly needed in C++ projects, like C++11 support, as well as how to support IDEs and more.
|
||||
|
||||
|
||||
## Default build type
|
||||
|
||||
CMake normally does a "non-release, non debug" empty build type; if you prefer to set the default build type yourself, you can follow this
|
||||
recipe for the default build type modified from the [Kitware blog](https://blog.kitware.com/cmake-and-the-default-build-type/):
|
||||
|
||||
```cmake
|
||||
set(default_build_type "Release")
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
||||
STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
```
|
||||
|
@ -26,6 +26,12 @@ if(NOT BUILD_TESTS_DEFAULT)
|
||||
mark_as_advanced(BUILD_TESTS)
|
||||
endif()
|
||||
```
|
||||
## [CMakePrintHelpers]
|
||||
|
||||
|
||||
This module has a couple of handy output functions. `cmake_print_properties` lets you easily print properties.
|
||||
And `cmake_print_variables` will print the names and values of any variables you give it.
|
||||
|
||||
|
||||
## [CheckCXXCompilerFlag]
|
||||
|
||||
@ -86,3 +92,4 @@ There are lots of options you can add, like `COMPILE_DEFINITIONS`. In CMake 3.8+
|
||||
[CMakeDependentOption]: https://cmake.org/cmake/help/latest/module/CMakeDependentOption.html
|
||||
[CheckCXXCompilerFlag]: https://cmake.org/cmake/help/latest/module/CheckCXXCompilerFlag.html
|
||||
[WriteCompilerDetectionHeader]: https://cmake.org/cmake/help/latest/module/WriteCompilerDetectionHeader.html
|
||||
[CMakePrintHelpers]: https://cmake.org/cmake/help/latest/module/CMakePrintHelpers.html
|
||||
|
@ -16,17 +16,20 @@ This not only is cleaner than the old method, it will also correctly set the lib
|
||||
```cmake
|
||||
# For CMake < 3.9, we need to make the target ourselves
|
||||
if(NOT TARGET OpenMP::OpenMP_CXX)
|
||||
find_package(Threads REQUIRED)
|
||||
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
|
||||
set_property(TARGET OpenMP::OpenMP_CXX
|
||||
PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS})
|
||||
# Only works if the same flag is passed to the linker; use CMake 3.9+ otherwise (Intel, AppleClang)
|
||||
set_property(TARGET OpenMP::OpenMP_CXX
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS})
|
||||
PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(MyTarget INTERFACE Threads::Threads)
|
||||
endif()
|
||||
target_link_libraries(MyTarget PUBLIC OpenMP::OpenMP_CXX)
|
||||
```
|
||||
|
||||
{% hint style='danger' %}
|
||||
Warning: CMake < 3.4 has a bug in the Threads package that requires you to have the `C` language enabled.
|
||||
{% endhint %}
|
||||
|
||||
[OpenMP]: https://cmake.org/cmake/help/latest/module/FindOpenMP.html
|
||||
|
@ -32,6 +32,10 @@ To link, just pick the libraries you want to use:
|
||||
|
||||
[import:'add_and_link', lang:'cmake'](../../examples/root-simple/CMakeLists.txt)
|
||||
|
||||
## Components
|
||||
|
||||
Find ROOT allows you to specify components. It will add anything you list to ${ROOT_LIBRARIES}, so you might want to build your own target using that to avoid listing the components twice.
|
||||
|
||||
## Dictionary generation
|
||||
|
||||
Dictionary generation is ROOT's way of working around the missing reflection feature in C++. It allows ROOT to learn the details of your class so it can save it, show methods in the Cling interpreter, etc. You'll need three things in your source code to make it work for classes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user