diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/ExternalProject.cmake | 51 | ||||
-rw-r--r-- | Modules/FindLibLZMA.cmake | 58 |
2 files changed, 88 insertions, 21 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 93cd74a..e763bab 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -550,6 +550,14 @@ External Project Definition ``LOG_MERGED_STDOUTERR <bool>`` When enabled, the output the step is not split by stdout and stderr. + ``LOG_OUTPUT_ON_FAILURE <bool>`` + This option only has an effect if at least one of the other ``LOG_<step>`` + options is enabled. If an error occurs for a step which has logging to + file enabled, that step's output will be printed to the console if + ``LOG_OUTPUT_ON_FAILURE`` is set to true. For cases where a large amount + of output is recorded, just the end of that output may be printed to the + console. + **Terminal Access Options:** Steps can be given direct access to the terminal in some cases. Giving a step access to the terminal may allow it to receive terminal input if @@ -1953,6 +1961,7 @@ endif() set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake) set(logbase ${log_dir}/${name}-${step}) get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR) + get_property(log_output_on_failure TARGET ${name} PROPERTY _EP_LOG_OUTPUT_ON_FAILURE) if (log_merged) set(stdout_log "${logbase}.log") set(stderr_log "${logbase}.log") @@ -1961,21 +1970,55 @@ endif() set(stderr_log "${logbase}-err.log") endif() set(code " +cmake_minimum_required(VERSION 3.13) ${code_cygpath_make} set(command \"${command}\") +set(log_merged \"${log_merged}\") +set(log_output_on_failure \"${log_output_on_failure}\") +set(stdout_log \"${stdout_log}\") +set(stderr_log \"${stderr_log}\") execute_process( COMMAND \${command} RESULT_VARIABLE result - OUTPUT_FILE \"${stdout_log}\" - ERROR_FILE \"${stderr_log}\" + OUTPUT_FILE \"\${stdout_log}\" + ERROR_FILE \"\${stderr_log}\" ) +macro(read_up_to_max_size log_file output_var) + file(SIZE \${log_file} determined_size) + set(max_size 10240) + if (determined_size GREATER max_size) + math(EXPR seek_position \"\${determined_size} - \${max_size}\") + file(READ \${log_file} \${output_var} OFFSET \${seek_position}) + set(\${output_var} \"...skipping to end...\\n\${\${output_var}}\") + else() + file(READ \${log_file} \${output_var}) + endif() +endmacro() if(result) set(msg \"Command failed: \${result}\\n\") foreach(arg IN LISTS command) set(msg \"\${msg} '\${arg}'\") endforeach() - set(msg \"\${msg}\\nSee also\\n ${stderr_log}\") - message(FATAL_ERROR \"\${msg}\") + if (\${log_merged}) + set(msg \"\${msg}\\nSee also\\n \${stderr_log}\") + else() + set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\") + endif() + if (\${log_output_on_failure}) + message(SEND_ERROR \"\${msg}\") + if (\${log_merged}) + read_up_to_max_size(\"\${stderr_log}\" error_log_contents) + message(STATUS \"Log output is:\\n\${error_log_contents}\") + else() + read_up_to_max_size(\"\${stdout_log}\" out_log_contents) + read_up_to_max_size(\"\${stderr_log}\" err_log_contents) + message(STATUS \"stdout output is:\\n\${out_log_contents}\") + message(STATUS \"stderr output is:\\n\${err_log_contents}\") + endif() + message(FATAL_ERROR \"Stopping after outputting logs.\") + else() + message(FATAL_ERROR \"\${msg}\") + endif() else() set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\") message(STATUS \"\${msg}\") diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index 6d30e57..6225744 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -5,22 +5,40 @@ FindLibLZMA ----------- -Find LibLZMA +Find LZMA compression algorithm headers and library. -Find LibLZMA headers and library -:: +Imported Targets +^^^^^^^^^^^^^^^^ - LIBLZMA_FOUND - True if liblzma is found. - LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located. - LIBLZMA_LIBRARIES - Lzma libraries to link against. - LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required). - LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required). - LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required). - LIBLZMA_VERSION_MAJOR - The major version of lzma - LIBLZMA_VERSION_MINOR - The minor version of lzma - LIBLZMA_VERSION_PATCH - The patch version of lzma - LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3") +This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if +liblzma has been found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``LIBLZMA_FOUND`` + True if liblzma headers and library were found. +``LIBLZMA_INCLUDE_DIRS`` + Directory where liblzma headers are located. +``LIBLZMA_LIBRARIES`` + Lzma libraries to link against. +``LIBLZMA_HAS_AUTO_DECODER`` + True if lzma_auto_decoder() is found (required). +``LIBLZMA_HAS_EASY_ENCODER`` + True if lzma_easy_encoder() is found (required). +``LIBLZMA_HAS_LZMA_PRESET`` + True if lzma_lzma_preset() is found (required). +``LIBLZMA_VERSION_MAJOR`` + The major version of lzma +``LIBLZMA_VERSION_MINOR`` + The minor version of lzma +``LIBLZMA_VERSION_PATCH`` + The patch version of lzma +``LIBLZMA_VERSION_STRING`` + version number as a string (ex: "5.0.3") #]=======================================================================] find_path(LIBLZMA_INCLUDE_DIR lzma.h ) @@ -51,17 +69,23 @@ if (LIBLZMA_LIBRARY) endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZMA REQUIRED_VARS LIBLZMA_INCLUDE_DIR - LIBLZMA_LIBRARY +find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY + LIBLZMA_INCLUDE_DIR LIBLZMA_HAS_AUTO_DECODER LIBLZMA_HAS_EASY_ENCODER LIBLZMA_HAS_LZMA_PRESET VERSION_VAR LIBLZMA_VERSION_STRING ) +mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) if (LIBLZMA_FOUND) set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY}) set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR}) + if(NOT TARGET LibLZMA::LibLZMA) + add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES C + IMPORTED_LOCATION ${LIBLZMA_LIBRARY}) + endif() endif () - -mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) |