@@ -398,62 +398,6 @@ if(asimage)
398398 endif ()
399399endif ()
400400
401- #---Check for GSL library---------------------------------------------------------------
402- if (mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas))
403- if (builtin_gsl)
404- ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION ("builtin_gsl" )
405- endif ()
406- message (STATUS "Looking for GSL" )
407- if (NOT builtin_gsl)
408- find_package (GSL 1.10 )
409- if (NOT GSL_FOUND)
410- if (fail-on -missing)
411- message (SEND_ERROR "GSL package not found and 'mathmore' component if required ('fail-on-missing' enabled). "
412- "Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally." )
413- else ()
414- message (STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation" )
415- message (STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'" )
416- message (STATUS " For the time being switching OFF 'mathmore' option" )
417- set (mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description} )" FORCE )
418- endif ()
419- endif ()
420- else ()
421- set (gsl_version 2.8)
422- message (STATUS "Downloading and building GSL version ${gsl_version} " )
423- foreach (l gsl gslcblas)
424- list (APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR } /lib/${CMAKE_STATIC_LIBRARY_PREFIX }${l}${CMAKE_STATIC_LIBRARY_SUFFIX } )
425- endforeach ()
426- set (GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR } /lib/${CMAKE_STATIC_LIBRARY_PREFIX } gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX } )
427- if (CMAKE_OSX_SYSROOT)
428- set (_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT} " )
429- set (_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT} " )
430- endif ()
431- ExternalProject_Add (
432- GSL
433- # http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
434- URL ${lcgpackages} /gsl-${gsl_version} .tar.gz
435- URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
436- SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
437- INSTALL_DIR ${CMAKE_BINARY_DIR }
438- CONFIGURE_COMMAND <SOURCE_DIR >/configure --prefix <INSTALL_DIR >
439- --libdir=<INSTALL_DIR >/lib
440- --enable-shared=no --with-pic
441- CC=${CMAKE_C_COMPILER }
442- CFLAGS=${CMAKE_C_FLAGS }
443- CPPFLAGS=${_gsl_cppflags}
444- LDFLAGS=${_gsl_ldflags}
445- LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
446- BUILD_BYPRODUCTS ${GSL_LIBRARIES}
447- TIMEOUT 600
448- )
449- set (GSL_TARGET GSL)
450- # FIXME: one need to find better way to extract path with GSL include files
451- set (GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR } /GSL-prefix/src/GSL-build)
452- set (GSL_FOUND ON )
453- set (mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description} )" FORCE )
454- endif ()
455- endif ()
456-
457401#---Check for Python installation-------------------------------------------------------
458402
459403message (STATUS "Looking for Python" )
@@ -1265,42 +1209,120 @@ if(tmva-sofie)
12651209 endif ()
12661210endif ()
12671211
1268- #---TMVA and its dependencies------------------------------------------------------------
1269- if (tmva)
1270- if (tmva-cpu AND imt)
1271- message (STATUS "Looking for BLAS for optional parts of TMVA" )
1272- # ROOT internal BLAS target
1273- add_library (Blas INTERFACE )
1274- add_library (ROOT::BLAS ALIAS Blas )
1275- if (use_gsl_cblas)
1276- message (STATUS "Using GSL CBLAS for optional parts of TMVA" )
1277- if (builtin_gsl)
1278- add_dependencies (Blas GSL )
1279- target_include_directories (Blas INTERFACE ${GSL_INCLUDE_DIR} )
1280- target_link_libraries (Blas INTERFACE ${GSL_CBLAS_LIBRARY} )
1212+ #---Figure out if TMVA CPU should be built and which BLAS we will use ------------------
1213+ if (tmva-cpu)
1214+ if (NOT tmva)
1215+ set (tmva-cpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-cpu_description} )" FORCE )
1216+ elseif (NOT imt)
1217+ set (tmva-cpu OFF CACHE BOOL "Disabled because 'imt' is disabled (${tmva-cpu_description} )" FORCE )
1218+ endif ()
1219+ endif ()
1220+ if (tmva-cpu)
1221+ if (NOT use_gsl_cblas)
1222+ find_package (BLAS )
1223+ if (NOT BLAS_FOUND)
1224+ # If no optimized BLAS library was found, we fall back to attempting to
1225+ # use the GSL CBLAS. If ROOT is built with fail-on-missing=ON, this
1226+ # usually means that the user does not want us to change build flags
1227+ # automatically, so we send an error.
1228+ if (fail-on -missing)
1229+ message (SEND_ERROR "Option tmva-cpu requires a BLAS library, but none could be found on the system. Either install a BLAS library like OpenBLAS (preferred), or set use_gsl_cblas=ON (possibly also builtin_gsl=ON if GSL not installed on the system)." )
12811230 else ()
1282- if (GSL_FOUND)
1283- target_link_libraries (Blas INTERFACE GSL::gslcblas )
1284- endif ()
1285- endif ()
1286- target_compile_definitions (Blas INTERFACE -DR__USE_CBLAS )
1287- else ()
1288- find_package (BLAS )
1289- if (BLAS_FOUND)
1290- target_link_libraries (Blas INTERFACE BLAS::BLAS )
1231+ set (use_gsl_cblas ON CACHE BOOL "Auto-enabling GSL CBLAS for TMVA [GPL]" FORCE )
12911232 endif ()
12921233 endif ()
1293- if (NOT BLAS_FOUND AND NOT GSL_FOUND)
1234+ endif ()
1235+ endif ()
1236+
1237+ #---Check for GSL library---------------------------------------------------------------
1238+ if (mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas))
1239+ if (builtin_gsl)
1240+ ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION ("builtin_gsl" )
1241+ endif ()
1242+ message (STATUS "Looking for GSL" )
1243+ if (NOT builtin_gsl)
1244+ find_package (GSL 1.10 )
1245+ if (NOT GSL_FOUND)
12941246 if (fail-on -missing)
1295- message (SEND_ERROR "tmva-cpu can't be built because BLAS was not found!" )
1247+ message (SEND_ERROR "GSL package not found and 'mathmore' component is required ('fail-on-missing' enabled). "
1248+ "Alternatively, you can enable the option 'builtin_gsl' to build the GSL libraries internally." )
12961249 else ()
1297- message (STATUS "tmva-cpu disabled because BLAS was not found" )
1298- set (tmva-cpu OFF CACHE BOOL "Disabled because BLAS was not found (${tmva-cpu_description} )" FORCE )
1250+ message (STATUS "GSL not found. Set variable GSL_ROOT_DIR to point to your GSL installation" )
1251+ message (STATUS " Alternatively, you can also enable the option 'builtin_gsl' to build the GSL libraries internally'" )
1252+ if (mathmore)
1253+ message (STATUS " For the time being switching OFF 'mathmore' option" )
1254+ set (mathmore OFF CACHE BOOL "Disable because builtin_gsl disabled and external GSL not found (${mathmore_description} )" FORCE )
1255+ endif ()
1256+ if (tmva-cpu AND use_gsl_cblas)
1257+ message (STATUS " For the time being switching OFF 'tmva-cpu' option" )
1258+ set (tmva-cpu OFF CACHE BOOL "Disable because use_gsl_cblas enabled, builtin_gsl disabled and external GSL not found (${tmva-cpu_description} )" FORCE )
1259+ endif ()
12991260 endif ()
13001261 endif ()
13011262 else ()
1302- set (tmva-cpu OFF CACHE BOOL "Disabled because 'imt' is disabled (${tmva-cpu_description} )" FORCE )
1263+ set (gsl_version 2.8)
1264+ message (STATUS "Downloading and building GSL version ${gsl_version} " )
1265+ foreach (l gsl gslcblas)
1266+ list (APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR } /lib/${CMAKE_STATIC_LIBRARY_PREFIX }${l}${CMAKE_STATIC_LIBRARY_SUFFIX } )
1267+ endforeach ()
1268+ set (GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR } /lib/${CMAKE_STATIC_LIBRARY_PREFIX } gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX } )
1269+ if (CMAKE_OSX_SYSROOT)
1270+ set (_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT} " )
1271+ set (_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT} " )
1272+ endif ()
1273+ ExternalProject_Add (
1274+ GSL
1275+ # http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
1276+ URL ${lcgpackages} /gsl-${gsl_version} .tar.gz
1277+ URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
1278+ SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
1279+ INSTALL_DIR ${CMAKE_BINARY_DIR }
1280+ CONFIGURE_COMMAND <SOURCE_DIR >/configure --prefix <INSTALL_DIR >
1281+ --libdir=<INSTALL_DIR >/lib
1282+ --enable-shared=no --with-pic
1283+ CC=${CMAKE_C_COMPILER }
1284+ CFLAGS=${CMAKE_C_FLAGS }
1285+ CPPFLAGS=${_gsl_cppflags}
1286+ LDFLAGS=${_gsl_ldflags}
1287+ LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
1288+ BUILD_BYPRODUCTS ${GSL_LIBRARIES}
1289+ TIMEOUT 600
1290+ )
1291+ set (GSL_TARGET GSL)
1292+ # FIXME: one need to find better way to extract path with GSL include files
1293+ set (GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR } /GSL-prefix/src/GSL-build)
1294+ set (GSL_FOUND ON )
1295+ set (mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description} )" FORCE )
13031296 endif ()
1297+ endif ()
1298+
1299+ #---TMVA and its dependencies------------------------------------------------------------
1300+ if (tmva-cpu)
1301+ # ROOT internal BLAS target for TMVA
1302+ add_library (Blas INTERFACE )
1303+ add_library (ROOT::BLAS ALIAS Blas )
1304+ if (NOT use_gsl_cblas AND BLAS_FOUND)
1305+ target_link_libraries (Blas INTERFACE BLAS::BLAS )
1306+ elseif (use_gsl_cblas AND builtin_gsl)
1307+ message (STATUS "Using builtin GSL CBLAS for optional parts of TMVA" )
1308+ add_dependencies (Blas GSL )
1309+ target_include_directories (Blas INTERFACE ${GSL_INCLUDE_DIR} )
1310+ target_link_libraries (Blas INTERFACE ${GSL_CBLAS_LIBRARY} )
1311+ target_compile_definitions (Blas INTERFACE -DR__USE_CBLAS )
1312+ elseif (use_gsl_cblas AND GSL_FOUND)
1313+ message (STATUS "Using GSL CBLAS for optional parts of TMVA" )
1314+ target_link_libraries (Blas INTERFACE GSL::gslcblas )
1315+ target_compile_definitions (Blas INTERFACE -DR__USE_CBLAS )
1316+ else ()
1317+ if (fail-on -missing)
1318+ message (SEND_ERROR "tmva-cpu can't be built because BLAS was not found!" )
1319+ else ()
1320+ message (STATUS "tmva-cpu disabled because BLAS was not found" )
1321+ set (tmva-cpu OFF CACHE BOOL "Disabled because BLAS was not found (${tmva-cpu_description} )" FORCE )
1322+ endif ()
1323+ endif ()
1324+ endif ()
1325+ if (tmva)
13041326 if (tmva-gpu AND NOT CMAKE_CUDA_COMPILER)
13051327 set (tmva-gpu OFF CACHE BOOL "Disabled because cuda not found" FORCE )
13061328 endif ()
@@ -1346,7 +1368,6 @@ if(tmva)
13461368 set (tmva-rmva OFF CACHE BOOL "Disabled because R was not found (${tmva-rmva_description} )" FORCE )
13471369 endif ()
13481370else ()
1349- set (tmva-cpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-cpu_description} )" FORCE )
13501371 set (tmva-gpu OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-gpu_description} )" FORCE )
13511372 set (tmva-cudnn OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-rmva_description} )" FORCE )
13521373 set (tmva-pymva OFF CACHE BOOL "Disabled because 'tmva' is disabled (${tmva-pymva_description} )" FORCE )
0 commit comments