2020-08-12 20:29:56 +02:00
|
|
|
# CMake ROOT dict example
|
|
|
|
|
2018-03-28 22:48:45 +02:00
|
|
|
## [main]
|
2020-08-12 20:29:56 +02:00
|
|
|
|
2023-07-19 17:25:52 +02:00
|
|
|
cmake_minimum_required(VERSION 3.4...3.27)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-03-29 12:27:23 +02:00
|
|
|
project(RootDictExample LANGUAGES CXX)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2022-06-02 20:04:47 +02:00
|
|
|
set(CMAKE_CXX_STANDARD
|
|
|
|
11
|
|
|
|
CACHE STRING "C++ standard to use")
|
2018-05-02 10:48:50 +02:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_PLATFORM_INDEPENDENT_CODE ON)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2020-06-09 17:33:13 +02:00
|
|
|
find_package(ROOT 6.20 CONFIG REQUIRED)
|
|
|
|
# If you want to support <6.20, add this line:
|
|
|
|
# include("${ROOT_DIR}/modules/RootNewMacros.cmake")
|
|
|
|
# However, it was moved and included by default in 6.201
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-03-29 12:27:23 +02:00
|
|
|
root_generate_dictionary(G__DictExample DictExample.h LINKDEF DictLinkDef.h)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2018-03-29 12:27:23 +02:00
|
|
|
add_library(DictExample SHARED DictExample.cxx DictExample.h G__DictExample.cxx)
|
2019-08-07 07:06:55 +02:00
|
|
|
target_include_directories(DictExample PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
2019-08-08 22:18:42 +02:00
|
|
|
target_link_libraries(DictExample PUBLIC ROOT::Core)
|
2018-03-28 20:50:38 +02:00
|
|
|
|
2021-03-23 20:07:29 +01:00
|
|
|
## Alternative to add the dictionary to an existing target:
|
|
|
|
# add_library(DictExample SHARED DictExample.cxx DictExample.h)
|
|
|
|
# target_include_directories(DictExample PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
# target_link_libraries(DictExample PUBLIC ROOT::Core)
|
|
|
|
# root_generate_dictionary(G__DictExample DictExample.h MODULE DictExample LINKDEF DictLinkDef.h)
|
|
|
|
|
2018-03-28 22:48:45 +02:00
|
|
|
## [main]
|
2018-03-29 12:27:23 +02:00
|
|
|
|
2018-05-02 10:48:50 +02:00
|
|
|
message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}")
|
|
|
|
message(STATUS "Original flags: ${ROOT_CXX_FLAGS}")
|
|
|
|
message(STATUS "Original definitions: ${ROOT_DEFINITIONS}")
|
|
|
|
message(STATUS "Original exe flags: ${ROOT_EXE_LINKER_FLAGS}")
|
|
|
|
|
2018-03-29 12:27:23 +02:00
|
|
|
enable_testing()
|
2020-08-04 00:16:52 +02:00
|
|
|
add_test(
|
|
|
|
NAME RootDictExample
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
COMMAND "${ROOT_root_CMD}" -b -l -q "${CMAKE_CURRENT_SOURCE_DIR}/CheckLoad.C")
|