As Philippe pointed out, you need to link against the generated dictionary of our class. Just changing slightly the CMakeLists.txt file like this should work.
cmake_minimum_required(VERSION 2.8)
project(tbjcAnalysis)
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT)
include(${ROOT_USE_FILE})
include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
include_directories(${PROJECT_SOURCE_DIR}/include)
ROOT_GENERATE_DICTIONARY(G__test include/test.h)
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cxx)
add_executable(example main.cxx G__test.cxx ${sources})
target_link_libraries(example ${ROOT_LIBRARIES})
Notice the following changes:
- Use the CMAKE_PREFIX_PATH to tell where to find the ROOTConfig.cmake file instead of using FindROOT.cmake (if ROOT was build with CMake).
- Use the file ${ROOT_USE_FILE} to define useful macros (i.e. ROOT_GENERATE_DICTIONARY)
- Generation of the dictionary G__test.cxx and its use to build the executable example.
Cheers,
Pere