Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions builtins/freetype/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(FREETYPE_HASH "e61b31ab26358b946e767ed7eb7f4bb2e507da1cfefeb7a8861ace7fd5c89

set(FREETYPE_PREFIX ${CMAKE_BINARY_DIR}/builtins/FREETYPE-prefix)

# The CMake of FreeType will call the static library differently if the CMAKE_BUILD_TYPE is Debug, bu adding a
# The CMake of FreeType will call the static library differently if the CMAKE_BUILD_TYPE is Debug, by adding a
# "d" to the name of the file. This is unusual if compared to the behaviour of other ROOT builtins, where the name
# changes only between Linux/macOS and Windows.
if(MSVC)
Expand Down Expand Up @@ -60,15 +60,26 @@ ExternalProject_Add(
TIMEOUT 600
)

set(incdir ${FREETYPE_PREFIX}/include/freetype2)
file(MAKE_DIRECTORY "${incdir}")

add_library(Freetype::Freetype IMPORTED STATIC GLOBAL)

set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FREETYPE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${incdir}")

if(builtin_zlib)
add_dependencies(BUILTIN_FREETYPE BUILTIN_ZLIB)
endif()

# Set the canonical output of find_package according to
# https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#standard-variable-names
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_PREFIX}/include/freetype2 PARENT_SCOPE)
set(FREETYPE_INCLUDE_DIRS ${incdir} PARENT_SCOPE)
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} PARENT_SCOPE)
set(Freetype_FOUND TRUE PARENT_SCOPE)
set(Freetype_VERSION ${FREETYPE_VERSION} PARENT_SCOPE)

if(builtin_zlib)
add_dependencies(BUILTIN_FREETYPE BUILTIN_ZLIB)
endif()


2 changes: 1 addition & 1 deletion cmake/modules/RootMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ endmacro()
# and then use those for linking.
# LIBRARIES lib1 lib2 : private arguments for target_link_library()
# DEPENDENCIES lib1 lib2 : PUBLIC arguments for target_link_library() such as Core, MathCore
# BUILTINS builtin1 builtin2 : builtins like AFTERIMAGE
# BUILTINS builtin1 builtin2 : builtins like xxhash
# LINKDEF LinkDef.h : linkdef file, default value is "LinkDef.h"
# DICTIONARY_OPTIONS option : options passed to rootcling
# INSTALL_OPTIONS option : options passed to install headers
Expand Down
130 changes: 29 additions & 101 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ if(asimage)
ROOT_FIND_REQUIRED_DEP(GIF builtin_gif)
ROOT_FIND_REQUIRED_DEP(JPEG builtin_jpeg)
# We cannot PNG here because while searching PNG, CMake will also find ZLIB.
# If found, CMake will define the default variables and target:
# If found, CMake will define the default variables and target:
# see https://cmake.org/cmake/help/latest/module/FindZLIB.html).
# For this reason, the check has to be put below, after ZLIB is searched for.
#ROOT_FIND_REQUIRED_DEP(PNG builtin_png)
Expand Down Expand Up @@ -253,7 +253,34 @@ if(NOT builtin_freetype)
else()
find_package(Freetype)
if(FREETYPE_FOUND)
set(FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR_freetype2})
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_freetype2})
if(NOT TARGET Freetype::Freetype)
add_library(Freetype::Freetype UNKNOWN IMPORTED)
set_target_properties(Freetype::Freetype PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIRS}")

