From e3974e474ec134b6abdc5ac5189508fec730ed62 Mon Sep 17 00:00:00 2001 From: berniev Date: Sun, 29 Jan 2023 16:05:11 +1000 Subject: [PATCH] Further efficiencies to Summary Report Changed existing function to macro to access list of lines Added conditional macro to save most of the if() else() endif() Output sorted for improved comprehension Moved build message out (nothing to do with report) SLOC -~30% --- CMakeLists.txt | 4 + cMake/FreeCAD_Helpers/PrintFinalReport.cmake | 254 ++++++++----------- 2 files changed, 104 insertions(+), 154 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5acfeeff0c..dcb9c53484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,3 +101,7 @@ if (BUILD_TEST) endif() PrintFinalReport() + +message("\n=================================================\n" + "Now run 'cmake --build ${CMAKE_BINARY_DIR}' to build ${PROJECT_NAME}\n" + "=================================================\n") diff --git a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake index fdd6d94215..97ed06f66f 100644 --- a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake +++ b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake @@ -1,182 +1,128 @@ macro(PrintFinalReport) - message(STATUS "\n==============\n" - "Summary report\n" - "==============\n") - function(report name) - if(NOT ARGV1) - set(ARGV1 "-undefined-") + # simple report line + macro(simple) + set(name ${ARGV0}) + set(value ${ARGV1}) + if(NOT value) + set(value "-undefined-") endif() - string(APPEND nameSp ${name} ": ") - string(SUBSTRING ${nameSp} 0 20 nameStr) - message(STATUS "${nameStr} ${ARGV1}") - endfunction() + string(APPEND name ": ") + string(SUBSTRING ${name} 0 20 nameStr) + list(APPEND simpleLines "${nameStr} ${value}") + endmacro() - report(BuildType ${CMAKE_BUILD_TYPE}) - report(Compiler "${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_VERSION})") - report(Flags ${CMAKE_CXX_FLAGS}) - report(Standard "Requires C++${CMAKE_CXX_STANDARD}") + # report line with conditional data + macro(conditional) + set(name ${ARGV0}) + set(condition ${ARGV1}) + set(ifFalse ${ARGV2}) + set(ifTrue ${ARGV3}) + if(${condition}) + set(out ${ifTrue}) + else() + set(out ${ifFalse}) + endif() + simple(${name} ${out}) + endmacro() + + ################ Report data ################## + + simple(BuildType ${CMAKE_BUILD_TYPE}) + simple(Compiler "${CMAKE_CXX_COMPILER} (${CMAKE_CXX_COMPILER_VERSION})") + simple(Flags ${CMAKE_CXX_FLAGS}) + simple(Standard "Requires C++${CMAKE_CXX_STANDARD}") # Qt5 needs/sets PYTHON_CONFIG_SUFFIX regarding Shiboken - report(Python "${PYTHON_VERSION_STRING} [${PYTHON_EXECUTABLE}] [${PYTHON_CONFIG_SUFFIX}]") - if(PCL_FOUND) - report(PCL ${PCL_VERSION}) - else() - report(PCL "not enabled") - endif() - if(pybind11_FOUND) - report(pybind11 "${pybind11_VERSION}") - else() - report(pybind11 "not enabled") - endif() - report(Boost ${Boost_VERSION}) - report(XercesC "${XercesC_VERSION} [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]") - report(ZLIB "${ZLIB_VERSION_STRING}") - report(PyCXX "${PYCXX_VERSION} [${PYCXX_INCLUDE_DIR}]") - report(OCC "${OCC_VERSION_STRING} [${OCC_LIBRARIES}] [${OCC_LIBRARY_DIR}] [${OCC_INCLUDE_DIR}]") + simple(Python "${Python3_VERSION} [${PYTHON_EXECUTABLE}] Suffix: [${PYTHON_CONFIG_SUFFIX}]") + conditional(pybind11 pybind11_FOUND "not enabled" ${pybind11_VERSION}) + simple(Boost ${Boost_VERSION}) + simple(XercesC "${XercesC_VERSION} [${XercesC_LIBRARIES}] [${XercesC_INCLUDE_DIRS}]") + simple(ZLIB "${ZLIB_VERSION_STRING}") + simple(PyCXX "${PYCXX_VERSION} [${PYCXX_INCLUDE_DIR}]") + simple(OCC "${OCC_VERSION_STRING} [${OCC_LIBRARY_DIR}] [${OCC_INCLUDE_DIR}]") + simple(OCC_Libs "[${OCC_LIBRARIES}]") if(BUILD_SMESH) if(FREECAD_USE_EXTERNAL_SMESH) - report(SMESH "${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK}") + simple(SMESH "${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK}") else() - report(SMESH "${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK} build internal") - report(MEDFile "${MEDFILE_VERSION} [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]") - report(HDF5 ${HDF5_VERSION}) - report(VTK ${VTK_VERSION}) + simple(SMESH "${SMESH_VERSION_MAJOR}.${SMESH_VERSION_MINOR}.${SMESH_VERSION_PATCH}.${SMESH_VERSION_TWEAK} build internal") + simple(MEDFile "${MEDFILE_VERSION} [${MEDFILE_LIBRARIES}] [${MEDFILE_INCLUDE_DIRS}]") + simple(HDF5 ${HDF5_VERSION}) + simple(VTK ${VTK_VERSION}) endif() else() - report(SMESH "do not build") + simple(SMESH "do not build") endif() - if(NETGEN_FOUND) - report(NETGEN "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}.${NETGEN_VERSION_PATCH} (${NETGEN_VERSION}) [${NETGEN_DEFINITIONS}] [${NETGEN_CXX_FLAGS}] [${NGLIB_INCLUDE_DIR}] [${NGLIB_LIBRARIES}] [${NETGEN_INCLUDE_DIRS}]") - else() - report(NETGEN "not enabled") - endif() - #report(OpenCV ${OpenCV_VERSION}) - if(SWIG_FOUND) - report(SWIG ${SWIG_VERSION}) - else() - report(SWIG "not found") - endif() - if(EIGEN3_FOUND) - report(Eigen3 ${EIGEN3_VERSION}) - else() - report(Eigen3 "not found") - endif() - report(QtCore ${QtCore_VERSION}) - report(QtNetwork ${QtNetwork_VERSION}) - report(QtXml ${QtXml_VERSION}) + conditional(NETGEN NETGEN_FOUND + "not enabled" + "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}.${NETGEN_VERSION_PATCH} (${NETGEN_VERSION}) [${NETGEN_DEFINITIONS}] [${NETGEN_CXX_FLAGS}] [${NGLIB_INCLUDE_DIR}] [${NGLIB_LIBRARIES}] [${NETGEN_INCLUDE_DIRS}]" + ) + #simple(OpenCV ${OpenCV_VERSION}) + conditional(SWIG SWIG_FOUND "not found" ${SWIG_VERSION}) + conditional(Eigen3 EIGEN3_FOUND "not found" ${EIGEN3_VERSION}) + conditional(QtConcurrent BUILD_GUI "not needed" ${QtConcurrent_VERSION}) + simple(QtCore ${QtCore_VERSION}) + simple(QtNetwork ${QtNetwork_VERSION}) + conditional(QtOpenGL BUILD_GUI "not needed" ${QtOpenGL_VERSION}) + conditional(QtPrintSupport BUILD_GUI "not needed" ${QtPrintSupport_VERSION}) + conditional(QtSvg BUILD_GUI "not needed" ${QtSvg_VERSION}) + conditional(QtUiTools BUILD_GUI "not needed" ${QtUiTools_VERSION}) + conditional(QtWidgets BUILD_GUI "not needed" ${QtWidgets_VERSION}) + simple(QtXml ${QtXml_VERSION}) if (BUILD_GUI) - report(QtWidgets ${QtWidgets_VERSION}) - report(QtPrintSupport ${QtPrintSupport_VERSION}) - report(QtOpenGL ${QtOpenGL_VERSION}) - report(QtSvg ${QtSvg_VERSION}) - report(QtUiTools ${QtUiTools_VERSION}) - report(QtConcurrent ${QtConcurrent_VERSION}) - if(BUILD_WEB) - report(QtWebEngineWidgets ${QtWebEngineWidgets_VERSION}) - else() - report(QtWebEngineWidgets "not needed (BUILD_WEB is OFF)") - endif() - if(BUILD_DESIGNER_PLUGIN) - report(DesignerPlugin "${DESIGNER_PLUGIN_LOCATION}/${libFreeCAD_widgets}") - else() - report(DesignerPlugin "not built (BUILD_DESIGNER_PLUGIN is OFF)") - endif() + conditional(QtWebEngineWidgets BUILD_WEB "not needed (BUILD_WEB is OFF)" ${QtWebEngineWidgets_VERSION}) + conditional(DesignerPlugin BUILD_DESIGNER_PLUGIN + "not built (BUILD_DESIGNER_PLUGIN is OFF)" + "[${DESIGNER_PLUGIN_LOCATION}/${libFreeCAD_widgets}]" + ) else() - report(QtWidgets "not needed") - report(QtPrintSupport "not needed") - report(QtOpenGL "not needed") - report(QtSvg "not needed") - report(QtUiTools "not needed") - report(QtConcurrent "not needed") - report(QtWebKitWidgets "not needed") + simple(QtWebKitWidgets "not needed") endif() - - if(DEFINED MACPORTS_PREFIX) - if(Shiboken${SHIBOKEN_MAJOR_VERSION}_FOUND) - report(Shiboken "${Shiboken_VERSION} [${SHIBOKEN_INCLUDE_DIR}]") - else() - report(Shiboken "not found (only searched if MACPORTS_PREFIX is defined)") - endif() - if(PySide_FOUND) - report(PySide "${PySide_VERSION} [${PYSIDE_INCLUDE_DIR}]") - if(NOT PYSIDE_INCLUDE_DIR) - report(IncludeDir "Unable to find, python version mismatch?") - endif() - else() - report(PySide: "not found (only searched if MACPORTS_PREFIX is defined)") - endif() - endif() - - if(PySide${SHIBOKEN_MAJOR_VERSION}_FOUND) - report(PySide "${PYSIDE_VERSION} [${PYSIDE_INCLUDE_DIR}]") - if(NOT PYSIDE_INCLUDE_DIR) - report(PySideIncludeDir "Unable to find, python version mismatch?") - endif() - else() - report(PySide "not found") - endif() - if(PYSIDE_TOOLS_FOUND) - report(PySideTools "[${PYSIDE_UIC_EXECUTABLE}] [${PYSIDE_RCC_EXECUTABLE}]") - else() - report(PySideTools "not found") - endif() - + conditional(Shiboken SHIBOKEN_FOUND "not found" "${SHIBOKEN_VERSION} Base: [${SHIBOKEN_BASEDIR}]") + conditional(PySide PYSIDE_FOUND "not found" "${PYSIDE_VERSION} [${PYSIDE_INCLUDE_DIR}]") + conditional(PySideTools PYSIDE_TOOLS_FOUND + "not found" + "uic: [${PYSIDE_UIC_EXECUTABLE}] rcc: [${PYSIDE_RCC_EXECUTABLE}]" + ) if(FREECAD_USE_FREETYPE) - if(FREETYPE_FOUND) - report(Freetype ${FREETYPE_VERSION_STRING}) - else() - report(Freetype "not found") - endif() + conditional(Freetype FREETYPE_FOUND "not found" ${FREETYPE_VERSION_STRING}) else() - report(Freetype "disabled") + simple(Freetype "disabled") endif() - report(OpenGL ${OPENGL_gl_LIBRARY}) - report(OpenGLU "[${OPENGL_glu_LIBRARY}][${OPENGL_INCLUDE_DIR}]") - report(Coin3D "${COIN3D_VERSION} [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]") - report(Pivy ${PIVY_VERSION}) + simple(OpenGL_Lib [${OPENGL_gl_LIBRARY}]) + simple(OpenGLU_Lib [${OPENGL_glu_LIBRARY}]) + simple(OpenGLU_Incl [${OPENGL_INCLUDE_DIR}]) + simple(Coin3D "${COIN3D_VERSION} [${COIN3D_LIBRARIES}] [${COIN3D_INCLUDE_DIRS}]") + simple(Pivy ${PIVY_VERSION}) if (WIN32) - #report(SPNAV "not available yet for your OS") # FREECAD_USE_3DCONNEXION instead... + #simple(SPNAV "not available yet for your OS") # FREECAD_USE_3DCONNEXION instead... else() - if(SPNAV_FOUND) - report(SPNAV "[${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]") - else() - report(SPNAV "not found") - endif() - endif() - - if(MATPLOTLIB_FOUND) - report(Matplotlib ${MATPLOTLIB_VERSION}) - else() - report(Matplotlib "not found") + conditional(SPNAV SPNAV_FOUND "not found" "[${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]") endif() + conditional(Matplotlib MATPLOTLIB_FOUND "not found" ${MATPLOTLIB_VERSION}) if(BUILD_VR) - if(RIFT_FOUND) - report(Rift ${Rift_VERSION}) - else() - report(Rift "not found") - endif() + conditional(Rift RIFT_FOUND "not found" ${Rift_VERSION}) else() - report(Rift "not enabled (BUILD_VR)") + simple(Rift "not enabled (BUILD_VR)") endif() if(DOXYGEN_FOUND) - report(Doxygen ${DOXYGEN_VERSION}) - report(Language ${DOXYGEN_LANGUAGE}) - if(COIN3D_DOC_FOUND) - report(Coin3D_DOC "found [${COIN3D_DOC_PATH}]") - else() - report(Coin3D_DOC "not found") - endif() + simple(Doxygen ${DOXYGEN_VERSION}) + simple(Language ${DOXYGEN_LANGUAGE}) + conditional(Coin3D_DOC COIN3D_DOC_FOUND "not found" ${COIN3D_DOC_PATH}) else() - report(Doxygen "not found") - endif() - if(BUILD_TEST) - report(Tests "ON") - else() - report(Tests "OFF") + simple(Doxygen "not found") endif() + conditional(Tests BUILD_TEST "OFF" "ON") + + ############## End report data #################### + + message(STATUS "\n==============\n" + "Summary Report\n" + "==============\n") + + list(SORT simpleLines CASE INSENSITIVE) + foreach(line ${simpleLines}) + message(STATUS ${line}) + endforeach() - # Print message to start build process - message("=================================================\n" - "Now run 'cmake --build ${CMAKE_BINARY_DIR}' to build ${PROJECT_NAME}\n" - "=================================================\n") endmacro()