Improve CMake build configuration summary

- simplify and unify build option output
- alignment can be changed in only 2 macros in CMake/fl_summary.cmake
- output system library location of image libraries if applicable
This commit is contained in:
Albrecht Schlosser 2024-04-08 18:56:40 +02:00
parent ba7b2427b6
commit 265e5cd77b
3 changed files with 127 additions and 93 deletions

View File

@ -43,6 +43,8 @@ function(fl_expand_name out in min_len)
set(temp "${in}${spaces}${spaces}")
string(SUBSTRING "${temp}" 0 ${min_len} temp)
set(${out} "${temp}" PARENT_SCOPE)
else()
set(${out} "${in}" PARENT_SCOPE)
endif()
endfunction(fl_expand_name)

89
CMake/fl_summary.cmake Normal file
View File

@ -0,0 +1,89 @@
#
# Macros used by the CMake build system for the Fast Light Tool Kit (FLTK).
#
# Copyright 2024 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this
# file is missing or damaged, see the license at:
#
# https://www.fltk.org/COPYING.php
#
# Please see the following page on how to report bugs and issues:
#
# https://www.fltk.org/bugs.php
#
########################################################################
# The macros in this file are used to generate the CMake build summary.
# Fixed widths of title fields are intentionally hard coded in two of
# these macros so we can easily change the alignment.
########################################################################
include(${CMAKE_CURRENT_LIST_DIR}/fl_debug_var.cmake)
########################################################################
# Output a summary line like "<title> <value>"
########################################################################
# <title> will be expanded to a fixed width (can be empty)
# <value> text to be displayed
########################################################################
macro(fl_summary title value)
fl_expand_name(label "${title}" 24)
message(STATUS "${label} ${value}")
endmacro(fl_summary title value)
########################################################################
# Output a summary line like "<title> will be built ..."
# or "<title> will not be built ..."
########################################################################
# title will be expanded to a fixed width (must not be empty)
# subdir = relative build directory (e.g. lib or bin/test)
# build = CMake variable name (bool): whether <title> is built
# option = option name the user can set to build <title>
########################################################################
macro(fl_summary_build title subdir build option)
if(${build})
set(value "will be built in: ${CMAKE_CURRENT_BINARY_DIR}/${subdir}")
else()
set(value "will not be built (set ${option}=ON to build)")
endif()
fl_expand_name(label "${title}" 19)
message(STATUS "${label} ${value}")
endmacro(fl_summary_build title var subdir)
########################################################################
# Output a simple summary line like "<title> {Yes|No}"
########################################################################
# title will be expanded to a fixed width (must not be empty)
# var = CMake variable name, must evaluate to true or false
########################################################################
macro(fl_summary_yn title var)
if(${var})
set(value "Yes")
else()
set(value "No")
endif()
fl_summary("${title}" ${value})
endmacro(fl_summary_yn title var)
########################################################################
# Output summary line for image libs (bundled or system libs)
########################################################################
# title = "Image Libraries" or empty
# name = displayed name = { JPEG | PNG | ZLIB }
# lib = CMake library name (system library, if it was found)
########################################################################
macro(fl_summary_image title name lib)
fl_expand_name(name4 "${name}" 4)
if(FLTK_USE_BUNDLED_${name})
set(value "${name4} = Bundled")
else()
set(value "${name4} = System: ${${lib}}")
endif()
fl_summary("${title}" "${value}")
endmacro(fl_summary_image title name lib)

View File