if(FREETYPE_LIBRARY_RELEASE)
set_property(TARGET Freetype::Freetype APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${FREETYPE_LIBRARIES}")
endif()

if(FREETYPE_LIBRARY_DEBUG)
set_property(TARGET Freetype::Freetype APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${FREETYPE_LIBRARIES}")
endif()

if(NOT FREETYPE_LIBRARY_RELEASE AND NOT FREETYPE_LIBRARY_DEBUG)
set_target_properties(Freetype::Freetype PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FREETYPE_LIBRARIES}")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should be instead like in https://github.com/Kitware/CMake/blob/f5fc584bffee1a0641f611523741a99898a864d9/Modules/FindFreetype.cmake#L243 with the suffix. Same above for Release

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have several other libs with similar logic - they do not have such special flags.
Therefore try first more simpler solutions

endif()
endif()
else()
message(STATUS "FreeType not found. Switching on builtin_freetype option")
set(builtin_freetype ON CACHE BOOL "Enabled because FreeType not found (${builtin_freetype_description})" FORCE)
Expand Down Expand Up @@ -451,105 +478,6 @@ if(asimage)
endif()
endif()
endif()

#---AfterImage---------------------------------------------------------------
set(AFTERIMAGE_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libAfterImage${CMAKE_STATIC_LIBRARY_SUFFIX})
if(WIN32)
set(ASTEP_LIB_DIR ".")
if(NOT CMAKE_GENERATOR MATCHES Ninja)
if(winrtdebug)
set(astepbld Debug)
else()
set(astepbld Release)
endif()
set(ASTEP_LIB_DIR "${astepbld}")
set(ASTEP_EXTRA_BUILD_ARGS --config ${astepbld})
endif()
ExternalProject_Add(
AFTERIMAGE
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/graf2d/asimage/src/libAfterImage AFTERIMAGE
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DFREETYPE_INCLUDE_DIR=${FREETYPE_INCLUDE_DIRS}
-DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS}
-DJPEG_INCLUDE_DIR=${JPEG_INCLUDE_DIR}
-DJPEG_LIBRARY_LOCATION=${JPEG_LIBRARY_LOCATION}
-DPNG_INCLUDE_DIR=${PNG_INCLUDE_DIR}
-DPNG_LIBRARY_LOCATION=${PNG_LIBRARY_LOCATION}
-DGIF_INCLUDE_DIR=${GIF_INCLUDE_DIR}
-DGIF_LIBRARY_LOCATION=${GIF_LIBRARY_LOCATION}
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${ASTEP_EXTRA_BUILD_ARGS}
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASTEP_LIB_DIR}/libAfterImage.lib <INSTALL_DIR>/lib/
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_IN_SOURCE 0
BUILD_BYPRODUCTS ${AFTERIMAGE_LIBRARIES}
TIMEOUT 600
)
set(AFTERIMAGE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/AFTERIMAGE-prefix/src/AFTERIMAGE)
else()
if(asimage_tiff)
list(APPEND afterimage_extra_args --with-tiff-includes=${TIFF_INCLUDE_DIR})
else()
list(APPEND afterimage_extra_args --with-tiff=no)
endif()
if(x11)
list(APPEND afterimage_extra_args --with-x)
else()
list(APPEND afterimage_extra_args --without-x)
endif()
if(builtin_freetype)
list(APPEND afterimage_extra_args --with-ttf-includes=-I${FREETYPE_INCLUDE_DIRS})
set(_after_cflags "${_after_cflags} -DHAVE_FREETYPE_FREETYPE -DPNG_ARM_NEON_OPT=0")
endif()
if(CMAKE_OSX_SYSROOT)
set(_after_cflags "${_after_cflags} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
if(builtin_zlib)
set(_after_cflags "${_after_cflags} -I${ZLIB_INCLUDE_DIRS}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
set(AFTERIMAGE_LIBRARIES ${CMAKE_BINARY_DIR}/AFTERIMAGE-prefix/src/AFTERIMAGE/libAfterImage${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()
ExternalProject_Add(
AFTERIMAGE
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/graf2d/asimage/src/libAfterImage AFTERIMAGE
INSTALL_DIR ${CMAKE_BINARY_DIR}
CONFIGURE_COMMAND ./configure --prefix <INSTALL_DIR>
--libdir=<INSTALL_DIR>/lib
--with-ttf --with-afterbase=no
--without-svg --disable-glx
--with-jpeg
--with-jpeg-includes=${JPEG_INCLUDE_DIR}
--with-png
--with-png-includes=${PNG_INCLUDE_DIR}
--with-gif
--with-gif-includes=${GIF_INCLUDE_DIR}
${afterimage_extra_args}
CC=${CMAKE_C_COMPILER} CFLAGS=${_after_cflags}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${AFTERIMAGE_LIBRARIES}
TIMEOUT 600
)
set(AFTERIMAGE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/libAfterImage)
if(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
set(AFTERIMAGE_INCLUDE_DIR ${CMAKE_BINARY_DIR}/AFTERIMAGE-prefix/src/AFTERIMAGE)
endif()
endif()
if(builtin_gif)
add_dependencies(AFTERIMAGE BUILTIN_LIBGIF)
endif()
if(builtin_jpeg)
add_dependencies(AFTERIMAGE BUILTIN_LIBJPEG)
endif()
if(builtin_png)
add_dependencies(AFTERIMAGE BUILTIN_LIBPNG)
endif()
if(builtin_freetype)
add_dependencies(AFTERIMAGE BUILTIN_FREETYPE)
endif()
set(AFTERIMAGE_TARGET AFTERIMAGE)
endif()

#---Check for GSL library---------------------------------------------------------------
Expand Down
20 changes: 12 additions & 8 deletions graf2d/asimage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# @author Pere Mato, CERN
############################################################################

add_subdirectory(src/libAfterImage)

ROOT_STANDARD_LIBRARY_PACKAGE(ASImage
NO_INSTALL_HEADERS
HEADERS
Expand All @@ -23,7 +25,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImage
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
${AFTERIMAGE_LIBRARIES}
libAfterImage
${ASEXTRA_LIBRARIES}
${FREETYPE_LIBRARIES}
${X11_LIBRARIES}
Expand All @@ -32,12 +34,12 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImage
Core
Graf
Postscript
BUILTINS
AFTERIMAGE
)

target_include_directories(ASImage SYSTEM PRIVATE ${FREETYPE_INCLUDE_DIRS} ${AFTERIMAGE_INCLUDE_DIR} ${X11_INCLUDE_DIR})
target_link_libraries(ASImage PRIVATE JPEG::JPEG PNG::PNG GIF::GIF)
target_link_libraries(ASImage PRIVATE JPEG::JPEG PNG::PNG GIF::GIF libAfterImage Freetype::Freetype)
if (x11)
target_link_libraries(ASImage PRIVATE X11::X11)
endif()

ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui
NO_INSTALL_HEADERS
Expand All @@ -50,7 +52,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
${AFTERIMAGE_LIBRARIES}
libAfterImage
${ASEXTRA_LIBRARIES}
${FREETYPE_LIBRARIES}
${X11_LIBRARIES}
Expand All @@ -60,7 +62,9 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui
ASImage
)

target_include_directories(ASImageGui SYSTEM PRIVATE ${FREETYPE_INCLUDE_DIRS} ${AFTERIMAGE_INCLUDE_DIR} ${X11_INCLUDE_DIR})
target_link_libraries(ASImageGui PRIVATE JPEG::JPEG PNG::PNG GIF::GIF)
target_link_libraries(ASImageGui PRIVATE JPEG::JPEG PNG::PNG GIF::GIF libAfterImage Freetype::Freetype)
if (x11)
target_link_libraries(ASImageGui PRIVATE X11::X11)
endif()

ROOT_INSTALL_HEADERS()
79 changes: 2 additions & 77 deletions graf2d/asimage/README
Original file line number Diff line number Diff line change
@@ -1,80 +1,5 @@
The package libAfterImage has been imported from its official repository using the command:
Originally, the package libAfterImage was imported from its official repository using the command:

cvs -d :pserver:anonymous@cvs.aftercode.net:/home/cvsroot checkout afterstep-stable/libAfterImage

This command download the source in:

afterstep-stable/libAfterImage

To get the updates for this package it is enough to do "cvs update" from this directory.

To import libAfterImage into the ROOT svn repository we use the following command script:

cd ~/afterstep-stable/libAfterImage
cvs update
cd /tmp
cp -rf ~/afterstep-stable/libAfterImage .
cd libAfterImage
rm -f Makefile config.status afterimage-libs config.log
rm -rf apps aftershow config.h
rm -rf ./libpng/CVS ./CVS ./win32/CVS ./libungif/CVS ./libjpeg/CVS ./zlib/CVS
cd libAfterImage
cp -R * $ROOTSYS/graf2d/asimage/src/libAfterImage
cd /tmp
rm -r libAfterImage

Some files have been modified compare to the official libAfterImage version:

config.h.in has been modified in order to use freetype from the ROOT
repository.

libjpeg/jcmainct.c libjpeg/jdmainct.c have been modified to avoid a
compilation warning. These two pieces of code contain a variable called
"main" (some compiler do not like this). This variable name has been
changed to "mainptr".

libjpeg/jmorecfg.h generated a warning on Windows: "a benign redifinition".
This warning has been disabled.

libjpeg/jconfig.h: disable INLINE definition.

libjpeg/jidctred.c: removed from repository (replaced by jidctint.c)

libjpeg/jmorecfg.h and libjpeg/jconfig.h: fix a problem with boolean.

configure.in: support clang++ by removing some warnings.

libpng/pngpriv.h: fp.h was moved into math.h. This fix was originated by G. Eullisse - ALICE (April 2025)

configure:
- has been modified to look at the ".dylib" file extension to find
the X11 libraries. This is needed on the Mac Leopard system.
- the compiling option -Winline has been removed because it produced many
warnings with gcc 4.3.
- support clang++ by removing some warnings.

libAfterImage.mak:
Remove the word "Warning" in the message
"Warning: cannot find "libAfterImage.dep" to prevent to SPI
nightly build to issue an error.

import.c: to fix the warning (on SLC5):
"warning: dereferencing type-punned pointer will break strict-aliasing rules"

import.c and ungif.c (Ubuntu gcc 4.4):
"warning: ignoring return value of 'fread', declared with attribute warn_unused_result"

export.c: to fix a warning on Open Solaris:
"initializer will be sign-extended: -1"

export.c and import.c:
OSX Lion comes with builtin libpng 1.5.1 which obsoletes some 1.2 constructs

asimage.c, char2uni.c, export.c, imencdec.c:
- fix a warning with clang:
"comparison of unsigned enum expression < 0 is always false"

Note:
The file afterbase.h gets autogenerated by configure from afterbase.h.in
if afterbase.h.in has not changed, afterbase.h remains unchanged.

Most files were modified and the build system adapted, compared to the official (obsolete) libAfterImage version.
3 changes: 1 addition & 2 deletions graf2d/asimage/src/TASImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ ROOT tutorials: `$ROOTSYS/tutorials/visualisation/image/`
#endif
# include <afterbase.h>
#else
# include <win32/config.h>
# include <win32/afterbase.h>
# define X_DISPLAY_MISSING 1
# include <afterbase.h>
#endif
# include <afterimage.h>
# include <bmp.h>
Expand Down
4 changes: 2 additions & 2 deletions graf2d/asimage/src/TASPaletteEditor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ It is called by a pull down menu item of TASImage.
#ifndef WIN32
# include <afterbase.h>
#else
# include <win32/config.h>
# include <win32/afterbase.h>
# define X_DISPLAY_MISSING 1
# include <afterbase.h>
#endif
# include <afterimage.h>
extern "C" {
Expand Down
3 changes: 1 addition & 2 deletions graf2d/asimage/src/TASPluginGS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ Allows to read PS/EPS/PDF files via GhostScript
#ifndef WIN32
# include <afterbase.h>
#else
# include <win32/config.h>
# include <win32/afterbase.h>
# define X_DISPLAY_MISSING 1
# include <afterbase.h>
#endif
# include <import.h>

Expand Down
8 changes: 0 additions & 8 deletions graf2d/asimage/src/libAfterImage/.cvsignore

This file was deleted.

Loading
Loading