Skip to content

Commit 0540804

Browse files
committed
[cmake] download instead of bundle gl2ps and bump from 1.3.1 to 1.4.2, and use CMake target
[cmake] simplify dependency check matches 6.40 release notes [cmake] use canonical names [cmake] fix case [cmake] fix case and simplify check [graf3d] add dependency on builtin [cmake] simplify check [cmake] fix freetype builtins [cmake] fix deprecation error [gl2ps] do not depend on PNG or ZLIB since only EPS backend is used by ROOT graf3d plotter
1 parent 4aacb18 commit 0540804

File tree

6 files changed

+90
-6252
lines changed

6 files changed

+90
-6252
lines changed

builtins/gl2ps/CMakeLists.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (C) 1995-2026, Rene Brun and Fons Rademakers.
2+
# All rights reserved.
3+
#
4+
# For the licensing terms see $ROOTSYS/LICENSE.
5+
# For the list of contributors see $ROOTSYS/README/CREDITS.
6+
7+
# **PLEASE UPDATE ALSO THE FOLLOWING LINE WHEN UPDATING THE VERSION**
8+
# 30 Apr 2020, https://gitlab.onelab.info/gl2ps/gl2ps/-/releases/gl2ps_1_4_2
9+
set(ROOT_GL2PS_VERSION 1.4.2)
10+
set(ROOT_GL2PS_HASH "afb6f4a8df9c7639449546a79aabd1baaccacc4360fc23741c6485138512ff72")
11+
12+
set(ROOT_GL2PS_PREFIX ${CMAKE_BINARY_DIR}/builtins/GL2PS-prefix)
13+
14+
set(ROOT_GL2PS_LIBRARY ${ROOT_GL2PS_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gl2ps${CMAKE_STATIC_LIBRARY_SUFFIX}
15+
)
16+
17+
if(WIN32 AND NOT CMAKE_GENERATOR MATCHES Ninja)
18+
if(winrtdebug)
19+
set(ROOT_GL2PS_BUILD_COMMAND_FLAGS "--config Debug")
20+
else()
21+
set(ROOT_GL2PS_BUILD_COMMAND_FLAGS "--config $<IF:$<CONFIG:Debug,RelWithDebInfo>,RelWithDebInfo,Release>")
22+
endif()
23+
endif()
24+
25+
ExternalProject_Add(
26+
BUILTIN_GL2PS
27+
PREFIX ${ROOT_GL2PS_PREFIX}
28+
URL ${lcgpackages}/gl2ps-${ROOT_GL2PS_VERSION}.tar.gz
29+
URL_HASH SHA256=${ROOT_GL2PS_HASH}
30+
CMAKE_ARGS -G ${CMAKE_GENERATOR}
31+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
32+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
33+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
34+
-DCMAKE_C_VISIBILITY_PRESET=hidden
35+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
36+
-DENABLE_PNG=OFF
37+
-DENABLE_ZLIB=OFF
38+
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_GL2PS_BUILD_COMMAND_FLAGS}
39+
INSTALL_COMMAND ${CMAKE_COMMAND} --build . ${ROOT_GL2PS_BUILD_COMMAND_FLAGS} --target install
40+
LOG_CONFIGURE 1
41+
LOG_BUILD 1
42+
LOG_INSTALL 1
43+
LOG_OUTPUT_ON_FAILURE 1
44+
BUILD_BYPRODUCTS ${ROOT_GL2PS_LIBRARY}
45+
TIMEOUT 600)
46+
47+
file(MAKE_DIRECTORY ${ROOT_GL2PS_PREFIX}/include)
48+
add_library(gl2ps::gl2ps IMPORTED STATIC GLOBAL)
49+
set_target_properties(gl2ps::gl2ps PROPERTIES
50+
IMPORTED_LOCATION ${ROOT_GL2PS_LIBRARY}
51+
INTERFACE_INCLUDE_DIRECTORIES ${ROOT_GL2PS_PREFIX}/include)
52+
set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS gl2ps::gl2ps)
53+
54+
# Set the canonical output of find_package according to
55+
# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names
56+
set(gl2ps_INCLUDE_DIRS ${ROOT_GL2PS_PREFIX}/include PARENT_SCOPE)
57+
set(gl2ps_LIBRARIES ${ROOT_GL2PS_LIBRARY} PARENT_SCOPE)
58+
set(gl2ps_FOUND TRUE PARENT_SCOPE)
59+
set(gl2ps_VERSION ${ROOT_GL2PS_VERSION} PARENT_SCOPE)

cmake/modules/Findgl2ps.cmake

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@
77
# - Locate gl2ps library
88
# Defines:
99
#
10-
# GL2PS_FOUND
11-
# GL2PS_INCLUDE_DIR
12-
# GL2PS_INCLUDE_DIRS (not cached)
13-
# GL2PS_LIBRARIES
10+
# gl2ps_FOUND
11+
# gl2ps_INCLUDE_DIR
12+
# gl2ps_INCLUDE_DIRS (not cached)
13+
# gl2ps_LIBRARIES
1414

15-
find_path(GL2PS_INCLUDE_DIR NAMES gl2ps.h HINTS ${GL2PS_DIR}/include $ENV{GL2PS_DIR}/include /usr/include)
16-
find_library(GL2PS_LIBRARY NAMES gl2ps HINTS ${GL2PS_DIR}/lib $ENV{GL2PS_DIR}/lib)
15+
find_path(gl2ps_INCLUDE_DIR NAMES gl2ps.h HINTS ${gl2ps_DIR}/include $ENV{gl2ps_DIR}/include /usr/include)
16+
find_library(gl2ps_LIBRARY NAMES gl2ps HINTS ${gl2ps_DIR}/lib $ENV{gl2ps_DIR}/lib)
1717

