diff --git a/CMakeLists.txt b/CMakeLists.txt index cd0edff..0975373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,91 +1,97 @@ # Top level CMakeLists.txt for Laura++ # Enforce an out-of-source build. # Should be the first action in the top level CMakeLists.txt if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(STATUS "Laura++ requires an out-of-source build.") message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:") message(STATUS " CMakeCache.txt") message(STATUS " CMakeFiles") message(STATUS "Once these files are removed, create a separate directory") message(STATUS "and run CMake from there, pointing it to:") message(STATUS " ${CMAKE_SOURCE_DIR}") message(FATAL_ERROR "in-source build detected") endif() # Also require a minimum version of CMake cmake_minimum_required(VERSION 3.12.0) # Project setup project(Laura++ VERSION 3.6.0 DESCRIPTION "A maximum likelihood fitting package for performing Dalitz-plot analysis." HOMEPAGE_URL "https://laura.hepforge.org" ) # Option to enable/disable compilation of the RooFit slave class option(LAURA_BUILD_ROOFIT_SLAVE "Enable/disable compilation of RooFit slave class" OFF) # Option to enable/disable building of the Doxygen documentation option(LAURA_BUILD_DOCS "Enable/disable building of Doxygen documentation" OFF) # Options to enable/disable compilation of the example/test executables option(LAURA_BUILD_EXAMPLES "Enable/disable compilation of example executables" OFF) option(LAURA_BUILD_TESTS "Enable/disable compilation of test executables" OFF) +message(STATUS "Laura++: Optional compilation of RooFit slave class LAURA_BUILD_ROOFIT_SLAVE ${LAURA_BUILD_ROOFIT_SLAVE}") +message(STATUS "Laura++: Optional building of Doxygen documentation LAURA_BUILD_DOCS ${LAURA_BUILD_DOCS}") +message(STATUS "Laura++: Optional building of example executables LAURA_BUILD_EXAMPLES ${LAURA_BUILD_EXAMPLES}") +message(STATUS "Laura++: Optional building of test executables LAURA_BUILD_TESTS ${LAURA_BUILD_TESTS}") + # Prepend this project's custom module path(s) to CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) # Include needed modules and perform any custom setup # Install paths include(GNUInstallDirs) # Compilation/linking flags and related settings include(LauraCompilerFlags) # External dependencies include(LauraExternalDependencies) # Create the documentation if(LAURA_BUILD_DOCS) add_subdirectory(doc) endif() # Install the headers add_subdirectory(inc) # Now build and install the library add_subdirectory(src) # Build and install the executables in the examples directory if(LAURA_BUILD_EXAMPLES) add_subdirectory(examples) endif() if(LAURA_BUILD_TESTS) add_subdirectory(test) endif() # Generate CMake config files, which can be used by other projects include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) +set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}) configure_package_config_file(cmake/Templates/LauraConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LauraConfig.cmake - INSTALL_DESTINATION cmake - PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR + INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/cmake + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR DATA_INSTALL_DIR ) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/LauraConfigVersion.cmake COMPATIBILITY AnyNewerVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LauraConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/LauraConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake + DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/cmake ) install( EXPORT "LauraTargets" NAMESPACE "Laura::" - DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake + DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/cmake ) diff --git a/cmake/Modules/LauraExternalDependencies.cmake b/cmake/Modules/LauraExternalDependencies.cmake index 3b168c8..4a0bfc6 100644 --- a/cmake/Modules/LauraExternalDependencies.cmake +++ b/cmake/Modules/LauraExternalDependencies.cmake @@ -1,24 +1,32 @@ # Laura++ needs ROOT, we just require that it is a version that exports CMake targets properly # We may depend on other things in the future, e.g. JSON or YAML for easier configuration of particle properties etc. if(DEFINED ENV{ROOTSYS}) list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS}) endif() if(LAURA_BUILD_ROOFIT_SLAVE) find_package(ROOT 6.14 REQUIRED COMPONENTS EG RooFitCore RooFit) else() find_package(ROOT 6.14 REQUIRED COMPONENTS EG) endif() #message(STATUS "ROOT include directories: ${ROOT_INCLUDE_DIRS}") #message(STATUS "ROOT libraries: ${ROOT_LIBRARIES}") #message(STATUS "ROOT definitions: ${ROOT_DEFINITIONS}") #message(STATUS "ROOT CXX flags: ${ROOT_CXX_FLAGS}") #message(STATUS "ROOT CC flags: ${ROOT_CC_FLAGS}") #message(STATUS "ROOT use file: ${ROOT_USE_FILE}") # Don't want to do this because it uses old-style CMake #include(${ROOT_USE_FILE}) -include(${ROOT_DIR}/modules/RootNewMacros.cmake) +if(EXISTS "${ROOT_DIR}/RootMacros.cmake") + message(STATUS "Laura++: Including ROOT macros module: ${ROOT_DIR}/RootMacros.cmake") + include(${ROOT_DIR}/RootMacros.cmake) +elseif(EXISTS "${ROOT_DIR}/modules/RootNewMacros.cmake") + message(STATUS "Laura++: Including ROOT macros module: ${ROOT_DIR}/modules/RootNewMacros.cmake") + include(${ROOT_DIR}/modules/RootNewMacros.cmake) +else() + message(WARNING "Laura++: Cannot locate ROOT macros module in ${ROOT_DIR}") +endif() diff --git a/cmake/Templates/LauraConfig.cmake.in b/cmake/Templates/LauraConfig.cmake.in index c15c21a..b9824d0 100644 --- a/cmake/Templates/LauraConfig.cmake.in +++ b/cmake/Templates/LauraConfig.cmake.in @@ -1,8 +1,9 @@ @PACKAGE_INIT@ include("${CMAKE_CURRENT_LIST_DIR}/LauraTargets.cmake") -set_and_check(EVTGEN_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") -set_and_check(EVTGEN_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") +set_and_check(LAURA_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(LAURA_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") +set_and_check(LAURA_DATA_DIR "@PACKAGE_DATA_INSTALL_DIR@") check_required_components("@PROJECT_NAME@")