Skip to content

Commit 73ce134

Browse files
aphecetchektf
authored andcommitted
Preparation work for the removal of the O2RecipeAdapter.
Extract the test adapter (that will stay) from the recipe adapter (that will go away at some point). Make a couple of find modules work with the environment version of the <PACKAGE>_ROOT cmake variables, so they will work when the corresponding variable will be removed from command line used in the o2.sh alidist recipe (the numerous -Dxxx_ROOT= lines)
1 parent d9284b1 commit 73ce134

7 files changed

Lines changed: 92 additions & 72 deletions

File tree

dependencies/FindFairRoot.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
find_path(FairRoot_INC FairDetector.h
1414
PATH_SUFFIXES FairRoot/include
15-
PATHS ${FAIRROOTPATH}/include)
16-
17-
# if(NOT EXISTS ${FairRoot_INC}) set(FairRoot_FOUND FALSE)
18-
# if(FairRoot_FIND_REQUIRED) message(FATAL_ERROR "Could not find FairRoot")
19-
# endif() return() endif()
15+
PATHS ${FAIRROOTPATH}/include
16+
${FAIRROOT_ROOT}/include
17+
$ENV{FAIRROOT_ROOT}/include)
2018

2119
get_filename_component(FairRoot_TOPDIR "${FairRoot_INC}/.." ABSOLUTE)
2220

dependencies/Findms_gsl.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11-
find_path(MS_GSL_INCLUDE_DIR gsl/gsl PATH_SUFFIXES ms_gsl/include)
11+
find_path(MS_GSL_INCLUDE_DIR gsl/gsl PATH_SUFFIXES ms_gsl/include include
12+
PATHS $ENV{MS_GSL_ROOT})
1213

1314
if(NOT MS_GSL_INCLUDE_DIR)
1415
set(MS_GSL_FOUND FALSE)

dependencies/Findpythia.cmake

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,39 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11-
find_path(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR
11+
set(PKGNAME ${CMAKE_FIND_PACKAGE_NAME})
12+
string(TOUPPER ${PKGNAME} PKGENVNAME)
13+
14+
find_path(${PKGNAME}_INCLUDE_DIR
1215
NAMES Pythia.h
13-
PATH_SUFFIXES Pythia8)
16+
PATH_SUFFIXES Pythia8
17+
PATHS $ENV{${PKGENVNAME}_ROOT}/include)
1418