@ -227,136 +227,79 @@ if(FLTK_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS)
endif(FLTK_BUILD_SHARED_LIBS AND GENERATE_EXPORT_HEADERS)
#######################################################################
# Output Configuration Summary
# Output Build Configuration Summary
#######################################################################
include(FeatureSummary)
include(FeatureSummary) # CMake Feature Summary
include(CMake/fl_summary.cmake) # special FLTK summary macros
# CMake Feature Summary
message("")
set(_descr "${PROJECT_NAME} ${FLTK_VERSION} generated by CMake ${CMAKE_VERSION}")
feature_summary(WHAT ALL DESCRIPTION "Configuration Summary for ${_descr} --\n")
message(STATUS "Static libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
# FLTK specific build configuration and options (see macros in fl_summary.cmake)
if(FLTK_BUILD_SHARED_LIBS)
message(STATUS "Shared libraries will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else()
message(STATUS "Shared libraries will not be built (set FLTK_BUILD_SHARED_LIBS=ON to build)")
endif()
# "title" dir build (bool) option to set
fl_summary_build("Static libraries" lib TRUE "n/a")
fl_summary_build("Shared libraries" lib FLTK_BUILD_SHARED_LIBS FLTK_BUILD_SHARED_LIBS)
fl_summary_build("The forms library" lib FLTK_BUILD_FORMS FLTK_BUILD_FORMS)
fl_summary_build("The OpenGL library" lib FLTK_USE_GL FLTK_BUILD_GL)
fl_summary_build("fluid" bin FLTK_BUILD_FLUID FLTK_BUILD_FLUID)
fl_summary_build("fltk-options" bin FLTK_BUILD_FLTK_OPTIONS FLTK_BUILD_FLTK_OPTIONS)
if(FLTK_BUILD_FORMS)
message(STATUS "The forms library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else()
message(STATUS "The forms library will not be built (set FLTK_BUILD_FORMS=ON to build)")
endif()
if(FLTK_USE_GL)
message(STATUS "The OpenGL library will be built in ${CMAKE_CURRENT_BINARY_DIR}/lib")
else()
message(STATUS "The OpenGL library will not be built (set FLTK_BUILD_GL=ON to build)")
endif()
if(FLTK_BUILD_FLUID)
message(STATUS "fluid will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid")
else()
message(STATUS "fluid will not be built (set FLTK_BUILD_FLUID=ON to build)")
endif()
if(FLTK_BUILD_FLTK_OPTIONS)
message(STATUS "fltk-options will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-options")
else()
message(STATUS "fltk-options will not be built (set FLTK_BUILD_FLTK_OPTIONS=ON to build)")
endif()
if(FLTK_BUILD_TEST)
message(STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test")
else()
message(STATUS "Test programs will not be built (set FLTK_BUILD_TEST=ON to build)")
endif()
if(FLTK_BUILD_EXAMPLES)
message(STATUS "Example programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/examples")
else()
message(STATUS "Example programs will not be built (set FLTK_BUILD_EXAMPLES=ON to build)")
endif()
fl_summary_build("Test programs" bin/test FLTK_BUILD_TEST FLTK_BUILD_TEST)
fl_summary_build("Example programs" bin/examples FLTK_BUILD_EXAMPLES FLTK_BUILD_EXAMPLES)
message(STATUS "")
if(CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "Build configuration : <unspecified>")
fl_summary("Build configuration" "<unspecified>")
else()
message(STATUS "Build configuration : ${CMAKE_BUILD_TYPE}")
fl_summary("Build configuration" "${CMAKE_BUILD_TYPE}")
endif()
message(STATUS "")
message("")
# "title" name system library if used
fl_summary_image("Image Libraries" JPEG LIB_jpeg)
fl_summary_image("" PNG LIB_png)
fl_summary_image("" ZLIB LIB_zlib)
if(FLTK_USE_BUNDLED_JPEG)
message(STATUS "Image Libraries : JPEG = Builtin")
else()
message(STATUS "Image Libraries : JPEG = System")
endif()
if(FLTK_USE_BUNDLED_PNG)
message(STATUS " : PNG = Builtin")
else()
message(STATUS " : PNG = System")
endif()
if(FLTK_USE_BUNDLED_ZLIB)
message(STATUS " : ZLIB = Builtin")
else()
message(STATUS " : ZLIB = System")
endif()
message("")
if(UNIX AND NOT (APPLE AND NOT FLTK_BACKEND_X11))
if(FLTK_BACKEND_WAYLAND)
if(FLTK_BACKEND_X11)
message(STATUS "Use Wayland : Yes (can also run as X11 client)")
fl_summary("Use Wayland" "Yes (can also run as X11 client)")
else()
message(STATUS "Use Wayland : Yes (cannot run as X11 client)")
fl_summary("Use Wayland" "Yes (cannot run as X11 client)")
endif(FLTK_BACKEND_X11)
if(USE_SYSTEM_LIBDECOR)
message(STATUS "Use system libdecor : Yes")
else()
message(STATUS "Use system libdecor : No")
endif(USE_SYSTEM_LIBDECOR)
fl_summary_yn("Use system libdecor" USE_SYSTEM_LIBDECOR)
else()
message(STATUS "Use Wayland : No (therefore, X11 is used)")
fl_summary("Use Wayland" "No (X11 is used)")
endif(FLTK_BACKEND_WAYLAND)
if(FLTK_USE_CAIRO)
message(STATUS "All drawing uses Cairo : Yes")
else()
message(STATUS "All drawing uses Cairo : No")
endif()
fl_summary_yn("All drawing uses Cairo" FLTK_USE_CAIRO)
if(USE_PANGO)
message(STATUS "Use Pango : Yes")
else()
message(STATUS "Use Pango : No")
if(USE_XFT)
message(STATUS "Use Xft : Yes")
else()
message(STATUS "Use Xft : No")
endif()
fl_summary_yn("Use Pango" USE_PANGO)
if(NOT USE_PANGO)
fl_summary_yn("Use Xft" USE_XFT)
endif()
endif()
set(title "Fl_Cairo_Window support")
if(FLTK_HAVE_CAIROEXT)
message(STATUS "Fl_Cairo_Window support : Yes (extended)")
fl_summary("${title}" "Yes (extended)")
elseif(FLTK_HAVE_CAIRO)
message(STATUS "Fl_Cairo_Window support : Yes (standard)")
fl_summary("${title}" "Yes (standard)")
else()
message(STATUS "Fl_Cairo_Window support : No")
fl_summary("${title}" "No")
endif()
if(FLTK_USE_STD)
message(STATUS "Use std:: : Yes")
else()
message(STATUS "Use std:: : No")
endif()
fl_summary_yn("Use std::" FLTK_USE_STD)
message("")
message(STATUS "End of Configuration Summary --\n")