More examples
This commit is contained in:
parent
ebfe7865b8
commit
0b5a8e4c89
@ -13,14 +13,6 @@ before_script:
|
|||||||
#- gitbook fetch pre # fetch latest pre-release version
|
#- gitbook fetch pre # fetch latest pre-release version
|
||||||
#- gitbook fetch 2.6.7 # fetch specific version
|
#- gitbook fetch 2.6.7 # fetch specific version
|
||||||
|
|
||||||
test:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- gitbook build . public # build to public path
|
|
||||||
only:
|
|
||||||
- branches # this job will affect only the 'master' branch
|
|
||||||
except:
|
|
||||||
- master
|
|
||||||
|
|
||||||
# the 'pages' job will deploy and build your site to the 'public' path
|
# the 'pages' job will deploy and build your site to the 'public' path
|
||||||
pages:
|
pages:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
## [main]
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
|
||||||
project(RootExampleDict LANGUAGES CXX)
|
project(RootExampleDict LANGUAGES CXX)
|
||||||
@ -20,5 +22,6 @@ root_generate_dictionary(G__MyExample MyExample.h LINKDEF SimpleLinkDef.h)
|
|||||||
add_library(MyExample SHARED MyExample.cxx MyExample.h G__MyExample.cxx)
|
add_library(MyExample SHARED MyExample.cxx MyExample.h G__MyExample.cxx)
|
||||||
target_link_libraries(MyExample PUBLIC ROOT::Core)
|
target_link_libraries(MyExample PUBLIC ROOT::Core)
|
||||||
|
|
||||||
|
## [main]
|
||||||
#enable_testing()
|
#enable_testing()
|
||||||
#add_test(NAME MyExample COMMAND )
|
#add_test(NAME MyExample COMMAND )
|
||||||
|
@ -1,20 +1,32 @@
|
|||||||
|
|
||||||
|
## [main]
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
|
||||||
project(RootExample LANGUAGES CXX)
|
project(RootSimpleExample LANGUAGES CXX)
|
||||||
|
|
||||||
|
## [find_package]
|
||||||
find_package(ROOT CONFIG REQUIRED)
|
find_package(ROOT CONFIG REQUIRED)
|
||||||
|
## [find_package]
|
||||||
|
|
||||||
message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}")
|
message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}")
|
||||||
|
|
||||||
|
# ROOT targets are missing includes and flags
|
||||||
|
## [setup_properties]
|
||||||
|
# Fix for ROOT_CXX_FLAGS not actually being a CMake list
|
||||||
string(REPLACE " " ";" ROOT_CXX_FLAG_LIST "${ROOT_CXX_FLAGS}")
|
string(REPLACE " " ";" ROOT_CXX_FLAG_LIST "${ROOT_CXX_FLAGS}")
|
||||||
|
|
||||||
set_target_properties(ROOT::Core PROPERTIES
|
set_property(TARGET ROOT::Core PROPERTY
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}"
|
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}")
|
||||||
INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAG_LIST}"
|
set_property(TARGET ROOT::Core APPEND PROPERTY
|
||||||
)
|
INTERFACE_COMPILE_OPTIONS ${ROOT_CXX_FLAG_LIST})
|
||||||
|
## [setup_properties]
|
||||||
|
|
||||||
|
## [add_and_link]
|
||||||
add_executable(MyExample MyExample.cxx)
|
add_executable(MyExample MyExample.cxx)
|
||||||
target_link_libraries(MyExample PUBLIC ROOT::Physics)
|
target_link_libraries(MyExample PUBLIC ROOT::Physics)
|
||||||
|
## [add_and_link]
|
||||||
|
|
||||||
|
## [main]
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_test(NAME MyExample COMMAND MyExample)
|
add_test(NAME RootSimpleExample COMMAND MyExample)
|
||||||
|
@ -7,9 +7,7 @@ ROOT is a C++ Toolkit for High Energy Physics. It is huge. There are really a lo
|
|||||||
|
|
||||||
ROOT supports config file discovery, so you can just do:
|
ROOT supports config file discovery, so you can just do:
|
||||||
|
|
||||||
```cmake
|
[import:'find_package', lang:'cmake'](../examples/root-example/CMakeLists.txt)
|
||||||
find_package(ROOT CONFIG)
|
|
||||||
```
|
|
||||||
|
|
||||||
to attempt to find ROOT. If you don't have your paths set up, you can pass `-DROOT_DIR=$ROOTSYS/cmake` to find ROOT. (But, really, you should source `thisroot.sh`)
|
to attempt to find ROOT. If you don't have your paths set up, you can pass `-DROOT_DIR=$ROOTSYS/cmake` to find ROOT. (But, really, you should source `thisroot.sh`)
|
||||||
|
|
||||||
@ -21,16 +19,7 @@ ROOT provides a utility to set up a ROOT project, which you can activate using `
|
|||||||
|
|
||||||
ROOT does not correctly set up it's imported targets. To fix this error, you'll need something like:
|
ROOT does not correctly set up it's imported targets. To fix this error, you'll need something like:
|
||||||
|
|
||||||
```cmake
|
[import:'setup_properties', lang:'cmake'](../examples/root-example/CMakeLists.txt)
|
||||||
find_package(ROOT CONFIG REQUIRED)
|
|
||||||
|
|
||||||
string(REPLACE " " ";" ROOT_CXX_FLAG_LIST "${ROOT_CXX_FLAGS}")
|
|
||||||
|
|
||||||
set_target_properties(ROOT::Core PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}"
|
|
||||||
INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAG_LIST}"
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
In CMake 3.11, you can replace that last function call with:
|
In CMake 3.11, you can replace that last function call with:
|
||||||
|
|
||||||
@ -43,10 +32,7 @@ All the ROOT targets will require `ROOT::Core`, so this will be enough regardles
|
|||||||
|
|
||||||
To link, just pick the libraries you want to use:
|
To link, just pick the libraries you want to use:
|
||||||
|
|
||||||
```cmake
|
[import:'add_and_link', lang:'cmake'](../examples/root-example/CMakeLists.txt)
|
||||||
add_executable(MyExample MyExample.cxx)
|
|
||||||
target_link_libraries(MyExample PUBLIC ROOT::Physics)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Dictionary generation
|
## Dictionary generation
|
||||||
|
|
||||||
@ -72,9 +58,12 @@ To generate a file:
|
|||||||
root_generate_dictionary(G__MyExample MyExample.h LINKDEF SimpleLinkDef.h)
|
root_generate_dictionary(G__MyExample MyExample.h LINKDEF SimpleLinkDef.h)
|
||||||
```
|
```
|
||||||
|
|
||||||
Then include G__MyExample.cxx in your sources when you make the library.
|
Then include `G__MyExample.cxx` in your sources when you make the library.
|
||||||
|
|
||||||
## Example: Minimal
|
## Example: Minimal
|
||||||
|
|
||||||
#### examples/root-example/CMakeLists.txt
|
#### examples/root-example/CMakeLists.txt
|
||||||
[include](../examples/root-example/CMakeLists.txt)
|
[import:'main', lang:'cmake'](../examples/root-example/CMakeLists.txt)
|
||||||
|
|
||||||
|
## Example: Dictionary
|
||||||
|
[import:'main', lang:'cmake', title:"CMakeLists.txt"](../examples/root-example-dict/CMakeLists.txt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user