From cbef79bb93d1197fc99de36388154ef43fac7431 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 13 Sep 2017 08:32:22 -0400 Subject: [PATCH] Clean up CMake stuff, remove unneeded modules --- CMakeLists.txt | 56 ++++--- CMakeModules/MacroLogFeature.cmake | 157 -------------------- CMakeModules/MacroOptionalFindPackage.cmake | 48 ------ 3 files changed, 32 insertions(+), 229 deletions(-) delete mode 100644 CMakeModules/MacroLogFeature.cmake delete mode 100644 CMakeModules/MacroOptionalFindPackage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5978a1c53..b14521417 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ cmake_policy( SET CMP0028 NEW ) # double colons in KF5::Foo and Qt5::Foo are nec cmake_policy( SET CMP0043 OLD ) include( MacroOptionalFindPackage ) -include( MacroLogFeature ) +include( FeatureSummary ) set( QT_VERSION 5.6.0 ) @@ -80,35 +80,29 @@ if( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_D set( WITH_CRASHREPORTER OFF ) endif() -macro_optional_find_package( PythonLibs 3.3 ) -macro_log_feature( - PYTHONLIBS_FOUND - "Python" - "C interface libraries for the Python 3 interpreter." - "http://python.org" - FALSE "3.3" - "Python 3 is used for some Calamares job modules." +find_package( PythonLibs 3.3 OPTIONAL ) +set_package_properties( + PYTHONLIBS PROPERTIES + DESCRIPTION "C interface libraries for the Python 3 interpreter." + URL "http://python.org" + PURPOSE "Python 3 is used for some Calamares job modules." ) if ( PYTHONLIBS_FOUND ) include( BoostPython3 ) find_boost_python3( 1.54.0 ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND ) - macro_log_feature( - CALAMARES_BOOST_PYTHON3_FOUND - "Boost.Python" - "A C++ library which enables seamless interoperability between C++ and Python 3." - "http://www.boost.org" - FALSE "1.54.0" - "Boost.Python is used for interfacing with Calamares job modules written in Python 3." + set_package_properties( + CALAMARES_BOOST_PYTHON3 PROPERTIES + DESCRIPTION "A C++ library which enables seamless interoperability between C++ and Python 3." + URL "http://www.boost.org" + PURPOSE "Boost.Python is used for interfacing with Calamares job modules written in Python 3." ) macro_optional_find_package( PythonQt ) - macro_log_feature( PYTHONQT_FOUND - "PythonQt" - "A Python embedding solution for Qt applications." - "http://pythonqt.sourceforge.net" - FALSE "3.1" - "PythonQt is used for the Python modules API." + set_package_properties( PYTHONQT PROPERTIES + DESCRIPTION "A Python embedding solution for Qt applications." + URL "http://pythonqt.sourceforge.net" + PURPOSE "PythonQt is used for the Python modules API." ) endif() @@ -203,8 +197,12 @@ set( THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty" ) # make example-distro # find_program( mksquashfs_PROGRAM mksquashfs ) -macro_log_feature( mksquashfs_PROGRAM "mksquashfs" "Create example distro" "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html") +set_package_properties( mksquashfs PROPERTIES + DESCRIPTION "Create example distro" + URL "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html" +) if( mksquashfs_PROGRAM ) + set( mksquashfs_FOUND ON ) set( src_fs ${CMAKE_SOURCE_DIR}/data/example-root/ ) set( dst_fs ${CMAKE_BINARY_DIR}/example.sqfs ) if( EXISTS ${src_fs} ) @@ -227,12 +225,22 @@ if( mksquashfs_PROGRAM ) ) add_custom_target(example-distro DEPENDS ${dst_fs}) endif() +else() + set( mksquashfs_FOUND OFF ) endif() +# Doesn't list mksquashfs as an optional dep, though, because it +# hasn't been sent through the find_package() scheme. +set_package_properties( mksquashfs PROPERTIES + DESCRIPTION "Create squashed filesystems" + URL "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html" + PURPOSE "Create example distro" + TYPE OPTIONAL +) add_subdirectory( thirdparty ) add_subdirectory( src ) -macro_display_feature_log() +feature_summary(WHAT ALL) if( NOT WITH_PYTHON ) message( "-- WARNING: Building Calamares without Python support. Legacy Python job modules will not work.\n" ) diff --git a/CMakeModules/MacroLogFeature.cmake b/CMakeModules/MacroLogFeature.cmake deleted file mode 100644 index 45e27b6df..000000000 --- a/CMakeModules/MacroLogFeature.cmake +++ /dev/null @@ -1,157 +0,0 @@ -# This file defines the Feature Logging macros. -# -# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) -# Logs the information so that it can be displayed at the end -# of the configure run -# VAR : TRUE or FALSE, indicating whether the feature is supported -# FEATURE: name of the feature, e.g. "libjpeg" -# DESCRIPTION: description what this feature provides -# URL: home page -# REQUIRED: TRUE or FALSE, indicating whether the featue is required -# MIN_VERSION: minimum version number. empty string if unneeded -# COMMENTS: More info you may want to provide. empty string if unnecessary -# -# MACRO_DISPLAY_FEATURE_LOG() -# Call this to display the collected results. -# Exits CMake with a FATAL error message if a required feature is missing -# -# Example: -# -# INCLUDE(MacroLogFeature) -# -# FIND_PACKAGE(JPEG) -# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") -# ... -# MACRO_DISPLAY_FEATURE_LOG() - -# Copyright (c) 2006, Alexander Neundorf, -# Copyright (c) 2006, Allen Winter, -# Copyright (c) 2009, Sebastian Trueg, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -IF (NOT _macroLogFeatureAlreadyIncluded) - SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) - IF (EXISTS ${_file}) - FILE(REMOVE ${_file}) - ENDIF (EXISTS ${_file}) - - SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) - IF (EXISTS ${_file}) - FILE(REMOVE ${_file}) - ENDIF (EXISTS ${_file}) - - SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) - IF (EXISTS ${_file}) - FILE(REMOVE ${_file}) - ENDIF (EXISTS ${_file}) - - SET(_macroLogFeatureAlreadyIncluded TRUE) - - INCLUDE(FeatureSummary) - -ENDIF (NOT _macroLogFeatureAlreadyIncluded) - - -MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) - - STRING(TOUPPER "${ARGV4}" _required) - SET(_minvers "${ARGV5}") - SET(_comments "${ARGV6}") - - IF (${_var}) - SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) - ELSE (${_var}) - IF ("${_required}" STREQUAL "TRUE") - SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt) - ELSE ("${_required}" STREQUAL "TRUE") - SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) - ENDIF ("${_required}" STREQUAL "TRUE") - ENDIF (${_var}) - - SET(_logtext " * ${_package}") - - IF (NOT ${_var}) - IF (${_minvers} MATCHES ".*") - SET(_logtext "${_logtext} (${_minvers} or higher)") - ENDIF (${_minvers} MATCHES ".*") - SET(_logtext "${_logtext} <${_url}>\n ") - ELSE (NOT ${_var}) - SET(_logtext "${_logtext} - ") - ENDIF (NOT ${_var}) - - SET(_logtext "${_logtext}${_description}") - - IF (NOT ${_var}) - IF (${_comments} MATCHES ".*") - SET(_logtext "${_logtext}\n ${_comments}") - ENDIF (${_comments} MATCHES ".*") -# SET(_logtext "${_logtext}\n") #double-space missing features? - ENDIF (NOT ${_var}) - - FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") - - IF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3 - SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"") - ENDIF(COMMAND SET_PACKAGE_INFO) - -ENDMACRO(MACRO_LOG_FEATURE) - - -MACRO(MACRO_DISPLAY_FEATURE_LOG) - IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3 - FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt - WHAT ALL) - ENDIF(COMMAND FEATURE_SUMMARY) - - SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt) - SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) - SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) - - IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) - SET(_printSummary TRUE) - ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) - - IF(_printSummary) - SET(_missingDeps 0) - IF (EXISTS ${_enabledFile}) - FILE(READ ${_enabledFile} _enabled) - FILE(REMOVE ${_enabledFile}) - SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n-----------------------------------------------------------------------------\n${_enabled}") - ENDIF (EXISTS ${_enabledFile}) - - - IF (EXISTS ${_disabledFile}) - SET(_missingDeps 1) - FILE(READ ${_disabledFile} _disabled) - FILE(REMOVE ${_disabledFile}) - SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n-----------------------------------------------------------------------------\n${_disabled}") - ENDIF (EXISTS ${_disabledFile}) - - - IF (EXISTS ${_missingFile}) - SET(_missingDeps 1) - FILE(READ ${_missingFile} _requirements) - SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- You must install these packages before continuing.\n-----------------------------------------------------------------------------\n${_requirements}") - FILE(REMOVE ${_missingFile}) - SET(_haveMissingReq 1) - ENDIF (EXISTS ${_missingFile}) - - - IF (NOT ${_missingDeps}) - SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.") - ENDIF (NOT ${_missingDeps}) - - - MESSAGE(${_summary}) - MESSAGE("-----------------------------------------------------------------------------\n") - - - IF(_haveMissingReq) - MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") - ENDIF(_haveMissingReq) - - ENDIF(_printSummary) - -ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) diff --git a/CMakeModules/MacroOptionalFindPackage.cmake b/CMakeModules/MacroOptionalFindPackage.cmake deleted file mode 100644 index d4ed48e33..000000000 --- a/CMakeModules/MacroOptionalFindPackage.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION() -# MACRO_OPTIONAL_FIND_PACKAGE( [QUIT] ) -# This macro is a combination of OPTION() and FIND_PACKAGE(), it -# works like FIND_PACKAGE(), but additionally it automatically creates -# an option name WITH_, which can be disabled via the cmake GUI. -# or via -DWITH_=OFF -# The standard _FOUND variables can be used in the same way -# as when using the normal FIND_PACKAGE() - -# Copyright (c) 2006-2010 Alexander Neundorf, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -# This is just a helper macro to set a bunch of variables empty. -# We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both: -macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var) - if(DEFINED ${_name}_${_var}) - set(${_name}_${_var} "") - endif(DEFINED ${_name}_${_var}) - - string(TOUPPER ${_name} _nameUpper) - if(DEFINED ${_nameUpper}_${_var}) - set(${_nameUpper}_${_var} "") - endif(DEFINED ${_nameUpper}_${_var}) -endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var) - - -macro (MACRO_OPTIONAL_FIND_PACKAGE _name ) - option(WITH_${_name} "Search for ${_name} package" ON) - if (WITH_${_name}) - find_package(${_name} ${ARGN}) - else (WITH_${_name}) - string(TOUPPER ${_name} _nameUpper) - set(${_name}_FOUND FALSE) - set(${_nameUpper}_FOUND FALSE) - - _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS) - _mofp_set_empty_if_defined(${_name} INCLUDE_DIR) - _mofp_set_empty_if_defined(${_name} INCLUDES) - _mofp_set_empty_if_defined(${_name} LIBRARY) - _mofp_set_empty_if_defined(${_name} LIBRARIES) - _mofp_set_empty_if_defined(${_name} LIBS) - _mofp_set_empty_if_defined(${_name} FLAGS) - _mofp_set_empty_if_defined(${_name} DEFINITIONS) - endif (WITH_${_name}) -endmacro (MACRO_OPTIONAL_FIND_PACKAGE) -