18-
set(GL2PS_INCLUDE_DIRS ${GL2PS_INCLUDE_DIR})
19-
if(GL2PS_LIBRARY)
20-
set(GL2PS_LIBRARIES ${GL2PS_LIBRARY})
18+
set(gl2ps_INCLUDE_DIRS ${gl2ps_INCLUDE_DIR})
19+
if(gl2ps_LIBRARY)
20+
set(gl2ps_LIBRARIES ${gl2ps_LIBRARY})
2121
endif()
2222

2323

24-
# handle the QUIETLY and REQUIRED arguments and set GL2PS_FOUND to TRUE if
24+
# handle the QUIETLY and REQUIRED arguments and set gl2ps_FOUND to TRUE if
2525
# all listed variables are TRUE
2626
INCLUDE(FindPackageHandleStandardArgs)
27-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(gl2ps DEFAULT_MSG GL2PS_LIBRARY GL2PS_INCLUDE_DIR)
27+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(gl2ps DEFAULT_MSG gl2ps_LIBRARY gl2ps_INCLUDE_DIR)
2828

29-
mark_as_advanced(GL2PS_FOUND GL2PS_INCLUDE_DIR GL2PS_LIBRARY)
29+
mark_as_advanced(gl2ps_FOUND gl2ps_INCLUDE_DIR gl2ps_LIBRARY)
30+
31+
if(gl2ps_FOUND)
32+
if(NOT TARGET gl2ps::g2ps)
33+
add_library(gl2ps::gl2ps UNKNOWN IMPORTED)
34+
set_target_properties(gl2ps::gl2ps PROPERTIES
35+
IMPORTED_LOCATION "${gl2ps_LIBRARY}"
36+
INTERFACE_INCLUDE_DIRECTORIES "${gl2ps_INCLUDE_DIR}")
37+
endif()
38+
endif()

cmake/modules/SearchInstalledSoftware.cmake

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ if(NOT builtin_freetype)
260260
endif()
261261

262262
if(builtin_freetype)
263-
list(APPEND ROOT_BUILTINS FREETYPE)
263+
list(APPEND ROOT_BUILTINS BUILTIN_FREETYPE)
264264
add_subdirectory(builtins/freetype)
265265
endif()
266266

@@ -567,16 +567,11 @@ if(opengl AND NOT asimage)
567567
endif()
568568

569569
#---Check for gl2ps ------------------------------------------------------------------
570-
if(opengl AND NOT builtin_gl2ps)
571-
message(STATUS "Looking for gl2ps")
572-
if(fail-on-missing)
573-
find_Package(gl2ps REQUIRED)
574-
else()
575-
find_Package(gl2ps)
576-
if(NOT GL2PS_FOUND)
577-
message(STATUS "gl2ps not found. Switching on builtin_gl2ps option")
578-
set(builtin_gl2ps ON CACHE BOOL "Enabled because opengl requested and gl2ps not found (${builtin_gl2ps_description})" FORCE)
579-
endif()
570+
if(opengl)
571+
ROOT_FIND_REQUIRED_DEP(gl2ps builtin_gl2ps)
572+
if (builtin_gl2ps)
573+
add_subdirectory(builtins/gl2ps)
574+
list(APPEND ROOT_BUILTINS BUILTIN_GL2PS)
580575
endif()
581576
endif()
582577

graf3d/gl/CMakeLists.txt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ if(x11)
1717
set(RGL_EXTRA_SOURCES TX11GL.cxx)
1818
endif()
1919

20-
21-
if(builtin_gl2ps)
22-
set(RGL_EXTRA_SOURCES ${RGL_EXTRA_SOURCES} src/gl2ps.cxx)
23-
endif()
24-
2520
set_source_files_properties(src/TGLFontManager.cxx PROPERTIES COMPILE_FLAGS "${FTGL_CFLAGS}")
2621
set_source_files_properties(src/TGLText.cxx PROPERTIES COMPILE_FLAGS "${FTGL_CFLAGS}")
2722

@@ -208,7 +203,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RGL
208203
OpenGL::GL
209204
OpenGL::GLU
210205
${FTGL_LIBRARIES}
211-
${GL2PS_LIBRARIES}
206+
gl2ps::gl2ps
212207
Freetype::Freetype
213208
ZLIB::ZLIB
214209
${X11_LIBRARIES}
@@ -219,21 +214,18 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RGL
219214
Ged
220215
RCsg
221216
ASImage
217+
BUILTINS
218+
BUILTIN_GL2PS
222219
INSTALL_OPTIONS
223220
${installoptions}
224221
)
225222

223+
226224
target_include_directories(RGL PRIVATE
227225
${OPENGL_INCLUDE_DIR}
228226
${FTGL_INCLUDE_DIR}
229227
)
230228

231-
if(builtin_gl2ps)
232-
target_include_directories(RGL PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/gl2ps)
233-
else()
234-
target_include_directories(RGL PRIVATE ${GL2PS_INCLUDE_DIRS})
235-
endif()
236-
237229
if(MACOSX_GLU_DEPRECATED)
238230
target_compile_options(RGL PRIVATE -Wno-deprecated-declarations)
239231
endif()

0 commit comments

Comments
 (0)