Skip to content

Commit 51e85e9

Browse files
authored
Merge pull request #64 from DUNE/63-skip-cet-option
Add SKIP_CET option for standalone build without CET/cetmodules
2 parents 7c3f8ab + f757c21 commit 51e85e9

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
cmake_minimum_required (VERSION 3.20 FATAL_ERROR)
1717
# cmake_policy(VERSION 3.18)
1818

19-
find_package(cetmodules REQUIRED)
20-
project(duneanaobj LANGUAGES CXX)
21-
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING 03.12.00)
19+
project(duneanaobj VERSION 03.12.00 LANGUAGES CXX)
20+
set(${PROJECT_NAME}_CMAKE_PROJECT_VERSION_STRING ${PROJECT_VERSION})
2221

2322
message(STATUS "\n\n ========================== ${PROJECT_NAME} ==========================")
2423

24+
option(SKIP_CET "Build without CET/cetmodules dependencies" OFF)
25+
2526
if(DEFINED ENV{UPS_DIR})
27+
find_package(cetmodules REQUIRED)
2628
# cetbuildtools contains our cmake modules
2729

2830
include(CetCMakeEnv)
@@ -59,4 +61,6 @@ endif()
5961

6062
add_subdirectory(duneanaobj)
6163

62-
cet_cmake_config()
64+
if (NOT SKIP_CET)
65+
cet_cmake_config()
66+
endif()

duneanaobj/StandardRecord/CMakeLists.txt

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
add_subdirectory(Proxy)
2-
add_subdirectory(Flat)
31

42
# for classes_def.xml!!
53
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
@@ -11,6 +9,9 @@ FILE( GLOB src_files *.cxx )
119
# add_compile_options(-Weffc++)
1210

1311
if(DEFINED CETMODULES_CURRENT_PROJECT_NAME)
12+
add_subdirectory(Proxy)
13+
add_subdirectory(Flat)
14+
1415
cet_make_library( LIBRARY_NAME duneanaobj_StandardRecord
1516
SOURCE ${src_files}
1617
LIBRARIES ROOT::Core ROOT::Physics
@@ -22,6 +23,51 @@ if(DEFINED CETMODULES_CURRENT_PROJECT_NAME)
2223

2324
install_headers()
2425
install_source()
26+
elseif(SKIP_CET)
27+
# n.b.: missing Proxy, Plain and the dictionary!
28+
29+
include(GNUInstallDirs)
30+
31+
# Create and configure library target
32+
add_library( StandardRecord SHARED
33+
${src_files}
34+
)
35+
36+
target_link_libraries( StandardRecord
37+
ROOT::Core ROOT::Physics
38+
)
39+
40+
# Setup installation
41+
file( GLOB headers_files *.h )
42+
43+
install( TARGETS StandardRecord EXPORT duneanaobjTargets DESTINATION ${CMAKE_INSTALL_LIBDIR} )
44+
install( FILES ${headers_files} DESTINATION "include/duneanaobj/StandardRecord" )
45+
46+
# Setup CMake find_package related files
47+
install( EXPORT duneanaobjTargets
48+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/duneanaobj"
49+
NAMESPACE duneanaobj::
50+
FILE duneanaobjTargets.cmake
51+
)
52+
53+
include(CMakePackageConfigHelpers)
54+
configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
55+
"${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfig.cmake"
56+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/duneanaobj"
57+
PATH_VARS CMAKE_INSTALL_LIBDIR
58+
)
59+
60+
write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfigVersion.cmake"
61+
VERSION ${PROJECT_VERSION}
62+
COMPATIBILITY SameMajorVersion
63+
)
64+
65+
# Install these files too
66+
install( FILES
67+
"${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfig.cmake"
68+
"${CMAKE_CURRENT_BINARY_DIR}/duneanaobjConfigVersion.cmake"
69+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/duneanaobj"
70+
)
2571
else()
2672
add_library(duneanaobj_StandardRecord
2773
${src_files})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
@PACKAGE_INIT@
3+
4+
include ( "${CMAKE_CURRENT_LIST_DIR}/duneanaobjTargets.cmake" )

0 commit comments

Comments
 (0)