Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmake/modules/FairRootTargetRootDictionary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,19 @@ function(fairroot_target_root_dictionary target)
# add a custom command to generate the dictionary using rootcling
# cmake-format: off
set(space " ")

if (APPLE AND CMAKE_OSX_SYSROOT)
set(_sysroot_arg "SDKROOT=${CMAKE_OSX_SYSROOT}")
else()
set(_sysroot_arg)
endif()

add_custom_command(
OUTPUT ${dictionaryFile} ${pcmFile} ${rootmapFile}
VERBATIM
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}"
COMMAND ${CMAKE_COMMAND} -E env
"LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}"
${_sysroot_arg}
$<TARGET_FILE:ROOT::rootcling>
-f ${dictionaryFile}
-inlineInputHeader
Expand Down
4 changes: 4 additions & 0 deletions cmake/scripts/generate_dictionary_root.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@

if [[ -n "@CMAKE_OSX_SYSROOT@" ]]; then
export SDKROOT=@CMAKE_OSX_SYSROOT@
fi

@ROOT_CINT_EXECUTABLE@ -f @Int_DICTIONARY@ @EXTRA_DICT_PARAMETERS_STR@ -c @Int_DEF_STR@ @Int_INC_STR@ @Int_HDRS_STR@ @Int_LINKDEF@
49 changes: 19 additions & 30 deletions templates/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_project_root_containers.sh.in
${CMAKE_CURRENT_BINARY_DIR}/test_project_root_containers.sh
@ONLY)
add_test(NAME project_root_containers
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project_root_containers.sh)
set_tests_properties(project_root_containers PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)
add_test(NAME project_root_containers_double
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project_root_containers.sh --double-configure)
set_tests_properties(project_root_containers_double PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_project.sh.in
${CMAKE_CURRENT_BINARY_DIR}/test_project.sh
@ONLY
USE_SOURCE_PERMISSIONS)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_project_stl_containers.sh.in
${CMAKE_CURRENT_BINARY_DIR}/test_project_stl_containers.sh
@ONLY)
add_test(NAME project_stl_containers
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project_stl_containers.sh)
set_tests_properties(project_stl_containers PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)
add_test(NAME project_stl_containers_double
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project_stl_containers.sh --double-configure)
set_tests_properties(project_stl_containers_double PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)
foreach(container_type IN ITEMS root stl)
add_test(NAME project_${container_type}_containers
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project.sh ${container_type})
set_tests_properties(project_${container_type}_containers PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)

add_test(NAME project_${container_type}_containers_double
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_project.sh ${container_type} --double-configure)
set_tests_properties(project_${container_type}_containers_double PROPERTIES
TIMEOUT "300"
PASS_REGULAR_EXPRESSION "Test successful."
)
endforeach()
87 changes: 87 additions & 0 deletions templates/test_project.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -e -u -o pipefail
[[ "${DEBUG:-0}" == "1" ]] && set -x

usage() {
echo "Usage: $0 <container_type> [--double-configure]" >&2
echo " container_type: 'root' or 'stl'" >&2
exit 1
}

# Parse arguments
CONTAINER_TYPE=""
DOUBLE_CONFIGURE=0

while [[ $# -gt 0 ]]; do
case $1 in
--double-configure)
DOUBLE_CONFIGURE=1
shift
;;
root|stl)
if [[ -n "$CONTAINER_TYPE" ]]; then
echo "Error: container_type specified multiple times" >&2
usage
fi
CONTAINER_TYPE=$1
shift
;;
-h|--help)
usage
;;
*)
echo "Error: Unknown argument '$1'" >&2
usage
;;
esac
done

if [[ -z "$CONTAINER_TYPE" ]]; then
echo "Error: container_type is required" >&2
usage
fi

readonly CONTAINER_TYPE
readonly DOUBLE_CONFIGURE

readonly CURRENT_DIR=$(pwd)
readonly SOURCE_DIR=@CMAKE_SOURCE_DIR@
readonly MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')

# Ensure cleanup on exit
trap 'cd "$CURRENT_DIR" && rm -rf "$MYTMPDIR"' EXIT

readonly TEMPLATE_DIR="$SOURCE_DIR/templates/project_${CONTAINER_TYPE}_containers"
if [[ ! -d "$TEMPLATE_DIR" ]]; then
echo "Error: Template directory not found: $TEMPLATE_DIR" >&2
exit 1
fi

cd "$MYTMPDIR"
cp -RP "$TEMPLATE_DIR" .
cd "project_${CONTAINER_TYPE}_containers"
./rename.sh TestProj Tst det

export SIMPATH=@SIMPATH@
export FAIRROOTPATH=@CMAKE_INSTALL_PREFIX@

# Use array for proper argument handling
parameters=(-DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@)

if [[ -n "@CMAKE_OSX_SYSROOT@" ]]; then
parameters+=(-DCMAKE_OSX_SYSROOT=@CMAKE_OSX_SYSROOT@)
fi

cmake -S . -B build "${parameters[@]}"

if [[ "$DOUBLE_CONFIGURE" == "1" ]]; then
echo "*** Calling cmake configure again:"
# Check if all the cache variables
# are good for a reconfiguration step
cmake -S . -B build
fi

cmake --build build

echo "Test successful."
35 changes: 0 additions & 35 deletions templates/test_project_root_containers.sh.in

This file was deleted.

35 changes: 0 additions & 35 deletions templates/test_project_stl_containers.sh.in

This file was deleted.