-
Tobias Triffterer authored
This class shall encapsulate a TCanvas instance from ROOT. The code is inspired by this ROOT forum thread https://root-forum.cern.ch/t/gvirtualx-addwindow-problem/25215/5 and this example posted there: https://root-forum.cern.ch/uploads/default/original/2X/4/4f1f5269962b0622a04fa6093c805f5573669df4.gz
Verified72ce8e2a
CMakeLists.txt 4.99 KiB
#
# @file CMakeLists.txt
#
# @author Tobias Triffterer
#
# Rutherford Experiment Lab Course Online
# Copyright © 2021 Ruhr-Universität Bochum, Institut für Experimentalphysik I
# https://www.ep1.ruhr-uni-bochum.de/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.13)
project(libfp311online)
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(LIBFP311ONLINE_KNOWN_BUILD_TYPES Debug Release MinSizeRel RelWithDebInfo)
list(FIND LIBFP311ONLINE_KNOWN_BUILD_TYPES ${CMAKE_BUILD_TYPE} LIBFP311ONLINE_BUILD_TYPE_VALID)
if (${LIBFP311ONLINE_BUILD_TYPE_VALID} EQUAL -1)
message(WARNING "The build type \"${CMAKE_BUILD_TYPE}\" for simulact is not recognized. Valid values are \"Debug\", \"Release\", \"MinSizeRel\", and \"RelWithDebInfo\".\nSee https://cmake.org/cmake/help/v3.13/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type for more information.\nThe project can be built, but if you have not taken the necessary steps outlined in the CMake documentation to create a custom build type, the behaviour is undefined.")
endif (${LIBFP311ONLINE_BUILD_TYPE_VALID} EQUAL -1)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif(NOT CMAKE_CXX_STANDARD)
# Instruct CMake to create a compile_commands.json file for clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Find Qt
find_package(Qt5 COMPONENTS Core Gui Widgets DBus LinguistTools CONFIG REQUIRED)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Instruct CMake to run qrc automatically when needed.
set(CMAKE_AUTORCC ON)
# Generate version information
add_custom_target(
libfp311online_versioning
ALL
DEPENDS "src/version.libfp311online.cpp.in"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/version.libfp311online.cpp"
COMMENT "Generating git-based version information for libfp311online..."
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DCURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DCURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P "${CMAKE_CURRENT_SOURCE_DIR}/versioning.cmake"
)
set(LIBFP311ONLINE_COMPILE_FLAGS -Wall -Wextra -Wconversion -Weffc++ -Wshadow -Wwrite-strings -Wredundant-decls -Wcast-align -Wmissing-include-dirs -Wmissing-declarations -Wswitch-enum -Wswitch-default -Winvalid-pch -Wformat=2 -Wmissing-format-attribute -pedantic -pthread -fexceptions -fstack-protector-strong -Wstack-protector $<$<CONFIG:Release>:-D_FORTIFY_SOURCE=2> $<$<CONFIG:RelWithDebInfo>:-D_FORTIFY_SOURCE=2> $<$<CONFIG:MinSizeRel>:-D_FORTIFY_SOURCE=2>)
set(LIBFP311ONLINE_LINK_FLAGS -rdynamic -pthread -Wl,-z,relro,-z,now -pie)
set(libfp311online_SRCS
src/clilogger.cpp
src/command.cpp
src/experimentstate.cpp
src/rootcanvaswidget.cpp
"${CMAKE_CURRENT_BINARY_DIR}/version.libfp311online.cpp"
)
option(USE_HOST_ROOT_INSTALL "Use the ROOT (https://root.cern) installation present on the host system instead of the submodule. Only enable if you know that your ROOT installation is compatible and discoverable for CMake." ON) # Default to host root during develoment
if (${USE_HOST_ROOT_INSTALL})
find_package(ROOT CONFIG COMPONENTS Hist HistPainter RooFit Minuit2 REQUIRED)
else()
include(${PROJECT_SOURCE_DIR}/cmake/build-root-submodule.cmake)
endif (${USE_HOST_ROOT_INSTALL})
add_library(fp311online STATIC
${libfp311online_SRCS}
)
include(GenerateExportHeader)
generate_export_header(fp311online)
target_compile_features(fp311online PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
target_compile_options(fp311online PRIVATE $<$<CXX_COMPILER_ID:GNU>:${LIBFP311ONLINE_COMPILE_FLAGS}>)
target_compile_options(fp311online PRIVATE $<$<CXX_COMPILER_ID:Clang>:${LIBFP311ONLINE_COMPILE_FLAGS}>)
target_link_options(fp311online PRIVATE $<$<CXX_COMPILER_ID:GNU>:${LIBFP311ONLINE_LINK_FLAGS}>)
target_link_options(fp311online PRIVATE $<$<CXX_COMPILER_ID:Clang>:${LIBFP311ONLINE_LINK_FLAGS}>)
target_include_directories(fp311online PUBLIC ${CMAKE_CURRENT_BINARY_DIR} src/)
add_dependencies(fp311online libfp311online_versioning)
target_link_libraries(fp311online PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets ROOT::Hist ROOT::HistPainter ROOT::Minuit2 -lpthread)
set_property(TARGET fp311online PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET fp311online PROPERTY CXX_VISIBILITY_PRESET hidden)
set_property(TARGET fp311online PROPERTY VISIBILITY_INLINES_HIDDEN ON)