diff --git a/CMakeLists.txt b/CMakeLists.txt index 5281941..3667cac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required (VERSION 3.20 FATAL_ERROR) # cmake_policy(VERSION 3.18) find_package(cetmodules REQUIRED) -project(duneanaobj LANGUAGES CXX) +project(duneanaobj VERSION 03.06.01 LANGUAGES CXX) set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 03.06.01) message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================") @@ -36,10 +36,10 @@ if(DEFINED ENV{UPS_DIR}) # Removing that qualifier, we need to supply that information manually, # and maintain it too. cet_set_compiler_flags(DIAGS CAUTIOUS - WERROR - NO_UNDEFINED - ALLOW_DEPRECATIONS - EXTRA_FLAGS -pedantic -Wno-unused-local-typedefs -Wno-undefined-var-template -I $ENV{CLANG_FQ_DIR}/include/c++/v1 + WERROR + NO_UNDEFINED + ALLOW_DEPRECATIONS + EXTRA_FLAGS -pedantic -Wno-unused-local-typedefs -Wno-undefined-var-template -I $ENV{CLANG_FQ_DIR}/include/c++/v1 ) cet_report_compiler_flags() @@ -51,12 +51,27 @@ if(DEFINED ENV{UPS_DIR}) # packaging utility - + cet_cmake_config() # Put this here but am not sure... probably not going to see a lot of use anyway /shrug else() + # This is where the real stuff happens, ain't nobody usin' this cet sit find_package(ROOT) + include(BuildDictionary) include_directories(.) + + # Include module with function 'write_basic_package_version_file' + include(CMakePackageConfigHelpers) + + # Write the ConfigVersion.cmake file which can be used to + # check if a version meets the requested properties. + write_basic_package_version_file(duneanaobjConfigVersion.cmake COMPATIBILITY SameMajorVersion) + + # Write the Config.cmake file so that a user package can + # access this with find_package. + configure_package_config_file(PackageConfig.cmake.in duneanaobjConfig.cmake PATH_VARS CMAKE_INSTALL_PREFIX INSTALL_DESTINATION lib/cmake/duneanaobj) + + # Install the config files. + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfigVersion.cmake DESTINATION lib/cmake/duneanaobj) + install(EXPORT duneanaobjTargets NAMESPACE duneanaobj:: DESTINATION lib/cmake/duneanaobj)# INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() add_subdirectory(duneanaobj) - -cet_cmake_config() diff --git a/PackageConfig.cmake.in b/PackageConfig.cmake.in new file mode 100644 index 0000000..b6a8259 --- /dev/null +++ b/PackageConfig.cmake.in @@ -0,0 +1,45 @@ +########################## +# Scaldily nicked from edep-sim by Liam, sound lad Clark +# +# A template for a Config.cmake that can be found by using +# the find_package macro. This should be modified to import all of +# the dependencies required by the local package. The template is +# fairly generic, except for the "find_package" related code between +# the beginning and ending boiler plate. +# +# This expect that any targets that are being exported will be +# installed using a command like +# +# install(TARGETS myTarget +# EXPORT Targets +# etc) +# +# Note that the is set in the project( ) macro +# that should be at the start of your top level CMakeLists.txt +########################## + +############# BOILER PLATE +# Include the cmake boiler plate. The next line should not be touched +@PACKAGE_INIT@ +############# END BOILER PLATE + +########################## +# Add any specific packages that the current package depends on. This is +# where the find_package commands needed to make the current package +# compile should be listed. +########################## + +find_package(ROOT REQUIRED) +if(ROOT_FOUND) + include(${ROOT_USE_FILE}) +endif(ROOT_FOUND) + +######################### +# Leave the next couple of lines alone since it will automatically customize +# for your package. +######################### + +############# BOILER PLATE +include("@CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") +############# END BOILER PLATE diff --git a/duneanaobj/StandardRecord/CMakeLists.txt b/duneanaobj/StandardRecord/CMakeLists.txt index bd5677b..fa97fb9 100644 --- a/duneanaobj/StandardRecord/CMakeLists.txt +++ b/duneanaobj/StandardRecord/CMakeLists.txt @@ -2,10 +2,11 @@ add_subdirectory(Proxy) add_subdirectory(Flat) # for classes_def.xml!! -include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) +include_directories( ${CMAKE_CURRENT_SOURCE_DIR} "$ENV{ROOT_INCLUDE_PATH}") set( PACKAGE duneanaobj_StandardRecord ) FILE( GLOB src_files *.cxx ) +FILE( GLOB inc_files *.h ) # For this directory only, pedantic option to catch uninitialized SR fields # add_compile_options(-Weffc++) @@ -23,10 +24,16 @@ if(DEFINED CETMODULES_CURRENT_PROJECT_NAME) install_headers() install_source() else() - add_library(duneanaobj_StandardRecord - ${src_files}) - target_link_libraries(duneanaobj_StandardRecord - ROOT::Core ROOT::Physics ) + add_library(duneanaobj_StandardRecord SHARED ${src_files}) + target_link_libraries(duneanaobj_StandardRecord PUBLIC ROOT::Core ROOT::Physics) - # n.b.: missing the dictionary and installation! + #ROOT_GENERATE_DICTIONARY(duneanaobj_StandardRecord_dict DICTIONARY_LIBRARIES duneanaobj_StandardRecord) + # TODO: Need to generate the dictionary + + install(TARGETS duneanaobj_StandardRecord + EXPORT duneanaobjTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin + INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX}/include/duneanaobj) + install(FILES ${inc_files} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/duneanaobj/StandardRecord) endif() diff --git a/duneanaobj/StandardRecord/Flat/CMakeLists.txt b/duneanaobj/StandardRecord/Flat/CMakeLists.txt index 25d2ad8..750c999 100644 --- a/duneanaobj/StandardRecord/Flat/CMakeLists.txt +++ b/duneanaobj/StandardRecord/Flat/CMakeLists.txt @@ -4,15 +4,15 @@ add_custom_command(# Rebuild if anything in StandardRecord/ changes DEPENDS ${SR_DEPENDENCIES} OUTPUT FlatRecord.cxx FlatRecord.h FwdDeclare.h COMMAND gen_srproxy --flat -i duneanaobj/StandardRecord/StandardRecord.h -o FlatRecord --target caf::StandardRecord --include-path ${PROJECT_SOURCE_DIR}:$ENV{ROOT_INC} --output-path duneanaobj/StandardRecord/Flat/ --prolog ${CMAKE_CURRENT_SOURCE_DIR}/Prolog.h --extra-cflags ' -D_Float16=short -fsized-deallocation' - ) +) -include_directories($ENV{SRPROXY_INC}) +include_directories($ENV{SRPROXY_INC} ${CMAKE_BINARY_DIR}) if(DEFINED CETMODULES_CURRENT_PROJECT_NAME) cet_make_library(LIBRARY_NAME duneanaobj_StandardRecordFlat SOURCE FlatRecord.cxx LIBRARIES ${ROOT_BASIC_LIB_LIST} ROOT::TreePlayer - ) + ) if (DEFINED ENV{MRB_BUILDDIR} AND NOT "$ENV{MRB_BUILDDIR}" STREQUAL "") set(builddir $ENV{MRB_BUILDDIR}/duneanaobj) @@ -21,11 +21,12 @@ if(DEFINED CETMODULES_CURRENT_PROJECT_NAME) endif() install_headers(EXTRAS ${builddir}/duneanaobj/StandardRecord/Flat/FlatRecord.h ${builddir}/duneanaobj/StandardRecord/Flat/FwdDeclare.h) else() - add_library(duneanaobj_StandardRecordFlat - FlatRecord.cxx) + add_library(duneanaobj_StandardRecordFlat SHARED FlatRecord.cxx) target_link_libraries(duneanaobj_StandardRecordFlat ${ROOT_BASIC_LIB_LIST} ROOT::TreePlayer) + install(TARGETS duneanaobj_StandardRecordFlat) install(FILES ${CMAKE_BINARY_DIR}/duneanaobj/StandardRecord/Flat/FlatRecord.h ${CMAKE_BINARY_DIR}/duneanaobj/StandardRecord/Flat/FwdDeclare.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/duneanaobj) + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/duneanaobj/StandardRecord/Flat) +# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/duneanaobj) endif() diff --git a/duneanaobj/StandardRecord/Proxy/CMakeLists.txt b/duneanaobj/StandardRecord/Proxy/CMakeLists.txt index 3ae40de..b820416 100644 --- a/duneanaobj/StandardRecord/Proxy/CMakeLists.txt +++ b/duneanaobj/StandardRecord/Proxy/CMakeLists.txt @@ -1,12 +1,12 @@ FILE(GLOB SR_DEPENDENCIES duneanaobj/StandardRecord/*.h) add_custom_command(# Rebuild if anything in StandardRecord/ changes - DEPENDS ${SR_DEPENDENCIES} - OUTPUT SRProxy.cxx SRProxy.h FwdDeclare.h - COMMAND gen_srproxy -i duneanaobj/StandardRecord/StandardRecord.h -o SRProxy --target caf::StandardRecord --include-path ${PROJECT_SOURCE_DIR}:$ENV{ROOT_INC} --output-path duneanaobj/StandardRecord/Proxy/ --prolog ${CMAKE_CURRENT_SOURCE_DIR}/Prolog.h --epilog-fwd ${CMAKE_CURRENT_SOURCE_DIR}/EpilogFwd.h --extra-cflags ' -D_Float16=short -fsized-deallocation' - ) + DEPENDS ${SR_DEPENDENCIES} + OUTPUT SRProxy.cxx SRProxy.h FwdDeclare.h + COMMAND gen_srproxy -i duneanaobj/StandardRecord/StandardRecord.h -o SRProxy --target caf::StandardRecord --include-path ${PROJECT_SOURCE_DIR}:$ENV{ROOT_INC} --output-path duneanaobj/StandardRecord/Proxy --prolog ${CMAKE_CURRENT_SOURCE_DIR}/Prolog.h --epilog-fwd ${CMAKE_CURRENT_SOURCE_DIR}/EpilogFwd.h --extra-cflags ' -D_Float16=short -fsized-deallocation' +) -include_directories($ENV{SRPROXY_INC}) +include_directories($ENV{SRPROXY_INC} ${CMAKE_BINARY_DIR}) # This is a very picky error buried inside template instantiations #add_definitions(-Wno-int-in-bool-context) @@ -14,22 +14,23 @@ include_directories($ENV{SRPROXY_INC}) if(DEFINED CETMODULES_CURRENT_PROJECT_NAME) message(STATUS "CETMODULES_CURRENT_PROJECT_NAME = '${CETMODULES_CURRENT_PROJECT_NAME}'") cet_make_library(LIBRARY_NAME duneanaobj_StandardRecordProxy - SOURCE SRProxy.cxx Instantiations.cxx - LIBRARIES ${ROOT_BASIC_LIB_LIST} ROOT::TreePlayer) + SOURCE SRProxy.cxx Instantiations.cxx + LIBRARIES ${ROOT_BASIC_LIB_LIST} ROOT::TreePlayer) if (DEFINED ENV{MRB_BUILDDIR} AND NOT "$ENV{MRB_BUILDDIR}" STREQUAL "") message(STATUS "MRB_BUILDDIR = $ENV{MRB_BUILDDIR}") set(builddir $ENV{MRB_BUILDDIR}/duneanaobj) else() + message(STATUS "BUILDDIR defaulting to ${CMAKE_BINARY_DIR}") set(builddir ${CMAKE_BINARY_DIR}) endif() install_headers(EXTRAS ${builddir}/duneanaobj/StandardRecord/Proxy/SRProxy.h ${builddir}/duneanaobj/StandardRecord/Proxy/FwdDeclare.h) else() - add_library(duneanaobj_StandardRecordProxy - SRProxy.cxx Instantiations.cxx) + add_library(duneanaobj_StandardRecordProxy SHARED SRProxy.cxx Instantiations.cxx) target_link_libraries(duneanaobj_StandardRecordProxy ${ROOT_BASIC_LIB_LIST} ROOT::TreePlayer) + install(TARGETS duneanaobj_StandardRecordProxy) install(FILES ${CMAKE_BINARY_DIR}/duneanaobj/StandardRecord/Proxy/SRProxy.h ${CMAKE_BINARY_DIR}/duneanaobj/StandardRecord/Proxy/FwdDeclare.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/duneanaobj) + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/duneanaobj/StandardRecord/Proxy) endif()