Skip to content

Commit 907e923

Browse files
authored
[gsl] use proper CMake target and move builtin-build to subdir
In particular: - use proper CMake target and move builtin-build to subdir - use proper CMake target for tmva
1 parent 2fed497 commit 907e923

6 files changed

Lines changed: 61 additions & 49 deletions

File tree

.github/workflows/root-ci-config/buildconfig/alma10-clang_ninja.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ builtin_freetype=ON
55
builtin_ftgl=ON
66
builtin_gif=ON
77
builtin_gl2ps=ON
8+
builtin_gsl=ON
89
builtin_jpeg=ON
910
builtin_lz4=ON
1011
builtin_lzma=ON

builtins/gsl/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
set(ROOT_GSL_VERSION 2.8)
2+
message(STATUS "Downloading and building GSL version ${ROOT_GSL_VERSION}")
3+
set(ROOT_GSL_PREFIX ${CMAKE_BINARY_DIR}/builtins/GSL-prefix)
4+
set(ROOT_GSL_LIBRARY ${ROOT_GSL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gsl${CMAKE_STATIC_LIBRARY_SUFFIX})
5+
set(ROOT_GSL_CBLAS_LIBRARY ${ROOT_GSL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX})
6+
set(ROOT_GSL_LIBRARIES ${ROOT_GSL_LIBRARY} ${ROOT_GSL_CBLAS_LIBRARY})
7+
if(CMAKE_OSX_SYSROOT)
8+
set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}")
9+
set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}")
10+
endif()
11+
ExternalProject_Add(
12+
BUILTIN_GSL
13+
PREFIX ${ROOT_GSL_PREFIX}
14+
# http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${ROOT_GSL_VERSION}.tar.gz
15+
URL ${lcgpackages}/gsl-${ROOT_GSL_VERSION}.tar.gz
16+
URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
17+
SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
18+
INSTALL_DIR ${ROOT_GSL_PREFIX}
19+
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR>
20+
--libdir=<INSTALL_DIR>/lib
21+
--enable-shared=no --with-pic
22+
CC=${CMAKE_C_COMPILER}
23+
CFLAGS=${CMAKE_C_FLAGS}
24+
CPPFLAGS=${_gsl_cppflags}
25+
LDFLAGS=${_gsl_ldflags}
26+
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
27+
BUILD_BYPRODUCTS ${ROOT_GSL_LIBRARIES}
28+
TIMEOUT 600
29+
)
30+
31+
# FIXME: one need to find better way to extract path with GSL include files
32+
set(ROOT_GSL_INCLUDE_DIR ${ROOT_GSL_PREFIX}/src/BUILTIN_GSL-build)
33+
34+
file(MAKE_DIRECTORY ${ROOT_GSL_INCLUDE_DIR})
35+
add_library(GSL::gsl IMPORTED STATIC GLOBAL)
36+
add_dependencies(GSL::gsl BUILTIN_GSL)
37+
set_target_properties(GSL::gsl PROPERTIES
38+
IMPORTED_LOCATION ${ROOT_GSL_LIBRARY}
39+
INTERFACE_INCLUDE_DIRECTORIES ${ROOT_GSL_INCLUDE_DIR})
40+
add_library(GSL::gslcblas IMPORTED STATIC GLOBAL)
41+
add_dependencies(GSL::gslcblas BUILTIN_GSL)
42+
set_target_properties(GSL::gslcblas PROPERTIES
43+
IMPORTED_LOCATION ${ROOT_GSL_CBLAS_LIBRARY}
44+
INTERFACE_INCLUDE_DIRECTORIES ${ROOT_GSL_INCLUDE_DIR})
45+
46+
set(GSL_INCLUDE_DIRS ${ROOT_GSL_INCLUDE_DIR} PARENT_SCOPE)
47+
set(GSL_FOUND ON PARENT_SCOPE)
48+
set(GSL_VERSION ${ROOT_GSL_VERSION} PARENT_SCOPE)
49+
set(GSL_LIBRARIES ${ROOT_GSL_LIBRARIES} PARENT_SCOPE)

