2018-03-28 22:48:45 +02:00
|
|
|
|
|
|
|
## [main]
|
2018-03-28 20:50:38 +02:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
|
|
|
|
2018-03-28 22:48:45 +02:00
|
|
|
project(RootSimpleExample LANGUAGES CXX)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-03-28 22:48:45 +02:00
|
|
|
## [find_package]
|
2018-03-28 20:50:38 +02:00
|
|
|
find_package(ROOT CONFIG REQUIRED)
|
2018-03-28 22:48:45 +02:00
|
|
|
## [find_package]
|
2018-03-28 20:50:38 +02:00
|
|
|
|
|
|
|
message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}")
|
|
|
|
|
2018-03-28 22:48:45 +02:00
|
|
|
# ROOT targets are missing includes and flags
|
2018-05-01 17:18:27 +02:00
|
|
|
## [setup_includes]
|
|
|
|
set_property(TARGET ROOT::Core PROPERTY
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}")
|
|
|
|
## [setup_includes]
|
|
|
|
|
|
|
|
## [setup_flags]
|
2018-03-28 22:48:45 +02:00
|
|
|
# Fix for ROOT_CXX_FLAGS not actually being a CMake list
|
2018-03-29 19:30:00 +02:00
|
|
|
separate_arguments(ROOT_CXX_FLAGS)
|
2018-05-01 17:18:27 +02:00
|
|
|
separate_arguments(ROOT_DEFINITIONS)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-05-01 17:18:27 +02:00
|
|
|
# This is required on if there is more than one flag (like on macOS)
|
|
|
|
# and this also fixes a bug in the linker flags
|
|
|
|
string(REPLACE "-L " "-L" ROOT_EXE_LINKER_FLAGS "${ROOT_EXE_LINKER_FLAGS}")
|
|
|
|
separate_arguments(ROOT_EXE_LINKER_FLAGS)
|
|
|
|
|
|
|
|
add_library(ROOT::Flags_CXX IMPORTED INTERFACE)
|
|
|
|
set_property(TARGET ROOT::Flags_CXX APPEND PROPERTY
|
2018-03-29 19:30:00 +02:00
|
|
|
INTERFACE_COMPILE_OPTIONS ${ROOT_CXX_FLAGS})
|
2018-05-01 17:18:27 +02:00
|
|
|
set_property(TARGET ROOT::Flags_CXX APPEND PROPERTY
|
|
|
|
INTERFACE_COMPILE_DEFINITIONS ${ROOT_DEFINITIONS})
|
|
|
|
set_property(TARGET ROOT::Flags_CXX APPEND PROPERTY
|
|
|
|
INTERFACE_LINK_LIBRARIES ${ROOT_EXE_LINKER_FLAGS})
|
|
|
|
## [setup_flags]
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-03-29 13:26:47 +02:00
|
|
|
# Adding an exectuable program and linking to needed ROOT libraries
|
2018-03-28 22:48:45 +02:00
|
|
|
## [add_and_link]
|
2018-03-29 12:27:23 +02:00
|
|
|
add_executable(RootSimpleExample SimpleExample.cxx)
|
2018-05-01 17:18:27 +02:00
|
|
|
target_link_libraries(RootSimpleExample PUBLIC ROOT::Physics ROOT::Flags_CXX)
|
2018-03-28 22:48:45 +02:00
|
|
|
## [add_and_link]
|
|
|
|
|
|
|
|
## [main]
|
2018-03-28 20:50:38 +02:00
|
|
|
|
|
|
|
enable_testing()
|
2018-03-29 12:27:23 +02:00
|
|
|
add_test(NAME RootSimpleExample COMMAND RootSimpleExample)
|