From d0e11daa4c20e492a0b595a7dac442b4b7f0bfb4 Mon Sep 17 00:00:00 2001 From: Vindaar Date: Mon, 14 Feb 2022 12:08:33 +0100 Subject: [PATCH 1/3] clean up cmake formatting --- cmake/FindROOT.cmake | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index 6855cb6f2..de06ef3cf 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -1,15 +1,15 @@ # - Finds ROOT instalation -# This module sets up ROOT information +# This module sets up ROOT information # It defines: # ROOT_FOUND If the ROOT is found # ROOT_INCLUDE_DIR PATH to the include directory (deprecated) # ROOT_INCLUDE_DIRS PATH to the include directory # ROOT_LIBRARIES Most common libraries -# ROOT_LIBRARY_DIR PATH to the library directory +# ROOT_LIBRARY_DIR PATH to the library directory # ROOT_BIN_DIR PATH to the excutables directory # ROOT_PYTHONVER Compatible python version string -# First search for ROOTConfig.cmake on the path defined via user setting +# First search for ROOTConfig.cmake on the path defined via user setting # ROOT_DIR if (CMAKE_SYSTEM_NAME MATCHES "Windows") @@ -19,7 +19,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") endif() if(NOT ROOTSYS) - set(ROOT_FOUND FALSE) + set(ROOT_FOUND FALSE) else() set(ROOT_FOUND TRUE) @@ -27,17 +27,17 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") set(ROOT_INCLUDE_DIRS ${ROOTSYS}/include) set(ROOT_BIN_DIR ${ROOTSYS}/bin) set(ROOTCINT_EXECUTABLE ${ROOTSYS}/bin/rootcint.exe) - set(GENREFLEX_EXECUTABLE ${ROOTSYS}/bin/genreflex.exe) + set(GENREFLEX_EXECUTABLE ${ROOTSYS}/bin/genreflex.exe) set(CMAKE_FIND_LIBRARY_PREFIXES "lib") set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") set(ROOT_LIBRARIES) foreach(_cpt Core Imt RIO Net Hist Gui Eve RGL Gdml Geom Graf Graf3d Gpad Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread MultiProc Minuit) find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) - if(ROOT_${_cpt}_LIBRARY) - mark_as_advanced(ROOT_${_cpt}_LIBRARY) - list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) - endif() + if(ROOT_${_cpt}_LIBRARY) + mark_as_advanced(ROOT_${_cpt}_LIBRARY) + list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) + endif() endforeach() if(ROOT_LIBRARIES) list(REMOVE_DUPLICATES ROOT_LIBRARIES) @@ -51,17 +51,16 @@ else() if(NOT ROOT_CONFIG_EXECUTABLE) set(ROOT_FOUND FALSE) - else() + else() set(ROOT_FOUND TRUE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir OUTPUT_VARIABLE ROOT_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir OUTPUT_VARIABLE ROOT_LIBRARY_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -70,7 +69,7 @@ else() set(GENREFLEX_EXECUTABLE $ENV{ROOTSYS}/bin/genreflex) execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --version + COMMAND ${ROOT_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -84,15 +83,16 @@ else() OUTPUT_VARIABLE ROOT_BIN_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) - # Make variables changeble to the advanced user + + # Make variables changeble to the advanced user mark_as_advanced(ROOT_CONFIG_EXECUTABLE) endif() endif() if (NOT ROOT_FOUND) - message(FATAL_ERROR "ROOT required, but not found") + message(FATAL_ERROR "ROOT required, but not found") else() - message(STATUS "Find ROOT ${ROOT_VERSION} in ${ROOT_BIN_DIR}") + message(STATUS "Find ROOT ${ROOT_VERSION} in ${ROOT_BIN_DIR}") endif() From 071f2af50c162060c020e215109108385919179a Mon Sep 17 00:00:00 2001 From: Vindaar Date: Mon, 14 Feb 2022 12:08:55 +0100 Subject: [PATCH 2/3] [Windows] error if $ROOTSYS environment variable undefined --- cmake/FindROOT.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index de06ef3cf..e5ae6da71 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -15,7 +15,9 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows") if(DEFINED ENV{ROOTSYS}) - set(ROOTSYS $ENV{ROOTSYS}) + set(ROOTSYS $ENV{ROOTSYS}) + else() + message(FATAL_ERROR "ROOTSYS environment variable is undefined. Did you forget to source the `thisroot.bat`?") endif() if(NOT ROOTSYS) From b7bcef5d19a6b0bf4e8686f03770a596d6044f67 Mon Sep 17 00:00:00 2001 From: Vindaar Date: Mon, 14 Feb 2022 12:09:11 +0100 Subject: [PATCH 3/3] [unix] do not use $ROOTSYS, use `root-config --bindir` Arguably one might want to error out same as for windows here. But given that `root-config` is enough to identify the bin directory of root, in theory it's enough for our purposes. Without the definition of `ROOTSYS` (i.e. `thisroot` wasn't sourced), hard to debug errors appear for people unfamiliar with ROOT & CMAKE --- cmake/FindROOT.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index e5ae6da71..69c0a9bf3 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -66,10 +66,6 @@ else() OUTPUT_VARIABLE ROOT_LIBRARY_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) - - set(ROOTCINT_EXECUTABLE $ENV{ROOTSYS}/bin/rootcint) - set(GENREFLEX_EXECUTABLE $ENV{ROOTSYS}/bin/genreflex) - execute_process( COMMAND ${ROOT_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE ROOT_VERSION @@ -85,6 +81,8 @@ else() OUTPUT_VARIABLE ROOT_BIN_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ROOTCINT_EXECUTABLE ${ROOT_BIN_DIR}/rootcint) + set(GENREFLEX_EXECUTABLE ${ROOT_BIN_DIR}/genreflex) # Make variables changeble to the advanced user mark_as_advanced(ROOT_CONFIG_EXECUTABLE)