Examples all build and test
This commit is contained in:
parent
0b5a8e4c89
commit
cf824ab47c
14
examples/.gitignore
vendored
Normal file
14
examples/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
Testing
|
||||
CMakeFiles
|
||||
build*
|
||||
G__*
|
||||
*.pcm
|
||||
*.root
|
||||
*.rootmap
|
||||
*.dylib
|
||||
*.so
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
MyExample
|
||||
CTestTestfile.cmake
|
9
examples/CMakeLists.txt
Normal file
9
examples/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
project(ModernCMakeExamples)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(root-simple)
|
||||
add_subdirectory(root-simple-3.11)
|
||||
add_subdirectory(root-dict)
|
@ -2,7 +2,7 @@
|
||||
## [main]
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(RootExampleDict LANGUAGES CXX)
|
||||
project(RootDictExample LANGUAGES CXX)
|
||||
|
||||
find_package(ROOT CONFIG REQUIRED)
|
||||
include("${ROOT_DIR}/modules/RootNewMacros.cmake")
|
||||
@ -17,11 +17,14 @@ set_target_properties(ROOT::Core PROPERTIES
|
||||
)
|
||||
|
||||
include_directories(ROOT_BUG)
|
||||
root_generate_dictionary(G__MyExample MyExample.h LINKDEF SimpleLinkDef.h)
|
||||
root_generate_dictionary(G__DictExample DictExample.h LINKDEF DictLinkDef.h)
|
||||
|
||||
add_library(MyExample SHARED MyExample.cxx MyExample.h G__MyExample.cxx)
|
||||
target_link_libraries(MyExample PUBLIC ROOT::Core)
|
||||
add_library(DictExample SHARED DictExample.cxx DictExample.h G__DictExample.cxx)
|
||||
target_link_libraries(DictExample PUBLIC ROOT::Core)
|
||||
|
||||
## [main]
|
||||
#enable_testing()
|
||||
#add_test(NAME MyExample COMMAND )
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME RootDictExample
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMAND "${ROOT_root_CMD}" -b -l -q "${CMAKE_CURRENT_SOURCE_DIR}/CheckLoad.C")
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
gSystem->Load("libMyExample");
|
||||
gSystem->Load("libDictExample");
|
||||
Simple s;
|
||||
cout << s.GetX() << endl;
|
||||
TFile *_file = TFile::Open("tmp.root", "RECREATE");
|
@ -1,4 +1,4 @@
|
||||
#include "MyExample.h"
|
||||
#include "DictExample.h"
|
||||
|
||||
Double_t Simple::GetX() const {return x;}
|
||||
|
19
examples/root-simple-3.11/CMakeLists.txt
Normal file
19
examples/root-simple-3.11/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
project(RootSimpleExample311 LANGUAGES CXX)
|
||||
|
||||
find_package(ROOT CONFIG REQUIRED)
|
||||
message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}")
|
||||
|
||||
string(REPLACE " " ";" ROOT_CXX_FLAG_LIST "${ROOT_CXX_FLAGS}")
|
||||
|
||||
## [modern_fix]
|
||||
target_include_directories(ROOT::Core INTERFACE "${ROOT_INCLUDE_DIRS}")
|
||||
target_compile_options(ROOT::Core INTERFACE "${ROOT_CXX_FLAG_LIST}")
|
||||
## [modern_fix]
|
||||
|
||||
add_executable(RootSimpleExample311 SimpleExample.cxx)
|
||||
target_link_libraries(RootSimpleExample311 PUBLIC ROOT::Physics)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME RootSimpleExample311 COMMAND RootSimpleExample311)
|
@ -22,11 +22,11 @@ set_property(TARGET ROOT::Core APPEND PROPERTY
|
||||
## [setup_properties]
|
||||
|
||||
## [add_and_link]
|
||||
add_executable(MyExample MyExample.cxx)
|
||||
target_link_libraries(MyExample PUBLIC ROOT::Physics)
|
||||
add_executable(RootSimpleExample SimpleExample.cxx)
|
||||
target_link_libraries(RootSimpleExample PUBLIC ROOT::Physics)
|
||||
## [add_and_link]
|
||||
|
||||
## [main]
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME RootSimpleExample COMMAND MyExample)
|
||||
add_test(NAME RootSimpleExample COMMAND RootSimpleExample)
|
7
examples/root-simple/SimpleExample.cxx
Normal file
7
examples/root-simple/SimpleExample.cxx
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
#include <TLorentzVector.h>
|
||||
int main() {
|
||||
TLorentzVector v(1,2,3,4);
|
||||
v.Print();
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user