Home | News | Documentation | Download

Ubuntu installation and cmake project integration

Hi there,
I installed (build) the latest root release with the following instructions

# aptitude install gfortran libpcre3-dev \
xlibmesa-glu-dev libglew1.5-dev libftgl-dev \
libmysqlclient-dev libfftw3-dev libcfitsio-dev \
graphviz-dev libavahi-compat-libdnssd-dev \
libldap2-dev python-dev libxml2-dev libkrb5-dev \
libgsl0-dev
# cd /opt
# git clone --branch latest-stable https://github.com/root-project/root.git root_src
# cd root_src
# mkdir builddir
# cd builddir
# cmake -Dgnuinstall=ON -DCMAKE_CXX_STANDARD=17 ..
# cmake --build . -- -j4
# make install

Doing this I now can launch root from a terminal simply using the command root. I also tried the root-config command that returns what looks like relevant results.

I use TH1 in C++/Qt/root project. I develop the project on fedora and people using the software use ubuntu. before adding root we never add any problems. My software was gently building on both OS.

My cmake file is the following one

cmake_minimum_required(VERSION 3.16)

project(daq_visu LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")

cmake_policy(SET CMP0071 NEW)
include(./check_git.cmake)
CheckGitSetup()

# ------------------------------------------------------------------------------
# distro
# ------------------------------------------------------------------------------
find_program(LSB_RELEASE_EXEC lsb_release)
execute_process(COMMAND ${LSB_RELEASE_EXEC} -is
    OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
    OUTPUT_STRIP_TRAILING_WHITESPACE
)

message("-- DISTRIBUTION FOUND: ${LSB_RELEASE_ID_SHORT}")
message("-- CMAKE_SYSTEM_INFO_FILE: ${CMAKE_SYSTEM_INFO_FILE}")
message("-- CMAKE_SYSTEM_NAME:      ${CMAKE_SYSTEM_NAME}")
message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message("-- CMAKE_SYSTEM:           ${CMAKE_SYSTEM}")


# ------------------------------------------------------------------------------
# root (cern)
# ------------------------------------------------------------------------------
if(${LSB_RELEASE_ID_SHORT} MATCHES Fedora)
  include_directories(/usr/include/root)
elseif(${LSB_RELEASE_ID_SHORT} MATCHES Ubuntu)
  include_directories(/usr/local/include/root)
else()
  include_directories(/usr/include/root)
endif()

find_package(ROOT 6.24 CONFIG REQUIRED RIO Net Hist)

# ------------------------------------------------------------------------------
# qt
# ------------------------------------------------------------------------------
#find_package(QT NAMES Qt5 COMPONENTS Widgets LinguistTools Charts Network PrintSupport REQUIRED)
find_package(Qt5 COMPONENTS Widgets LinguistTools Core Charts Network SerialPort PrintSupport REQUIRED)
#find_package(Qt5 COMPONENTS SerialPort REQUIRED)
find_package(Qt5DataVisualization)


set(PROJECT_SOURCES
        main.cxx
        src/main_window.cxx
        src/main_window.hxx
        src/main_widget.cxx
        src/main_widget.hxx
        src/file_selector.hxx
        src/file_selector.cxx
        src/slice.hxx
        src/slices_summary_table.hxx
        src/slices_summary_table.cxx
        src/daq_file.hxx
        src/daq_file.cxx
        src/raw_data_display.hxx
        src/raw_data_display.cxx
        src/slice_display_find_dialog.hxx
        src/slice_display_find_dialog.cxx
        src/acquisition_widget.hxx
        src/acquisition_widget.cxx
        src/udp_constants.hxx
        src/qcustomplot.h
        src/qcustomplot.cpp
        src/single_plot_widget.hxx
        src/single_plot_widget.cxx
        src/stacked_bars_chart_qcp.hxx
        src/stacked_bars_chart_qcp.cxx
        src/leds_and_registers_config_widget.hxx
        src/leds_and_registers_config_widget.cxx
        src/led_configuration_doc.hxx
        src/slice_color_constants.hxx
        src/acquisition_configuration_widget.cxx
        src/acquisition_configuration_widget.hxx
        src/register_long_single_bit.cxx
        src/register_long_single_bit.hxx
        src/bit.cxx
        src/bit.hxx
        src/register_abstract.cxx
        src/register_abstract.hxx
        src/leds_configuration_widget.hxx
        src/leds_configuration_widget.cxx
        src/udp_client_socket_api.cxx
        src/udp_client_socket_api.hxx
        src/acquisition_configuration_multi_widget.hxx
        src/acquisition_configuration_multi_widget.cxx
        src/folder_selector_viewer.hxx
        src/folder_selector_viewer.cxx
        src/can_widget.cxx
        src/can_widget.hxx
        src/serial_port.hxx
        src/serial_port.cxx
        src/tooltips.hxx
        src/selector_numbers_generic.hxx
        src/selector_numbers_generic.cxx
        )


qt5_add_resources(PROJECT_SOURCES src/images.qrc)

add_executable(daq_visu
        ${PROJECT_SOURCES}
        )

#qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})

target_link_libraries(daq_visu PRIVATE Qt5::Widgets Qt5::SerialPort
        Qt5::DataVisualization Qt5::Core Qt5::Charts Qt5::Network
        Qt5::PrintSupport git_version ${ROOT_LIBRARIES})

The error is something saying

ROOT/Config.hxx: No such file or directory

In the file a little bit more details.

Thank you very much for your help

ROOT Version: 6.24
Platform: ubuntu
Compiler: gcc


Welcome to the ROOT Forum!
Maybe How to Integrate ROOT into my project with CMake can help

On Data races TThread TTimer TApplication · Issue #8365 · root-project/root · GitHub
you have one minimal example of linking to ROOT libraries, using CMake and QtCreator as IDE (though no Qt libraries).