15-
find_library(${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED
16-
NAMES libpythia8.so libpythia8.dylib)
19+
find_library(${PKGNAME}_LIBRARY_SHARED NAMES libpythia8.so libpythia8.dylib
20+
PATHS $ENV{${PKGENVNAME}_ROOT}/lib)
1721

18-
find_path(${CMAKE_FIND_PACKAGE_NAME}_DATA
22+
find_path(${PKGNAME}_DATA
1923
NAMES MainProgramSettings.xml
20-
PATHS ${${CMAKE_FIND_PACKAGE_NAME}_ROOT}/share/Pythia8/xmldoc)
24+
PATHS ${${PKGNAME}_ROOT}/share/Pythia8/xmldoc
25+
$ENV{${PKGENVNAME}_ROOT}/share/Pythia8/xmldoc)
2126

22-
if(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR
23-
AND ${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED
24-
AND ${CMAKE_FIND_PACKAGE_NAME}_DATA)
27+
if(${PKGNAME}_INCLUDE_DIR AND ${PKGNAME}_LIBRARY_SHARED AND ${PKGNAME}_DATA)
2528
add_library(pythia SHARED IMPORTED)
26-
get_filename_component(incdir ${${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR}/..
27-
ABSOLUTE)
29+
get_filename_component(incdir ${${PKGNAME}_INCLUDE_DIR}/.. ABSOLUTE)
2830
set_target_properties(pythia
2931
PROPERTIES IMPORTED_LOCATION
30-
${${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED}
32+
${${PKGNAME}_LIBRARY_SHARED}
3133
INTERFACE_INCLUDE_DIRECTORIES ${incdir})
3234
endif()
3335

3436
include(FindPackageHandleStandardArgs)
35-
find_package_handle_standard_args(
36-
${CMAKE_FIND_PACKAGE_NAME}
37-
REQUIRED_VARS ${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR
38-
${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED
39-
${CMAKE_FIND_PACKAGE_NAME}_DATA)
40-
41-
mark_as_advanced(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIR
42-
${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED
43-
${CMAKE_FIND_PACKAGE_NAME}_DATA)
37+
find_package_handle_standard_args(${PKGNAME}
38+
REQUIRED_VARS ${PKGNAME}_INCLUDE_DIR
39+
${PKGNAME}_LIBRARY_SHARED
40+
${PKGNAME}_DATA)
41+
42+
mark_as_advanced(${PKGNAME}_INCLUDE_DIR ${PKGNAME}_LIBRARY_SHARED
43+
${PKGNAME}_DATA)
44+
45+
unset(PKGNAME)
46+
unset(PKGENVNAME)

dependencies/Findpythia6.cmake

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11-
find_library(${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED
12-
NAMES libpythia6.so libpythia6.dylib)
11+
set(PKGNAME ${CMAKE_FIND_PACKAGE_NAME})
12+
string(TOUPPER ${PKGNAME} PKGENVNAME)
1313

14-
if(${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED)
14+
find_library(${PKGNAME}_LIBRARY_SHARED
15+
NAMES libpythia6.so libpythia6.dylib
16+
PATHS $ENV{${PKGENVNAME}_ROOT}/lib)
17+
18+
if(${PKGNAME}_LIBRARY_SHARED)
1519
add_library(pythia6 SHARED IMPORTED)
1620
set_target_properties(pythia6
1721
PROPERTIES IMPORTED_LOCATION
18-
${${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED})
22+
${${PKGNAME}_LIBRARY_SHARED})
1923
endif()
2024

2125
include(FindPackageHandleStandardArgs)
2226
find_package_handle_standard_args(
23-
${CMAKE_FIND_PACKAGE_NAME}
24-
REQUIRED_VARS ${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED)
27+
${PKGNAME}
28+
REQUIRED_VARS ${PKGNAME}_LIBRARY_SHARED)
29+
30+
mark_as_advanced(${PKGNAME}_LIBRARY_SHARED)
2531

26-
mark_as_advanced(${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_SHARED)
32+
unset(PKGNAME)
33+
unset(PKGENVNAME)

dependencies/O2Dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
include_guard()
1212

1313
include("${CMAKE_CURRENT_LIST_DIR}/O2RecipeAdapter.cmake")
14+
include("${CMAKE_CURRENT_LIST_DIR}/O2TestsAdapter.cmake")
1415

1516
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
1617

dependencies/O2RecipeAdapter.cmake

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,9 @@
1111
# FIXME: this part should disappear when we merge all this new cmake stuff and
1212
# we change the o2.sh recipe accordingly.
1313
#
14-
# We "adapt" two things here :
15-
#
16-
# 1. we unset most of the -D variables that were passed to cmake so our auto-
17-
# detection has a chance to work. Should not be needed in the long run if we
18-
# use the correct -D set from the beginning
19-
#
20-
# 1. we patch those tests that require some environment (most notably the O2_ROOT
21-
# variable) to convert from O2_ROOT pointing to build tree to O2_ROOT pointing
22-
# to install tree. Should not be needed in the long run if we consider (as we
23-
# should, I would argue) that tests are running off the build tree, before
24-
# installation (and are not installed, as there's probably no point in doing
25-
# so) Should not be needed in the long run if we consider (as we should, I
26-
# would argue) that tests are running off the build tree, before installation
27-
# (and are not installed, as there's probably no point in doing so)
14+
# we unset most of the -D variables that were passed to cmake so our auto-
15+
# detection has a chance to work. Should not be needed in the long run if we use
16+
# the correct -D set from the beginning
2817
#
2918

3019
function(o2_show_env var)
@@ -43,11 +32,12 @@ macro(o2_unset var)
4332
unset(${var})
4433
endmacro()
4534

46-
message(STATUS "!!!")
47-
message(STATUS "!!! Using O2RecipeAdapter - this should be only temporary")
48-
message(STATUS "!!!")
49-
5035
if(ALICEO2_MODULAR_BUILD)
36+
37+
message(STATUS "!!!")
38+
message(STATUS "!!! Using O2RecipeAdapter - this should be only temporary")
39+
message(STATUS "!!!")
40+
5141
#
5242
# we use the presence of ALICEO2_MODULAR_BUILD as a signal that we are using
5343
# the old recipe and we assume Common_O2_ROOT is defined and can be used to
@@ -107,23 +97,3 @@ if(ALICEO2_MODULAR_BUILD)
10797
o2_show_env(PATH)
10898

10999
endif()
110-
111-
if(DEFINED ENV{ALIBUILD_O2_TESTS} AND PROJECT_NAME STREQUAL "O2")
112-
message(STATUS "!!!")
113-
message(
114-
STATUS
115-
"!!! ALIBUILD_O2_TESTS detected. Will patch my tests so they work off the install tree"
116-
)
117-
configure_file(${CMAKE_SOURCE_DIR}/tests/tmp-patch-tests-environment.sh.in
118-
tmp-patch-tests-environment.sh)
119-
install(
120-
CODE [[ execute_process(COMMAND bash tmp-patch-tests-environment.sh) ]])
121-
122-
install(CODE
123-
[[ execute_process(COMMAND ldd ${ROOT_rootcling_CMD}) ]])
124-
125-
install(CODE
126-
[[ execute_process(COMMAND otool -L ${ROOT_rootcling_CMD}) ]])
127-
endif()
128-
129-
message(STATUS "!!!")

dependencies/O2TestsAdapter.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
# We patch those tests that require some environment (most notably the O2_ROOT
12+
# variable) to convert from O2_ROOT pointing to build tree to O2_ROOT pointing
13+
# to install tree. Should not be needed in the long run if we consider (as we
14+
# should, I would argue) that tests are running off the build tree, before
15+
# installation (and are not installed, as there's probably no point in doing so)
16+
# Should not be needed in the long run if we consider (as we should, I would
17+
# argue) that tests are running off the build tree, before installation (and are
18+
# not installed, as there's probably no point in doing so)
19+
#
20+
21+
include_guard()
22+
23+
if(DEFINED ENV{ALIBUILD_O2_TESTS} AND PROJECT_NAME STREQUAL "O2")
24+
message(STATUS "!!!")
25+
message(
26+
STATUS
27+
"!!! ALIBUILD_O2_TESTS detected. Will patch my tests so they work off the install tree"
28+
)
29+
configure_file(${CMAKE_SOURCE_DIR}/tests/tmp-patch-tests-environment.sh.in
30+
tmp-patch-tests-environment.sh)
31+
install(
32+
CODE [[ execute_process(COMMAND bash tmp-patch-tests-environment.sh) ]])
33+
34+
install(CODE
35+
[[ execute_process(COMMAND ldd ${ROOT_rootcling_CMD}) ]])
36+
37+
install(CODE
38+
[[ execute_process(COMMAND otool -L ${ROOT_rootcling_CMD}) ]])
39+
endif()
40+

0 commit comments

Comments
 (0)