cmake/modules/SearchInstalledSoftware.cmake

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,38 +1163,8 @@ if(mathmore OR builtin_gsl OR (tmva-cpu AND use_gsl_cblas))
11631163
endif()
11641164
endif()
11651165
else()
1166-
set(gsl_version 2.8)
1167-
message(STATUS "Downloading and building GSL version ${gsl_version}")
1168-
foreach(l gsl gslcblas)
1169-
list(APPEND GSL_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${l}${CMAKE_STATIC_LIBRARY_SUFFIX})
1170-
endforeach()
1171-
set(GSL_CBLAS_LIBRARY ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gslcblas${CMAKE_STATIC_LIBRARY_SUFFIX})
1172-
if(CMAKE_OSX_SYSROOT)
1173-
set(_gsl_cppflags "-isysroot ${CMAKE_OSX_SYSROOT}")
1174-
set(_gsl_ldflags "-isysroot ${CMAKE_OSX_SYSROOT}")
1175-
endif()
1176-
ExternalProject_Add(
1177-
GSL
1178-
# http://mirror.switch.ch/ftp/mirror/gnu/gsl/gsl-${gsl_version}.tar.gz
1179-
URL ${lcgpackages}/gsl-${gsl_version}.tar.gz
1180-
URL_HASH SHA256=6a99eeed15632c6354895b1dd542ed5a855c0f15d9ad1326c6fe2b2c9e423190
1181-
SOURCE_DIR GSL-src # prevent "<gsl/...>" vs GSL/ macOS warning
1182-
INSTALL_DIR ${CMAKE_BINARY_DIR}
1183-
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix <INSTALL_DIR>
1184-
--libdir=<INSTALL_DIR>/lib
1185-
--enable-shared=no --with-pic
1186-
CC=${CMAKE_C_COMPILER}
1187-
CFLAGS=${CMAKE_C_FLAGS}
1188-
CPPFLAGS=${_gsl_cppflags}
1189-
LDFLAGS=${_gsl_ldflags}
1190-
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
1191-
BUILD_BYPRODUCTS ${GSL_LIBRARIES}
1192-
TIMEOUT 600
1193-
)
1194-
set(GSL_TARGET GSL)
1195-
# FIXME: one need to find better way to extract path with GSL include files
1196-
set(GSL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/GSL-prefix/src/GSL-build)
1197-
set(GSL_FOUND ON)
1166+
list(APPEND ROOT_BUILTINS BUILTIN_GSL)
1167+
add_subdirectory(builtins/gsl)
11981168
set(mathmore ON CACHE BOOL "Enabled because builtin_gsl requested (${mathmore_description})" FORCE)
11991169
endif()
12001170
endif()
@@ -1206,16 +1176,14 @@ if(tmva-cpu)
12061176
add_library(ROOT::BLAS ALIAS Blas)
12071177
if (NOT use_gsl_cblas AND BLAS_FOUND)
12081178
target_link_libraries(Blas INTERFACE BLAS::BLAS)
1209-
elseif(use_gsl_cblas AND builtin_gsl)
1210-
message(STATUS "Using builtin GSL CBLAS for optional parts of TMVA")
1211-
add_dependencies(Blas GSL)
1212-
target_include_directories(Blas INTERFACE ${GSL_INCLUDE_DIR})
1213-
target_link_libraries(Blas INTERFACE ${GSL_CBLAS_LIBRARY})
1214-
target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS)
12151179
elseif(use_gsl_cblas AND GSL_FOUND)
1216-
message(STATUS "Using GSL CBLAS for optional parts of TMVA")
1217-
target_link_libraries(Blas INTERFACE GSL::gslcblas)
1180+
if (builtin_gsl)
1181+
message(STATUS "Using builtin GSL CBLAS for optional parts of TMVA")
1182+
else()
1183+
message(STATUS "Using system GSL CBLAS for optional parts of TMVA")
1184+
endif()
12181185
target_compile_definitions(Blas INTERFACE -DR__USE_CBLAS)
1186+
target_link_libraries(Blas INTERFACE GSL::gslcblas)
12191187
else()
12201188
if(fail-on-missing)
12211189
message(SEND_ERROR "tmva-cpu can't be built because BLAS was not found!")

math/mathmore/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ SOURCES
7979
Math/LinkDef.h
8080
DEPENDENCIES
8181
MathCore
82-
BUILTINS
83-
GSL
8482
)
8583

86-
target_include_directories(MathMore SYSTEM PRIVATE ${GSL_INCLUDE_DIR})
87-
target_link_libraries(MathMore PRIVATE ${GSL_LIBRARIES})
84+
target_link_libraries(MathMore PRIVATE GSL::gsl GSL::gslcblas)
8885

8986
ROOT_ADD_TEST_SUBDIRECTORY(test)

math/mathmore/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ add_definitions(-DHAVE_ROOTLIBS)
4545
#---Build and add all the defined test in the list---------------
4646
foreach(file ${TestMathMoreSource})
4747
get_filename_component(testname ${file} NAME_WE)
48-
ROOT_EXECUTABLE(${testname} ${file} LIBRARIES ${GSL_LIBRARIES} ${Libraries})
48+
ROOT_EXECUTABLE(${testname} ${file} LIBRARIES GSL::gsl GSL::gslcblas ${Libraries})
4949
ROOT_ADD_TEST(mathmore-${testname} COMMAND ${testname} LABELS ${${testname}_LABELS})
5050
endforeach()
5151

roofit/roofitmore/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitMore
5050
RIO
5151
MathCore
5252
Foam
53-
BUILTINS
54-
GSL
5553
${EXTRA_DICT_OPTS}
5654
)
5755

58-
target_include_directories(RooFitMore SYSTEM PRIVATE ${GSL_INCLUDE_DIR})
59-
target_link_libraries(RooFitMore PRIVATE ${GSL_LIBRARIES})
56+
target_link_libraries(RooFitMore PRIVATE GSL::gsl GSL::gslcblas)
6057

6158
# For recent clang, this can facilitate auto-vectorisation.
6259
# In RooFit, the errno side effect is not needed, anyway:

0 commit comments

Comments
 (0)