# - spirit_fcn_test
cmake_minimum_required(VERSION 3.17)

project(spirit_fcn_test VERSION 0.1 LANGUAGES CXX)

include(GNUInstallDirs)

#--- set a default build type if none was specified ---------------------------
set(default_build_type "Debug")

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
      STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()

#--- check for pkg-config -----------------------------------------------------
find_package(PkgConfig REQUIRED)

#--- check for ROOT -----------------------------------------------------------
find_package(ROOT 6.18 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser)
if (ROOT_mathmore_FOUND)
  #---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
  include(${ROOT_USE_FILE})
endif (ROOT_mathmore_FOUND)

#--- check for boost ----------------------------------------------------------
find_package(Boost QUIET)
if (Boost_VERSION VERSION_GREATER_EQUAL "1.89")
  find_package(Boost REQUIRED COMPONENTS filesystem)
  set(BOOST_LINK_LIBS Boost::filesystem)
else (Boost_VERSION VERSION_GREATER_EQUAL "1.89")
  find_package(Boost REQUIRED COMPONENTS system filesystem)
  set(BOOST_LINK_LIBS Boost::filesystem Boost::system)
endif (Boost_VERSION VERSION_GREATER_EQUAL "1.89")

#--- create executable --------------------------------------------------------
add_executable(spirit_fcn_test
	       spirit_fcn_test.cpp
               PFunction.cpp
	       PFunctionHandler.cpp
)

#--- add include directories --------------------------------------------------
target_include_directories(spirit_fcn_test
  BEFORE PRIVATE
    ${Boost_INCLUDE_DIRS}
)

#--- link libraries -----------------------------------------------------------
target_link_libraries(spirit_fcn_test
  ${ROOT_LIBRARIES}
  ${BOOST_LINK_LIBS}
)

#--- installation info --------------------------------------------------------
install(
  TARGETS
    spirit_fcn_test
  RUNTIME DESTINATION
    ${CMAKE_INSTALL_BINDIR}
)
