# Set the minimum CMake version required to build the project. cmake_minimum_required( VERSION 3.6 ) set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Path to the install directory") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # Set the project's name and version. project( FastFrames ) # Set up the "C++ version" to use. set( CMAKE_CXX_STANDARD_REQUIRED 17 CACHE STRING "Minimum C++ standard required for the build" ) set( CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use for the build" ) set( CMAKE_CXX_EXTENSIONS FALSE CACHE BOOL "(Dis)allow using compiler extensions" ) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Specify the install locations for libraries and binaries. set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) set( CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/lib ) # Needed by ROOT_GENERATE_DICTIONARY() set(FastFrames_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include" CACHE STRING "Path to the includes") # Set the warning flag(s) to use. set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wshadow -pedantic -O3 -g" ) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # ------------------------------------------------ # Dependencies and sub-libraries # ------------------------------------------------ find_package( Boost COMPONENTS python REQUIRED ) # hack for homebrew installation and potentially some other platforms if( EXISTS "${Boost_INCLUDE_DIR}/root" ) set( ROOT_EXTRA_INCLUDE_DIR "${Boost_INCLUDE_DIR}/root" ) string( REPLACE "/include/" "/lib/" ROOT_EXTRA_LIB_DIR "${ROOT_EXTRA_INCLUDE_DIR}" ) list( APPEND CMAKE_INCLUDE_PATH "${ROOT_EXTRA_INCLUDE_DIR}" ) list( APPEND CMAKE_LIBRARY_PATH "${ROOT_EXTRA_LIB_DIR}" ) endif() # Add ROOT system directory and require ROOT. find_package( ROOT 6.28.00 REQUIRED COMPONENTS Core Hist RIO Tree ROOTDataFrame ROOTVecOps) message(STATUS "The value of FOUND_ROOT is: ${ROOT_FOUND}") message(STATUS "The value of ROOT_INCLUDE_DIRS is: ${ROOT_INCLUDE_DIRS}") message(STATUS "The value of ROOT_LIBRARIES is: ${ROOT_LIBRARIES}") find_package( Python3 COMPONENTS Development REQUIRED ) find_package( LCG QUIET ) find_package( onnxruntime QUIET ) include_directories(${CMAKE_SOURCE_DIR}) # ------------------------------------------------ # The actual FastFrames library # ------------------------------------------------ file(GLOB SOURCES "Root/*.cc" ) file(GLOB LIB_HEADERS "FastFrames/*.h" ) # Build the shared library. add_library( FastFrames SHARED ${LIB_HEADERS} ${SOURCES} ) set_target_properties(FastFrames PROPERTIES SUFFIX ".so") target_include_directories( FastFrames PUBLIC $ ${ONNXRUNTIME_INCLUDE_DIRS} ) target_include_directories(FastFrames SYSTEM PUBLIC ${ONNXRUNTIME_INCLUDE_DIRS} ) target_link_libraries( FastFrames PUBLIC ROOT::Core ROOT::Hist ROOT::RIO ROOT::Tree ROOT::ROOTDataFrame ROOT::ROOTVecOps ${ONNXRUNTIME_LIBRARIES} ) set_property( TARGET FastFrames PROPERTY PUBLIC_HEADER ${LIB_HEADERS} ) # Build the Python module for C++ logger add_library( cppLogger SHARED python_wrapper/utils/Logger.cxx ) set_target_properties(cppLogger PROPERTIES SUFFIX ".so") target_link_libraries( cppLogger PRIVATE Python3::Python ) set_target_properties( cppLogger PROPERTIES PREFIX "" OUTPUT_NAME "cppLogger" ) # Build the Python module for config reader add_library( ConfigReaderCpp SHARED python_wrapper/utils/ConfigReaderCpp.cxx ${LIB_HEADERS} ) set_target_properties(ConfigReaderCpp PROPERTIES SUFFIX ".so") target_link_libraries( ConfigReaderCpp PRIVATE Python3::Python ${Boost_LIBRARIES} FastFrames ) set_target_properties( ConfigReaderCpp PROPERTIES PREFIX "" OUTPUT_NAME "ConfigReaderCpp" ) set(SETUP ${CMAKE_CURRENT_BINARY_DIR}/setup.sh) file(WRITE ${SETUP} "#!/bin/bash\n") file(APPEND ${SETUP} "# this is an auto-generated setup script\n" ) file(APPEND ${SETUP} "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${CMAKE_INSTALL_PREFIX}/lib\n") file(APPEND ${SETUP} "export PATH=\${PATH}:${CMAKE_CURRENT_SOURCE_DIR}/python\n") # Install the libraries. install( TARGETS FastFrames ConfigReaderCpp cppLogger EXPORT FastFramesTargets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/FastFrames ) # Export the targets. install( EXPORT FastFramesTargets FILE FastFramesTargets.cmake NAMESPACE FastFrames:: DESTINATION lib/cmake/FastFrames ) # Create a Config file for the package. include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_LIST_DIR}/FastFramesConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/FastFramesConfig.cmake" INSTALL_DESTINATION lib/cmake/FastFrames PATH_VARS CMAKE_INSTALL_PREFIX ) # Install the Config file. install( FILES "${CMAKE_CURRENT_BINARY_DIR}/FastFramesConfig.cmake" DESTINATION lib/cmake/FastFrames ) # ------------------------------------------------ # FastFrames executables # ------------------------------------------------ # Helper macro for building the project's executables. macro( FastFrames_add_executable name ) add_executable( ${name} ${ARGN} ) target_link_libraries( ${name} FastFrames) install( TARGETS ${name} EXPORT FastFramesTargets RUNTIME DESTINATION bin ) endmacro( FastFrames_add_executable ) FastFrames_add_executable( fast-frames.exe util/fast-frames.cc ) ROOT_GENERATE_DICTIONARY(FastFrames_dict FastFrames/MainFrame.h MODULE FastFrames LINKDEF Root/LinkDef.h) # needed as ROOT_GENERATE_DICTIONARY does not support system includes target_compile_options(FastFrames_dict PUBLIC -Wno-shadow) get_target_property(LIB_FastFrames_dict_INCLUDES FastFrames_dict INCLUDE_DIRECTORIES) message(STATUS "The value of LIB_FastFrames_dict_INCLUDES is: ${LIB_FastFrames_dict_INCLUDES}") target_include_directories(FastFrames_dict PUBLIC ${ROOT_INCLUDE_DIRS} ) message(STATUS "The value of LIB_FastFrames_dict_INCLUDES is: ${LIB_FastFrames_dict_INCLUDES}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/lib${PROJECT_NAME}_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/lib/lib${PROJECT_NAME}.rootmap DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)