Skip to content
Snippets Groups Projects
Commit bc01b8fb authored by Ole Hansen's avatar Ole Hansen Committed by Stephen A. Wood
Browse files

CMake updates:

1. Update for ROOT5-enabled root_generate_dictionary CMake function

  root_generate_dictionary now works with both ROOT 5 and ROOT 6.
  It defines the dictionary custom target and PCM file internally,
  as appropriate, and also automatically extracts any required
  -D compile definitions from the given target(s).

2. Add configuration option HCANA_BUILTIN_PODD (default ON)

  If set to OFF (cmake -DHCANA_BUILTIN_PODD=OFF ...), CMake will find a
  pre-built version of Podd according to the usual find_package search
  rules. (It's sufficient to have the installed "analyzer" in your PATH,
  but you can also set CMAKE_PREFIX_PATH to the Podd installation root,
  for example.) This version of Podd has to have been built and
  installed with Podd's CMake system. In this case, only libHallC will
  be built, and the Podd submodule of hcana is ignored and does not even
  have to be present.

3. Clean existing src/hc_compiledata.h during CMake configuration

  This file might be left over from a previous non-CMake build and would
  be incorrectly picked up instead of the CMake-generated version.

4. Generate hcanaConfig.cmake config and version files using latest Podd scripts

  Requires Podd at commit JeffersonLab/analyzer@34dd368
parent 4fdc46f7
No related branches found
No related tags found
No related merge requests found
......@@ -2,22 +2,27 @@ cmake_minimum_required(VERSION 3.5)
project(hcana VERSION 0.90 LANGUAGES CXX)
#----------------------------------------------------------------------------
# Use our modules and utility functions
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/podd/cmake/Modules
${CMAKE_MODULE_PATH}
)
include(PoddCMakeEnv)
option(HCANA_BUILTIN_PODD "Use built-in Podd submodule (default: YES)" ON)
#----------------------------------------------------------------------------
# Install in GNU-style directory layout
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME_LC})
# Set up Podd and ROOT dependencies
if(HCANA_BUILTIN_PODD)
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/podd/cmake/Modules
${CMAKE_MODULE_PATH}
)
include(PoddCMakeEnv)
find_package(ROOT 5.10 REQUIRED)
else()
# Find Podd and register it as a dependency
# This will also automatically set up ROOT
find_package(Podd 1.6 REQUIRED)
include(PoddCMakeEnv)
config_add_dependency(Podd 1.6)
endif()
#----------------------------------------------------------------------------
# Find ROOT (using Podd's FindROOT.cmake)
find_package(ROOT 5.10 MODULE REQUIRED)
# Register ROOT dependency - it's in our public interface
config_add_dependency(ROOT 5.10)
#----------------------------------------------------------------------------
# Set up the compiler flags
......@@ -26,14 +31,14 @@ set_diagnostic_flags(WALL WEXTRA)
report_build_info()
#----------------------------------------------------------------------------
# Directories in which we build things
add_subdirectory(podd)
add_subdirectory(src)
# Install in GNU-style directory layout
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/${MAIN_PROJECT_NAME_LC})
#----------------------------------------------------------------------------
# Install and export targets defined in the subdirectories
install(EXPORT ${PROJECT_NAME_LC}-exports
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${INSTALL_CONFIGDIR}
)
# Directories in which we build things
if(HCANA_BUILTIN_PODD)
add_subdirectory(podd)
endif()
add_subdirectory(src)
add_subdirectory(cmake)
# Create <Project>Config.cmake and <Project>ConfigVersion.cmake
include(WriteProjectConfig)
@PACKAGE_INIT@
message(STATUS "Found @PROJECT_NAME@: @PACKAGE_CMAKE_INSTALL_PREFIX@ (found version @PROJECT_VERSION@@EXTVERS@)")
set_and_check(@PROJECT_NAME_UC@_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@")
set_and_check(@PROJECT_NAME_UC@_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
if(IS_DIRECTORY "@PACKAGE_INSTALL_CONFIGDIR@/Modules")
list(APPEND CMAKE_MODULE_PATH "@PACKAGE_INSTALL_CONFIGDIR@/Modules")
endif()
@FIND_DEPENDENCY_COMMANDS@
include("@PACKAGE_TARGETS_FILE@")
check_required_components(@PROJECT_NAME_UC@)
......@@ -40,8 +40,12 @@ file(APPEND "${linkdef}" "${postamble}")
unset(postamble)
#----------------------------------------------------------------------------
# Generate ha_compiledata.h
# Generate hc_compiledata.h
include(PoddCompileInfo)
# Ensure there's no old hc_compiledata.h hanging around from a non-CMake build
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/hc_compiledata.h")
configure_file(hc_compiledata.h.in hc_compiledata.h)
list(APPEND allheaders "${CMAKE_CURRENT_BINARY_DIR}/hc_compiledata.h")
......@@ -79,7 +83,7 @@ set_target_properties(${LIBNAME} PROPERTIES
)
install(TARGETS ${LIBNAME}
EXPORT ${PROJECT_NAME_LC}-exports
EXPORT ${MAIN_PROJECT_NAME_LC}-exports
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
......@@ -88,18 +92,10 @@ install(FILES ${allheaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#----------------------------------------------------------------------------
# libHallCDict
get_target_definitions(${LIBNAME} defines)
root_generate_dictionary(${LIBNAME} ${defines} ${headers}
build_root_dictionary(${LIBNAME} ${headers}
TARGETS ${LIBNAME}
LINKDEF ${linkdef}
)
set(PCM_FILE ${CMAKE_CURRENT_BINARY_DIR}/lib${LIBNAME}_rdict.pcm)
add_custom_target(${LIBNAME}_ROOTDICT
DEPENDS ${src} ${headers} ${LIBNAME}_LinkDef.h ${LIBNAME}Dict.cxx)
install(FILES ${PCM_FILE} DESTINATION ${CMAKE_INSTALL_LIBDIR})
#----------------------------------------------------------------------------
# hcana executable
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment