diff --git a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt index f570304443ab1..8775a9a2c65f7 100644 --- a/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt +++ b/.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt @@ -5,6 +5,7 @@ builtin_freetype=ON builtin_ftgl=ON builtin_gif=ON builtin_gl2ps=ON +builtin_gsl=ON builtin_jpeg=ON builtin_lz4=ON builtin_lzma=ON diff --git a/builtins/gsl/CMakeLists.txt b/builtins/gsl/CMakeLists.txt new file mode 100644 index 0000000000000..62e903186381c --- /dev/null +++ b/builtins/gsl/CMakeLists.txt @@ -0,0 +1,49 @@ +set(ROOT_GSL_VERSION 2.8) +message(STATUS "Downloading and building GSL version ${ROOT_GSL_VERSION}") +set(ROOT_GSL_PREFIX ${CMAKE_BINARY_DIR}/builtins/GSL-prefix) +set(ROOT_GSL_LIBRARY ${ROOT_GSL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gsl${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(ROOT_GSL_CBLAS_LIBRARY ${ROOT_GSL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX}) +set(ROOT_GSL_LIBRARIES ${ROOT_GSL_LIBRARY} ${ROOT_GSL_CBLAS_LIBRARY}) +if(CMAKE_OSX_SYSROOT) + set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}") + set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}") +endif() +ExternalProject_Add( + BUILTIN_GSL + PREFIX ${ROOT_GSL_PREFIX} + # http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${ROOT_GSL_VERSION}.tar.gz + URL ${lcgpackages}/gsl-${ROOT_GSL_VERSION}.tar.gz + URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190 + SOURCE_DIR GSL-src # prevent "" vs GSL/ macOS warning + INSTALL_DIR ${ROOT_GSL_PREFIX} + CONFIGURE_COMMAND /configure --prefix + --libdir=/lib + --enable-shared=no --with-pic + CC=${CMAKE_C_COMPILER} + CFLAGS=${CMAKE_C_FLAGS} + CPPFLAGS=${_gsl_cppflags} + LDFLAGS=${_gsl_ldflags} + LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 + BUILD_BYPRODUCTS ${ROOT_GSL_LIBRARIES} + TIMEOUT 600 +) + +# FIXME: one need to find better way to extract path with GSL include files +set(ROOT_GSL_INCLUDE_DIR ${ROOT_GSL_PREFIX}/src/BUILTIN_GSL-build) + +file(MAKE_DIRECTORY ${ROOT_GSL_INCLUDE_DIR}) +add_library(GSL::gsl IMPORTED STATIC GLOBAL) +add_dependencies(GSL::gsl BUILTIN_GSL) +set_target_properties(GSL::gsl PROPERTIES + IMPORTED_LOCATION ${ROOT_GSL_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_GSL_INCLUDE_DIR}) +add_library(GSL::gslcblas IMPORTED STATIC GLOBAL) +add_dependencies(GSL::gslcblas BUILTIN_GSL) +set_target_properties(GSL::gslcblas PROPERTIES + IMPORTED_LOCATION ${ROOT_GSL_CBLAS_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_GSL_INCLUDE_DIR}) + +set(GSL_INCLUDE_DIRS ${ROOT_GSL_INCLUDE_DIR} PARENT_SCOPE) +set(GSL_FOUND ON PARENT_SCOPE) +set(GSL_VERSION ${ROOT_GSL_VERSION} PARENT_SCOPE) +set(GSL_LIBRARIES ${ROOT_GSL_LIBRARIES} PARENT_SCOPE) diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index fb3ba29c6804a..253a736513265 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -1229,38 +1229,8 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas)) endif() endif() else() - set(gsl_version 2.8) - message(STATUS "Downloading and building GSL version ${gsl_version}") - foreach(l gsl gslcblas) - list(APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${l}${CMAKE_STATIC_LIBRARY_SUFFIX}) - endforeach() - set(GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX}) - if(CMAKE_OSX_SYSROOT) - set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}") - set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}") - endif() - ExternalProject_Add( - GSL - # http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz - URL ${lcgpackages}/gsl-${gsl_version}.tar.gz - URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190 - SOURCE_DIR GSL-src # prevent "" vs GSL/ macOS warning - INSTALL_DIR ${CMAKE_BINARY_DIR} - CONFIGURE_COMMAND /configure --prefix - --libdir=/lib - --enable-shared=no --with-pic - CC=${CMAKE_C_COMPILER} - CFLAGS=${CMAKE_C_FLAGS} - CPPFLAGS=${_gsl_cppflags} - LDFLAGS=${_gsl_ldflags} - LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1 - BUILD_BYPRODUCTS ${GSL_LIBRARIES} - TIMEOUT 600 - ) - set(GSL_TARGET GSL) - # FIXME: one need to find better way to extract path with GSL include files - set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build) - set(GSL_FOUND ON) + list(APPEND ROOT_BUILTINS BUILTIN_GSL) + add_subdirectory(builtins/gsl) set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})" FORCE) endif() endif() @@ -1272,16 +1242,14 @@ if(tmva-cpu) add_library(ROOT::BLAS ALIAS Blas) if (NOT use_gsl_cblas AND BLAS_FOUND) target_link_libraries(Blas INTERFACE BLAS::BLAS) - elseif(use_gsl_cblas AND builtin_gsl) - message(STATUS "Using builtin GSL CBLAS for optional parts of TMVA") - add_dependencies(Blas GSL) - target_include_directories(Blas INTERFACE ${GSL_INCLUDE_DIR}) - target_link_libraries(Blas INTERFACE ${GSL_CBLAS_LIBRARY}) - target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS) elseif(use_gsl_cblas AND GSL_FOUND) - message(STATUS "Using GSL CBLAS for optional parts of TMVA") - target_link_libraries(Blas INTERFACE GSL::gslcblas) + if (builtin_gsl) + message(STATUS "Using builtin GSL CBLAS for optional parts of TMVA") + else() + message(STATUS "Using system GSL CBLAS for optional parts of TMVA") + endif() target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS) + target_link_libraries(Blas INTERFACE GSL::gslcblas) else() if(fail-on-missing) message(SEND_ERROR "tmva-cpu can't be built because BLAS was not found!") diff --git a/math/mathmore/CMakeLists.txt b/math/mathmore/CMakeLists.txt index 4356e02e6f091..d33bde74ffe96 100644 --- a/math/mathmore/CMakeLists.txt +++ b/math/mathmore/CMakeLists.txt @@ -79,11 +79,8 @@ SOURCES Math/LinkDef.h DEPENDENCIES MathCore - BUILTINS - GSL ) -target_include_directories(MathMore SYSTEM PRIVATE ${GSL_INCLUDE_DIR}) -target_link_libraries(MathMore PRIVATE ${GSL_LIBRARIES}) +target_link_libraries(MathMore PRIVATE GSL::gsl GSL::gslcblas) ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/math/mathmore/test/CMakeLists.txt b/math/mathmore/test/CMakeLists.txt index e4409aeb7f146..5360074515ab5 100644 --- a/math/mathmore/test/CMakeLists.txt +++ b/math/mathmore/test/CMakeLists.txt @@ -45,7 +45,7 @@ add_definitions(-DHAVE_ROOTLIBS) #---Build and add all the defined test in the list--------------- foreach(file ${TestMathMoreSource}) get_filename_component(testname ${file} NAME_WE) - ROOT_EXECUTABLE(${testname} ${file} LIBRARIES ${GSL_LIBRARIES} ${Libraries}) + ROOT_EXECUTABLE(${testname} ${file} LIBRARIES GSL::gsl GSL::gslcblas ${Libraries}) ROOT_ADD_TEST(mathmore-${testname} COMMAND ${testname} LABELS ${${testname}_LABELS}) endforeach() diff --git a/roofit/roofitmore/CMakeLists.txt b/roofit/roofitmore/CMakeLists.txt index 561d55382309f..1130797b255b0 100644 --- a/roofit/roofitmore/CMakeLists.txt +++ b/roofit/roofitmore/CMakeLists.txt @@ -50,13 +50,10 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitMore RIO MathCore Foam - BUILTINS - GSL ${EXTRA_DICT_OPTS} ) -target_include_directories(RooFitMore SYSTEM PRIVATE ${GSL_INCLUDE_DIR}) -target_link_libraries(RooFitMore PRIVATE ${GSL_LIBRARIES}) +target_link_libraries(RooFitMore PRIVATE GSL::gsl GSL::gslcblas) # For recent clang, this can facilitate auto-vectorisation. # In RooFit, the errno side effect is not needed, anyway: