summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--Help/command/list.rst3
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/module/FindOctave.rst1
-rw-r--r--Help/prop_sf/OBJECT_OUTPUTS.rst6
-rw-r--r--Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst14
-rw-r--r--Help/release/3.14.rst2
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake11
-rw-r--r--Modules/FindOctave.cmake179
-rw-r--r--Modules/FindThreads.cmake14
-rw-r--r--Source/CMakeLists.txt3
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/Checks/cm_cxx14_check.cpp9
-rw-r--r--Source/Checks/cm_cxx17_check.cpp11
-rw-r--r--Source/cmGeneratorExpressionNode.cxx137
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx158
-rw-r--r--Source/cmGlobalNinjaGenerator.h3
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx4
-rw-r--r--Source/cmMakefile.cxx14
-rw-r--r--Source/cmNinjaTargetGenerator.cxx110
-rw-r--r--Source/cmNinjaTargetGenerator.h4
-rw-r--r--Source/cmQtAutoGen.cxx42
-rw-r--r--Source/cmQtAutoGen.h16
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx6
-rw-r--r--Source/cmQtAutoGenInitializer.h12
-rw-r--r--Source/cmakemain.cxx2
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt4
-rw-r--r--Tests/CompileFeatures/genex_test.cpp4
-rw-r--r--Tests/FindOctave/CMakeLists.txt10
-rw-r--r--Tests/FindOctave/Test/CMakeLists.txt24
-rw-r--r--Tests/FindOctave/Test/interp_main.cpp26
-rw-r--r--Tests/FindOctave/Test/main.cpp18
-rw-r--r--Tests/FindOctave/Test/testtrue.m1
-rw-r--r--Tests/RunCMake/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake4
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake5
-rw-r--r--Tests/RunCMake/list/RunCMakeTest.cmake2
-rw-r--r--Utilities/cmcompress/CMakeLists.txt5
-rw-r--r--Utilities/cmcompress/Copyright.txt34
-rw-r--r--Utilities/cmcompress/cmcompress.c551
-rw-r--r--Utilities/cmcompress/cmcompress.h195
-rw-r--r--Utilities/cmcompress/compress.c.original1308
44 files changed, 371 insertions, 2605 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bd130ec..69e3064 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -445,14 +445,6 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
- # Build Compress library for CTest.
- set(CMAKE_COMPRESS_INCLUDES
- "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
- set(CMAKE_COMPRESS_LIBRARIES "cmcompress")
- add_subdirectory(Utilities/cmcompress)
- CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty")
-
- #---------------------------------------------------------------------
# Build expat library for CMake, CTest, and libarchive.
if(CMAKE_USE_SYSTEM_EXPAT)
find_package(EXPAT)
diff --git a/Help/command/list.rst b/Help/command/list.rst
index 6c86c2a..4444af7 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -196,7 +196,8 @@ Removes items at given indices from the list.
list(REMOVE_DUPLICATES <list>)
-Removes duplicated items in the list.
+Removes duplicated items in the list. The relative order of items is preserved,
+but if duplicates are encountered, only the first instance is preserved.
.. _TRANSFORM:
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 71a8b00..d9b939f 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -178,7 +178,6 @@ They are normally called through the :command:`find_package` command.
/module/FindMPEG2
/module/FindMPEG
/module/FindMPI
- /module/FindOctave
/module/FindODBC
/module/FindOpenACC
/module/FindOpenAL
diff --git a/Help/module/FindOctave.rst b/Help/module/FindOctave.rst
deleted file mode 100644
index 2dbcec4..0000000
--- a/Help/module/FindOctave.rst
+++ /dev/null
@@ -1 +0,0 @@
-.. cmake-module:: ../../Modules/FindOctave.cmake
diff --git a/Help/prop_sf/OBJECT_OUTPUTS.rst b/Help/prop_sf/OBJECT_OUTPUTS.rst
index 6a28553..1ce4866 100644
--- a/Help/prop_sf/OBJECT_OUTPUTS.rst
+++ b/Help/prop_sf/OBJECT_OUTPUTS.rst
@@ -1,9 +1,9 @@
OBJECT_OUTPUTS
--------------
-Additional outputs for a Makefile rule.
+Additional outputs for a Ninja or Makefile rule.
Additional outputs created by compilation of this source file. If any
of these outputs is missing the object will be recompiled. This is
-supported only on Makefile generators and will be ignored on other
-generators.
+supported only on the Ninja and Makefile generators and will be ignored on
+other generators.
diff --git a/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
index 511de7a..3378797 100644
--- a/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
+++ b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
@@ -8,14 +8,14 @@ This property is initialized by the value of the variable
On platforms that support runtime paths (``RPATH``) with the
``$ORIGIN`` token, setting this property to ``TRUE`` enables relative
-paths in the build ``RPATH`` for executables that point to shared
-libraries in the same build tree.
+paths in the build ``RPATH`` for executables and shared libraries that
+point to shared libraries in the same build tree.
-Normally the build ``RPATH`` of an executable contains absolute paths
-to the directory of shared libraries. Directories contained within the
-build tree can be made relative to enable relocatable builds and to
-help achieving reproducible builds by omitting the build directory
-from the build environment.
+Normally the build ``RPATH`` of a binary contains absolute paths
+to the directory of each shared library it links to. The ``RPATH``
+entries for directories contained within the build tree can be made
+relative to enable relocatable builds and to help achieve reproducible
+builds by omitting the build directory from the build environment.
This property has no effect on platforms that do not support the
``$ORIGIN`` token in ``RPATH``, or when the :variable:`CMAKE_SKIP_RPATH`
diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst
index 0246071..e4b4d38 100644
--- a/Help/release/3.14.rst
+++ b/Help/release/3.14.rst
@@ -216,8 +216,6 @@ Modules
mirror the new options to the ``mex`` command in MATLAB R2018a.
The option ``MX_LIBRARY`` is no longer needed.
-* A :module:`FindOctave` module was added to find GNU octave.
-
* The :module:`FindPostgreSQL` module now provides imported targets.
* The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3`
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 8ba4246..59dab6d 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -181,7 +181,10 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(vs_version ${CMAKE_MATCH_1})
set(id_platform ${CMAKE_VS_PLATFORM_NAME})
set(id_lang "${lang}")
- if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
+ set(id_PostBuildEvent_Command "")
+ if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm]$")
+ set(id_cl_var "ClangClExecutable")
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
set(id_cl clang.exe)
else()
set(id_cl cl.exe)
@@ -268,7 +271,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
set(id_src "${src}")
set(id_compile "ClCompile")
- set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
+ if(id_cl_var)
+ set(id_PostBuildEvent_Command "echo CMAKE_${lang}_COMPILER=$(${id_cl_var})")
+ else()
+ set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
+ endif()
set(id_Import_props "")
set(id_Import_targets "")
set(id_ItemDefinitionGroup_entry "")
diff --git a/Modules/FindOctave.cmake b/Modules/FindOctave.cmake
deleted file mode 100644
index 8110ff1..0000000
--- a/Modules/FindOctave.cmake
+++ /dev/null
@@ -1,179 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#[=======================================================================[.rst:
-FindOctave
-----------
-
-Finds GNU Octave interpreter, libraries and compilers.
-
-Imported targets
-^^^^^^^^^^^^^^^^
-
-This module defines the following :prop_tgt:`IMPORTED` targets:
-
-``Octave::Interpreter``
- Octave interpreter (the main program)
-``Octave::Octave``
- include directories and the octave library
-``Octave::Octinterp``
- include directories and the octinterp library including the dependency on
- Octave::Octave
-
-If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
-
-Result Variables
-^^^^^^^^^^^^^^^^
-
-``Octave_FOUND``
- Octave interpreter and/or libraries were found
-``Octave_<component>_FOUND``
- Octave <component> specified was found
-
-``Octave_EXECUTABLE``
- Octave interpreter
-``Octave_INCLUDE_DIRS``
- include path for mex.h
-``Octave_LIBRARIES``
- octinterp, octave libraries
-
-
-Cache variables
-^^^^^^^^^^^^^^^
-
-The following cache variables may also be set:
-
-``Octave_INTERP_LIBRARY``
- path to the library octinterp
-``Octave_OCTAVE_LIBRARY``
- path to the liboctave library
-
-#]=======================================================================]
-
-cmake_policy(VERSION 3.3)
-
-unset(Octave_REQUIRED_VARS)
-unset(Octave_Development_FOUND)
-unset(Octave_Interpreter_FOUND)
-set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME Interpreter)
-
-if(Development IN_LIST Octave_FIND_COMPONENTS)
- find_program(Octave_CONFIG_EXECUTABLE
- NAMES octave-config)
-
- if(Octave_CONFIG_EXECUTABLE)
-
- execute_process(COMMAND ${Octave_CONFIG_EXECUTABLE} -p BINDIR
- OUTPUT_VARIABLE Octave_BINARY_DIR
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- execute_process(COMMAND ${Octave_CONFIG_EXECUTABLE} -p OCTINCLUDEDIR
- OUTPUT_VARIABLE Octave_INCLUDE_DIR
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- list(APPEND Octave_REQUIRED_VARS ${Octave_INCLUDE_DIR})
-
- execute_process(COMMAND ${Octave_CONFIG_EXECUTABLE} -p OCTLIBDIR
- OUTPUT_VARIABLE Octave_LIB1
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- execute_process(COMMAND ${Octave_CONFIG_EXECUTABLE} -p LIBDIR
- OUTPUT_VARIABLE Octave_LIB2
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- find_library(Octave_INTERP_LIBRARY
- NAMES octinterp
- PATHS ${Octave_LIB1} ${Octave_LIB2}
- NO_DEFAULT_PATH
- )
- find_library(Octave_OCTAVE_LIBRARY
- NAMES octave
- PATHS ${Octave_LIB1} ${Octave_LIB2}
- NO_DEFAULT_PATH
- )
- list(APPEND Octave_REQUIRED_VARS ${Octave_OCTAVE_LIBRARY} ${Octave_INTERP_LIBRARY})
-
- if(Octave_REQUIRED_VARS)
- set(Octave_Development_FOUND true)
- endif()
- endif(Octave_CONFIG_EXECUTABLE)
-endif()
-
-if(Interpreter IN_LIST Octave_FIND_COMPONENTS)
-
- find_program(Octave_EXECUTABLE
- NAMES octave)
-
- list(APPEND Octave_REQUIRED_VARS ${Octave_EXECUTABLE})
-
-endif()
-
-if(Octave_EXECUTABLE)
- execute_process(COMMAND ${Octave_EXECUTABLE} -v
- OUTPUT_VARIABLE Octave_VERSION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-
- string(REGEX REPLACE "GNU Octave, version ([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" Octave_VERSION_MAJOR ${Octave_VERSION})
- string(REGEX REPLACE "GNU Octave, version [0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" Octave_VERSION_MINOR ${Octave_VERSION})
- string(REGEX REPLACE "GNU Octave, version [0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Octave_VERSION_PATCH ${Octave_VERSION})
-
- set(Octave_VERSION ${Octave_VERSION_MAJOR}.${Octave_VERSION_MINOR}.${Octave_VERSION_PATCH})
-
- set(Octave_Interpreter_FOUND true)
-
-endif(Octave_EXECUTABLE)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Octave
- REQUIRED_VARS Octave_REQUIRED_VARS
- VERSION_VAR Octave_VERSION
- HANDLE_COMPONENTS)
-
-
-if(Octave_Development_FOUND)
- set(Octave_LIBRARIES ${Octave_INTERP_LIBRARY} ${Octave_OCTAVE_LIBRARY})
- set(Octave_INCLUDE_DIRS ${Octave_INCLUDE_DIR})
-
- if(NOT TARGET Octave::Octave)
- add_library(Octave::Octave UNKNOWN IMPORTED)
- set_target_properties(Octave::Octave PROPERTIES
- IMPORTED_LOCATION ${Octave_OCTAVE_LIBRARY}
- INTERFACE_INCLUDE_DIRECTORIES ${Octave_INCLUDE_DIR}
- )
- endif()
-
- if(NOT TARGET Octave::Octinterp)
- add_library(Octave::Octinterp UNKNOWN IMPORTED)
- set_target_properties(Octave::Octinterp PROPERTIES
- IMPORTED_LOCATION ${Octave_INTERP_LIBRARY}
- INTERFACE_INCLUDE_DIRECTORIES ${Octave_INCLUDE_DIR})
- target_link_libraries(Octave::Octinterp INTERFACE
- Octave::Octave)
- endif()
-
-endif()
-
-
-if(Octave_Interpreter_FOUND)
- if(NOT TARGET Octave::Interpreter)
- add_executable(Octave::Interpreter IMPORTED)
- set_target_properties(Octave::Interpreter PROPERTIES
- IMPORTED_LOCATION ${Octave_EXECUTABLE}
- VERSION ${Octave_VERSION})
- endif()
-endif()
-
-mark_as_advanced(
- Octave_CONFIG_EXECUTABLE
- Octave_INTERP_LIBRARY
- Octave_OCTAVE_LIBRARY
- Octave_INCLUDE_DIR
- Octave_VERSION_MAJOR
- Octave_VERSION_MINOR
- Octave_VERSION_PATCH
-)
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 5d894c8..919392a 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -118,16 +118,8 @@ if(CMAKE_HAVE_PTHREAD_H)
set(CMAKE_HAVE_THREADS_LIBRARY)
if(NOT THREADS_HAVE_PTHREAD_ARG)
# Check if pthread functions are in normal C library.
- # If the pthread functions already exist in C library, we could just use
- # them instead of linking to the additional pthread library. We could
- # try to check any pthread symbol name, but here is an exception. If we
- # use clang asan build, we will find the pthread_create() symbol in the
- # libc(libasan). However, it doesn't have the full pthread implementation.
- # So, we can't assume that we have the pthread implementation in libc
- # using the pthread_create() checking here. Then, we turn to check the
- # pthread_kill() symbol instead.
- CHECK_SYMBOL_EXISTS(pthread_kill pthread.h CMAKE_HAVE_LIBC_PTHREAD_KILL)
- if(CMAKE_HAVE_LIBC_PTHREAD_KILL)
+ CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
+ if(CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
@@ -152,7 +144,7 @@ if(CMAKE_HAVE_PTHREAD_H)
_check_pthreads_flag()
endif()
-if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_PTHREAD_KILL)
+if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 663d42e..2db276d 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -92,7 +92,6 @@ include_directories(
${CMAKE_ZLIB_INCLUDES}
${CMAKE_EXPAT_INCLUDES}
${CMAKE_TAR_INCLUDES}
- ${CMAKE_COMPRESS_INCLUDES}
${CMake_HAIKU_INCLUDE_DIRS}
)
@@ -801,7 +800,7 @@ endforeach()
add_library(CMakeLib ${SRCS})
target_link_libraries(CMakeLib cmsys
${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
- ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
+ ${CMAKE_TAR_LIBRARIES}
${CMAKE_CURL_LIBRARIES}
${CMAKE_JSONCPP_LIBRARIES}
${CMAKE_LIBUV_LIBRARIES}
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 268efa5..a6ae1fe 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 14)
-set(CMake_VERSION_PATCH 20190226)
+set(CMake_VERSION_PATCH 20190228)
#set(CMake_VERSION_RC 1)
diff --git a/Source/Checks/cm_cxx14_check.cpp b/Source/Checks/cm_cxx14_check.cpp
index 9369ba2..fff36c9 100644
--- a/Source/Checks/cm_cxx14_check.cpp
+++ b/Source/Checks/cm_cxx14_check.cpp
@@ -1,8 +1,15 @@
#include <cstdio>
+#include <iterator>
#include <memory>
int main()
{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
std::unique_ptr<int> u(new int(0));
- return *u;
+ return *u + *ai + *(bi - 1);
}
diff --git a/Source/Checks/cm_cxx17_check.cpp b/Source/Checks/cm_cxx17_check.cpp
index 2de10d6..593d9b2 100644
--- a/Source/Checks/cm_cxx17_check.cpp
+++ b/Source/Checks/cm_cxx17_check.cpp
@@ -1,4 +1,5 @@
#include <cstdio>
+#include <iterator>
#include <memory>
#include <unordered_map>
@@ -8,6 +9,14 @@
int main()
{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
+ auto ci = std::size(a);
+
std::unique_ptr<int> u(new int(0));
#ifdef _MSC_VER
@@ -18,5 +27,5 @@ int main()
IDispatchPtr disp(ptr);
#endif
- return *u;
+ return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci));
}
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 49a5fcd..ce308cc 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -2058,75 +2058,76 @@ static const struct ShellPathNode : public cmGeneratorExpressionNode
const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
const std::string& identifier)
{
- typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
- static NodeMap nodeMap;
- if (nodeMap.empty()) {
- nodeMap["0"] = &zeroNode;
- nodeMap["1"] = &oneNode;
- nodeMap["AND"] = &andNode;
- nodeMap["OR"] = &orNode;
- nodeMap["NOT"] = &notNode;
- nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
- nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
- nodeMap["Fortran_COMPILER_ID"] = &fortranCompilerIdNode;
- nodeMap["VERSION_GREATER"] = &versionGreaterNode;
- nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode;
- nodeMap["VERSION_LESS"] = &versionLessNode;
- nodeMap["VERSION_LESS_EQUAL"] = &versionLessEqNode;
- nodeMap["VERSION_EQUAL"] = &versionEqualNode;
- nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
- nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
- nodeMap["Fortran_COMPILER_VERSION"] = &fortranCompilerVersionNode;
- nodeMap["PLATFORM_ID"] = &platformIdNode;
- nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
- nodeMap["CONFIGURATION"] = &configurationNode;
- nodeMap["CONFIG"] = &configurationTestNode;
- nodeMap["TARGET_FILE"] = &targetNodeGroup.File;
- nodeMap["TARGET_LINKER_FILE"] = &targetLinkerNodeGroup.File;
- nodeMap["TARGET_SONAME_FILE"] = &targetSoNameNodeGroup.File;
- nodeMap["TARGET_PDB_FILE"] = &targetPdbNodeGroup.File;
- nodeMap["TARGET_FILE_NAME"] = &targetNodeGroup.FileName;
- nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerNodeGroup.FileName;
- nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameNodeGroup.FileName;
- nodeMap["TARGET_PDB_FILE_NAME"] = &targetPdbNodeGroup.FileName;
- nodeMap["TARGET_FILE_DIR"] = &targetNodeGroup.FileDir;
- nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir;
- nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir;
- nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir;
- nodeMap["TARGET_BUNDLE_DIR"] = &targetBundleDirNode;
- nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode;
- nodeMap["STREQUAL"] = &strEqualNode;
- nodeMap["EQUAL"] = &equalNode;
- nodeMap["IN_LIST"] = &inListNode;
- nodeMap["LOWER_CASE"] = &lowerCaseNode;
- nodeMap["UPPER_CASE"] = &upperCaseNode;
- nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
- nodeMap["BOOL"] = &boolNode;
- nodeMap["IF"] = &ifNode;
- nodeMap["ANGLE-R"] = &angle_rNode;
- nodeMap["COMMA"] = &commaNode;
- nodeMap["SEMICOLON"] = &semicolonNode;
- nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
- nodeMap["TARGET_NAME"] = &targetNameNode;
- nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
- nodeMap["TARGET_POLICY"] = &targetPolicyNode;
- nodeMap["TARGET_EXISTS"] = &targetExistsNode;
- nodeMap["TARGET_NAME_IF_EXISTS"] = &targetNameIfExistsNode;
- nodeMap["TARGET_GENEX_EVAL"] = &targetGenexEvalNode;
- nodeMap["GENEX_EVAL"] = &genexEvalNode;
- nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
- nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
- nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
- nodeMap["JOIN"] = &joinNode;
- nodeMap["LINK_ONLY"] = &linkOnlyNode;
- nodeMap["COMPILE_LANGUAGE"] = &languageNode;
- nodeMap["SHELL_PATH"] = &shellPathNode;
- }
- NodeMap::const_iterator i = nodeMap.find(identifier);
- if (i == nodeMap.end()) {
- return nullptr;
+ static std::map<std::string, cmGeneratorExpressionNode const*> const nodeMap{
+ { "0", &zeroNode },
+ { "1", &oneNode },
+ { "AND", &andNode },
+ { "OR", &orNode },
+ { "NOT", &notNode },
+ { "C_COMPILER_ID", &cCompilerIdNode },
+ { "CXX_COMPILER_ID", &cxxCompilerIdNode },
+ { "Fortran_COMPILER_ID", &fortranCompilerIdNode },
+ { "VERSION_GREATER", &versionGreaterNode },
+ { "VERSION_GREATER_EQUAL", &versionGreaterEqNode },
+ { "VERSION_LESS", &versionLessNode },
+ { "VERSION_LESS_EQUAL", &versionLessEqNode },
+ { "VERSION_EQUAL", &versionEqualNode },
+ { "C_COMPILER_VERSION", &cCompilerVersionNode },
+ { "CXX_COMPILER_VERSION", &cxxCompilerVersionNode },
+ { "Fortran_COMPILER_VERSION", &fortranCompilerVersionNode },
+ { "PLATFORM_ID", &platformIdNode },
+ { "COMPILE_FEATURES", &compileFeaturesNode },
+ { "CONFIGURATION", &configurationNode },
+ { "CONFIG", &configurationTestNode },
+ { "TARGET_FILE", &targetNodeGroup.File },
+ { "TARGET_LINKER_FILE", &targetLinkerNodeGroup.File },
+ { "TARGET_SONAME_FILE", &targetSoNameNodeGroup.File },
+ { "TARGET_PDB_FILE", &targetPdbNodeGroup.File },
+ { "TARGET_FILE_NAME", &targetNodeGroup.FileName },
+ { "TARGET_LINKER_FILE_NAME", &targetLinkerNodeGroup.FileName },
+ { "TARGET_SONAME_FILE_NAME", &targetSoNameNodeGroup.FileName },
+ { "TARGET_PDB_FILE_NAME", &targetPdbNodeGroup.FileName },
+ { "TARGET_FILE_DIR", &targetNodeGroup.FileDir },
+ { "TARGET_LINKER_FILE_DIR", &targetLinkerNodeGroup.FileDir },
+ { "TARGET_SONAME_FILE_DIR", &targetSoNameNodeGroup.FileDir },
+ { "TARGET_PDB_FILE_DIR", &targetPdbNodeGroup.FileDir },
+ { "TARGET_BUNDLE_DIR", &targetBundleDirNode },
+ { "TARGET_BUNDLE_CONTENT_DIR", &targetBundleContentDirNode },
+ { "STREQUAL", &strEqualNode },
+ { "EQUAL", &equalNode },
+ { "IN_LIST", &inListNode },
+ { "LOWER_CASE", &lowerCaseNode },
+ { "UPPER_CASE", &upperCaseNode },
+ { "MAKE_C_IDENTIFIER", &makeCIdentifierNode },
+ { "BOOL", &boolNode },
+ { "IF", &ifNode },
+ { "ANGLE-R", &angle_rNode },
+ { "COMMA", &commaNode },
+ { "SEMICOLON", &semicolonNode },
+ { "TARGET_PROPERTY", &targetPropertyNode },
+ { "TARGET_NAME", &targetNameNode },
+ { "TARGET_OBJECTS", &targetObjectsNode },
+ { "TARGET_POLICY", &targetPolicyNode },
+ { "TARGET_EXISTS", &targetExistsNode },
+ { "TARGET_NAME_IF_EXISTS", &targetNameIfExistsNode },
+ { "TARGET_GENEX_EVAL", &targetGenexEvalNode },
+ { "GENEX_EVAL", &genexEvalNode },
+ { "BUILD_INTERFACE", &buildInterfaceNode },
+ { "INSTALL_INTERFACE", &installInterfaceNode },
+ { "INSTALL_PREFIX", &installPrefixNode },
+ { "JOIN", &joinNode },
+ { "LINK_ONLY", &linkOnlyNode },
+ { "COMPILE_LANGUAGE", &languageNode },
+ { "SHELL_PATH", &shellPathNode }
+ };
+
+ {
+ auto itr = nodeMap.find(identifier);
+ if (itr != nodeMap.end()) {
+ return itr->second;
+ }
}
- return i->second;
+ return nullptr;
}
void reportError(cmGeneratorExpressionContext* context,
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 018606c..d21fd35 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1574,12 +1574,13 @@ Compilation of source files within a target is split into the following steps:
command = gfortran -cpp $DEFINES $INCLUDES $FLAGS -E $in -o $out &&
cmake -E cmake_ninja_depends \
--tdi=FortranDependInfo.json --pp=$out --dep=$DEP_FILE \
- --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE
+ --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE \
+ --lang=Fortran
- build src.f90-pp.f90 | src.f90-pp.f90.ddi: Fortran_PREPROCESS src.f90
+ build src.f90-pp.f90 | src.f90.o.ddi: Fortran_PREPROCESS src.f90
OBJ_FILE = src.f90.o
- DEP_FILE = src.f90-pp.f90.d
- DYNDEP_INTERMEDIATE_FILE = src.f90-pp.f90.ddi
+ DEP_FILE = src.f90.o.d
+ DYNDEP_INTERMEDIATE_FILE = src.f90.o.ddi
The ``cmake -E cmake_ninja_depends`` tool reads the preprocessed output
and generates the ninja depfile for preprocessor dependencies. It also
@@ -1593,9 +1594,9 @@ Compilation of source files within a target is split into the following steps:
rule Fortran_DYNDEP
command = cmake -E cmake_ninja_dyndep \
- --tdi=FortranDependInfo.json --dd=$out $in
+ --tdi=FortranDependInfo.json --lang=Fortran --dd=$out $in
- build Fortran.dd: Fortran_DYNDEP src1.f90-pp.f90.ddi src2.f90-pp.f90.ddi
+ build Fortran.dd: Fortran_DYNDEP src1.f90.o.ddi src2.f90.o.ddi
The ``cmake -E cmake_ninja_dyndep`` tool reads the "ddi" files from all
sources in the target and the ``FortranModules.json`` files from targets
@@ -1633,6 +1634,19 @@ Compilation of source files within a target is split into the following steps:
(because the latter consumes the module).
*/
+struct cmSourceInfo
+{
+ // Set of provided and required modules.
+ std::set<std::string> Provides;
+ std::set<std::string> Requires;
+
+ // Set of files included in the translation unit.
+ std::set<std::string> Includes;
+};
+
+static std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp);
+
int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string>::const_iterator argEnd)
{
@@ -1641,6 +1655,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::string arg_dep;
std::string arg_obj;
std::string arg_ddi;
+ std::string arg_lang;
for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
@@ -1652,6 +1667,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
arg_obj = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--ddi=")) {
arg_ddi = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--lang=")) {
+ arg_lang = arg.substr(7);
} else {
cmSystemTools::Error("-E cmake_ninja_depends unknown argument: " + arg);
return 1;
@@ -1677,7 +1694,61 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_depends requires value for --ddi=");
return 1;
}
+ if (arg_lang.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_depends requires value for --lang=");
+ return 1;
+ }
+
+ std::unique_ptr<cmSourceInfo> info;
+ if (arg_lang == "Fortran") {
+ info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_pp);
+ } else {
+ cmSystemTools::Error("-E cmake_ninja_depends does not understand the " +
+ arg_lang + " language");
+ return 1;
+ }
+
+ if (!info) {
+ // The error message is already expected to have been output.
+ return 1;
+ }
+
+ {
+ cmGeneratedFileStream depfile(arg_dep);
+ depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
+ for (std::string const& include : info->Includes) {
+ depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
+ }
+ depfile << "\n";
+ }
+
+ Json::Value ddi(Json::objectValue);
+ ddi["object"] = arg_obj;
+ Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
+ for (std::string const& provide : info->Provides) {
+ ddi_provides.append(provide);
+ }
+ Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
+ for (std::string const& r : info->Requires) {
+ // Require modules not provided in the same source.
+ if (!info->Provides.count(r)) {
+ ddi_requires.append(r);
+ }
+ }
+
+ cmGeneratedFileStream ddif(arg_ddi);
+ ddif << ddi;
+ if (!ddif) {
+ cmSystemTools::Error("-E cmake_ninja_depends failed to write " + arg_ddi);
+ return 1;
+ }
+ return 0;
+}
+
+std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp)
+{
cmFortranCompiler fc;
std::vector<std::string> includes;
{
@@ -1689,7 +1760,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
if (!reader.parse(tdif, tdio, false)) {
cmSystemTools::Error("-E cmake_ninja_depends failed to parse " +
arg_tdi + reader.getFormattedErrorMessages());
- return 1;
+ return nullptr;
}
}
@@ -1710,52 +1781,26 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
fc.SModExt = tdi_submodule_ext.asString();
}
- cmFortranSourceInfo info;
+ cmFortranSourceInfo finfo;
std::set<std::string> defines;
- cmFortranParser parser(fc, includes, defines, info);
+ cmFortranParser parser(fc, includes, defines, finfo);
if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
cmSystemTools::Error("-E cmake_ninja_depends failed to open " + arg_pp);
- return 1;
+ return nullptr;
}
if (cmFortran_yyparse(parser.Scanner) != 0) {
// Failed to parse the file.
- return 1;
+ return nullptr;
}
- {
- cmGeneratedFileStream depfile(arg_dep);
- depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
- for (std::string const& include : info.Includes) {
- depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
- }
- depfile << "\n";
- }
-
- Json::Value ddi(Json::objectValue);
- ddi["object"] = arg_obj;
-
- Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
- for (std::string const& provide : info.Provides) {
- ddi_provides.append(provide);
- }
- Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
- for (std::string const& r : info.Requires) {
- // Require modules not provided in the same source.
- if (!info.Provides.count(r)) {
- ddi_requires.append(r);
- }
- }
-
- cmGeneratedFileStream ddif(arg_ddi);
- ddif << ddi;
- if (!ddif) {
- cmSystemTools::Error("-E cmake_ninja_depends failed to write " + arg_ddi);
- return 1;
- }
- return 0;
+ auto info = cm::make_unique<cmSourceInfo>();
+ info->Provides = finfo.Provides;
+ info->Requires = finfo.Requires;
+ info->Includes = finfo.Includes;
+ return info;
}
-struct cmFortranObjectInfo
+struct cmDyndepObjectInfo
{
std::string Object;
std::vector<std::string> Provides;
@@ -1767,7 +1812,8 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
std::string const& dir_cur_src, std::string const& dir_cur_bld,
std::string const& arg_dd, std::vector<std::string> const& arg_ddis,
std::string const& module_dir,
- std::vector<std::string> const& linked_target_dirs)
+ std::vector<std::string> const& linked_target_dirs,
+ std::string const& arg_lang)
{
// Setup path conversions.
{
@@ -1784,7 +1830,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
this->LocalGenerators.push_back(lgd.release());
}
- std::vector<cmFortranObjectInfo> objects;
+ std::vector<cmDyndepObjectInfo> objects;
for (std::string const& arg_ddi : arg_ddis) {
// Load the ddi file and compute the module file paths it provides.
Json::Value ddio;
@@ -1797,7 +1843,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
return false;
}
- cmFortranObjectInfo info;
+ cmDyndepObjectInfo info;
info.Object = ddi["object"].asString();
Json::Value const& ddi_provides = ddi["provides"];
if (ddi_provides.isArray()) {
@@ -1819,7 +1865,8 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// Populate the module map with those provided by linked targets first.
for (std::string const& linked_target_dir : linked_target_dirs) {
- std::string const ltmn = linked_target_dir + "/FortranModules.json";
+ std::string const ltmn =
+ linked_target_dir + "/" + arg_lang + "Modules.json";
Json::Value ltm;
cmsys::ifstream ltmf(ltmn.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
@@ -1840,7 +1887,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// We do this after loading the modules provided by linked targets
// in case we have one of the same name that must be preferred.
Json::Value tm = Json::objectValue;
- for (cmFortranObjectInfo const& object : objects) {
+ for (cmDyndepObjectInfo const& object : objects) {
for (std::string const& p : object.Provides) {
std::string const mod = module_dir + p;
mod_files[p] = mod;
@@ -1851,7 +1898,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
cmGeneratedFileStream ddf(arg_dd);
ddf << "ninja_dyndep_version = 1.0\n";
- for (cmFortranObjectInfo const& object : objects) {
+ for (cmDyndepObjectInfo const& object : objects) {
std::string const ddComment;
std::string const ddRule = "dyndep";
cmNinjaDeps ddOutputs;
@@ -1882,7 +1929,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// Store the map of modules provided by this target in a file for
// use by dependents that reference this target in linked-target-dirs.
std::string const target_mods_file =
- cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json";
+ cmSystemTools::GetFilenamePath(arg_dd) + "/" + arg_lang + "Modules.json";
cmGeneratedFileStream tmf(target_mods_file);
tmf << tm;
@@ -1896,11 +1943,14 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::HandleResponseFile(argBeg, argEnd);
std::string arg_dd;
+ std::string arg_lang;
std::string arg_tdi;
std::vector<std::string> arg_ddis;
for (std::string const& arg : arg_full) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--lang=")) {
+ arg_lang = arg.substr(7);
} else if (cmHasLiteralPrefix(arg, "--dd=")) {
arg_dd = arg.substr(5);
} else if (!cmHasLiteralPrefix(arg, "--") &&
@@ -1915,6 +1965,10 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --tdi=");
return 1;
}
+ if (arg_lang.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --lang=");
+ return 1;
+ }
if (arg_dd.empty()) {
cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --dd=");
return 1;
@@ -1955,8 +2009,8 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja")));
if (!ggd ||
!ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld,
- arg_dd, arg_ddis, module_dir,
- linked_target_dirs)) {
+ arg_dd, arg_ddis, module_dir, linked_target_dirs,
+ arg_lang)) {
return 1;
}
return 0;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index c619e67..69210ec 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -365,7 +365,8 @@ public:
std::string const& arg_dd,
std::vector<std::string> const& arg_ddis,
std::string const& module_dir,
- std::vector<std::string> const& linked_target_dirs);
+ std::vector<std::string> const& linked_target_dirs,
+ std::string const& arg_lang);
protected:
void Generate() override;
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index b224d09..93134ad 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -85,10 +85,12 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(
// Create a target instance for this utility.
cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY,
utility_name.c_str());
+ if (this->Makefile->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
- target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
if (!customType.empty())
target->SetProperty("VS_PROJECT_TYPE", customType.c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a0b09da..ab37774 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4725,6 +4725,13 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
needCxx17, needCxx20);
const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
+ if (existingCxxStandard == nullptr) {
+ const char* defaultCxxStandard =
+ this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ if (defaultCxxStandard && *defaultCxxStandard) {
+ existingCxxStandard = defaultCxxStandard;
+ }
+ }
const char* const* existingCxxLevel = nullptr;
if (existingCxxStandard) {
existingCxxLevel =
@@ -4827,6 +4834,13 @@ bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
const char* existingCStandard = target->GetProperty("C_STANDARD");
+ if (existingCStandard == nullptr) {
+ const char* defaultCStandard =
+ this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ if (defaultCStandard && *defaultCStandard) {
+ existingCStandard = defaultCStandard;
+ }
+ }
if (existingCStandard) {
if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
cmStrCmp(existingCStandard)) == cm::cend(C_STANDARDS)) {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 6013cd0..8d11408 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -102,6 +102,12 @@ bool cmNinjaTargetGenerator::NeedExplicitPreprocessing(
return lang == "Fortran";
}
+bool cmNinjaTargetGenerator::UsePreprocessedSource(
+ std::string const& lang) const
+{
+ return lang == "Fortran";
+}
+
std::string cmNinjaTargetGenerator::LanguageDyndepRule(
const std::string& lang) const
{
@@ -558,7 +564,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
cmake +
" -E cmake_ninja_depends"
" --tdi=" +
- tdi +
+ tdi + " --lang=" + lang +
" --pp=$out"
" --dep=$DEP_FILE" +
(needDyndep ? " --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE" : ""));
@@ -588,13 +594,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
std::string ddRspContent = "$in";
std::string ddInput = "@" + ddRspFile;
- // Run CMake dependency scanner on preprocessed output.
+ // Run CMake dependency scanner on the source file (using the preprocessed
+ // source if that was performed).
std::string const cmake = this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
ddCmds.push_back(cmake +
" -E cmake_ninja_dyndep"
" --tdi=" +
- tdi +
+ tdi + " --lang=" + lang +
" --dd=$out"
" " +
ddInput);
@@ -868,24 +875,27 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
this->WriteObjectBuildStatement(sf);
}
- if (!this->DDIFiles.empty()) {
+ for (auto const& langDDIFiles : this->DDIFiles) {
+ std::string const& language = langDDIFiles.first;
+ cmNinjaDeps const& ddiFiles = langDDIFiles.second;
+
std::string const ddComment;
- std::string const ddRule = this->LanguageDyndepRule("Fortran");
+ std::string const ddRule = this->LanguageDyndepRule(language);
cmNinjaDeps ddOutputs;
cmNinjaDeps ddImplicitOuts;
- cmNinjaDeps const& ddExplicitDeps = this->DDIFiles;
+ cmNinjaDeps const& ddExplicitDeps = ddiFiles;
cmNinjaDeps ddImplicitDeps;
cmNinjaDeps ddOrderOnlyDeps;
cmNinjaVars ddVars;
- this->WriteTargetDependInfo("Fortran");
+ this->WriteTargetDependInfo(language);
- ddOutputs.push_back(this->GetDyndepFilePath("Fortran"));
+ ddOutputs.push_back(this->GetDyndepFilePath(language));
// Make sure dyndep files for all our dependencies have already
- // been generated so that the 'FortranModules.json' files they
+ // been generated so that the '<LANG>Modules.json' files they
// produced as side-effects are available for us to read.
- // Ideally we should depend on the 'FortranModules.json' files
+ // Ideally we should depend on the '<LANG>Modules.json' files
// from our dependencies directly, but we don't know which of
// our dependencies produces them. Fixing this will require
// refactoring the Ninja generator to generate targets in
@@ -1032,6 +1042,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// For some cases we do an explicit preprocessor invocation.
bool const explicitPP = this->NeedExplicitPreprocessing(language);
if (explicitPP) {
+ bool const compilePP = this->UsePreprocessedSource(language);
std::string const ppComment;
std::string const ppRule = this->LanguagePreprocessRule(language);
cmNinjaDeps ppOutputs;
@@ -1045,61 +1056,80 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->ConvertToNinjaPath(this->GetPreprocessedFilePath(source));
ppOutputs.push_back(ppFileName);
- // Move compilation dependencies to the preprocessing build statement.
- std::swap(ppExplicitDeps, explicitDeps);
- std::swap(ppImplicitDeps, implicitDeps);
- std::swap(ppOrderOnlyDeps, orderOnlyDeps);
- std::swap(ppVars["IN_ABS"], vars["IN_ABS"]);
+ if (compilePP) {
+ // Move compilation dependencies to the preprocessing build statement.
+ std::swap(ppExplicitDeps, explicitDeps);
+ std::swap(ppImplicitDeps, implicitDeps);
+ std::swap(ppOrderOnlyDeps, orderOnlyDeps);
+ std::swap(ppVars["IN_ABS"], vars["IN_ABS"]);
- // The actual compilation will now use the preprocessed source.
- explicitDeps.push_back(ppFileName);
+ // The actual compilation will now use the preprocessed source.
+ explicitDeps.push_back(ppFileName);
+ } else {
+ // Copy compilation dependencies to the preprocessing build statement.
+ ppExplicitDeps = explicitDeps;
+ ppImplicitDeps = implicitDeps;
+ ppOrderOnlyDeps = orderOnlyDeps;
+ ppVars["IN_ABS"] = vars["IN_ABS"];
+ }
// Preprocessing and compilation generally use the same flags.
ppVars["FLAGS"] = vars["FLAGS"];
- // In case compilation requires flags that are incompatible with
- // preprocessing, include them here.
- std::string const postFlag =
- this->Makefile->GetSafeDefinition("CMAKE_Fortran_POSTPROCESS_FLAG");
- this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
+ if (compilePP) {
+ // In case compilation requires flags that are incompatible with
+ // preprocessing, include them here.
+ std::string const postFlag = this->Makefile->GetSafeDefinition(
+ "CMAKE_" + language + "_POSTPROCESS_FLAG");
+ this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
+ }
- // Move preprocessor definitions to the preprocessor build statement.
- std::swap(ppVars["DEFINES"], vars["DEFINES"]);
+ if (compilePP) {
+ // Move preprocessor definitions to the preprocessor build statement.
+ std::swap(ppVars["DEFINES"], vars["DEFINES"]);
+ } else {
+ // Copy preprocessor definitions to the preprocessor build statement.
+ ppVars["DEFINES"] = vars["DEFINES"];
+ }
// Copy include directories to the preprocessor build statement. The
// Fortran compilation build statement still needs them for the INCLUDE
// directive.
ppVars["INCLUDES"] = vars["INCLUDES"];
- // Prepend source file's original directory as an include directory
- // so e.g. Fortran INCLUDE statements can look for files in it.
- std::vector<std::string> sourceDirectory;
- sourceDirectory.push_back(
- cmSystemTools::GetParentDirectory(source->GetFullPath()));
+ if (compilePP) {
+ // Prepend source file's original directory as an include directory
+ // so e.g. Fortran INCLUDE statements can look for files in it.
+ std::vector<std::string> sourceDirectory;
+ sourceDirectory.push_back(
+ cmSystemTools::GetParentDirectory(source->GetFullPath()));
- std::string sourceDirectoryFlag = this->LocalGenerator->GetIncludeFlags(
- sourceDirectory, this->GeneratorTarget, language, false, false,
- this->GetConfigName());
+ std::string sourceDirectoryFlag = this->LocalGenerator->GetIncludeFlags(
+ sourceDirectory, this->GeneratorTarget, language, false, false,
+ this->GetConfigName());
- vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+ vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+ }
// Explicit preprocessing always uses a depfile.
ppVars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ppFileName + ".d", cmOutputConverter::SHELL);
- // The actual compilation does not need a depfile because it
- // depends on the already-preprocessed source.
- vars.erase("DEP_FILE");
+ objectFileName + ".d", cmOutputConverter::SHELL);
+ if (compilePP) {
+ // The actual compilation does not need a depfile because it
+ // depends on the already-preprocessed source.
+ vars.erase("DEP_FILE");
+ }
if (needDyndep) {
// Tell dependency scanner the object file that will result from
- // compiling the preprocessed source.
+ // compiling the source.
ppVars["OBJ_FILE"] = objectFileName;
// Tell dependency scanner where to store dyndep intermediate results.
- std::string const ddiFile = ppFileName + ".ddi";
+ std::string const ddiFile = objectFileName + ".ddi";
ppVars["DYNDEP_INTERMEDIATE_FILE"] = ddiFile;
ppImplicitOuts.push_back(ddiFile);
- this->DDIFiles.push_back(ddiFile);
+ this->DDIFiles[language].push_back(ddiFile);
}
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 373c693..6a42da0 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -10,6 +10,7 @@
#include "cmNinjaTypes.h"
#include "cmOSXBundleGenerator.h"
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -64,6 +65,7 @@ protected:
bool NeedExplicitPreprocessing(std::string const& lang) const;
std::string LanguageDyndepRule(std::string const& lang) const;
bool NeedDyndep(std::string const& lang) const;
+ bool UsePreprocessedSource(std::string const& lang) const;
std::string OrderDependsTargetForTarget();
@@ -165,7 +167,7 @@ private:
cmLocalNinjaGenerator* LocalGenerator;
/// List of object files for this target.
cmNinjaDeps Objects;
- cmNinjaDeps DDIFiles; // TODO: Make per-language.
+ std::map<std::string, cmNinjaDeps> DDIFiles;
std::vector<cmCustomCommand const*> CustomCommands;
cmNinjaDeps ExtraFiles;
};
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 25ef4fc..022947f 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -73,44 +73,44 @@ void MergeOptions(std::vector<std::string>& baseOpts,
unsigned int const cmQtAutoGen::ParallelMax = 64;
std::string const cmQtAutoGen::ListSep = "<<<S>>>";
-std::string const cmQtAutoGen::GenNameGen = "AutoGen";
-std::string const cmQtAutoGen::GenNameMoc = "AutoMoc";
-std::string const cmQtAutoGen::GenNameUic = "AutoUic";
-std::string const cmQtAutoGen::GenNameRcc = "AutoRcc";
+std::string const cmQtAutoGen::GenAutoGen = "AutoGen";
+std::string const cmQtAutoGen::GenAutoMoc = "AutoMoc";
+std::string const cmQtAutoGen::GenAutoUic = "AutoUic";
+std::string const cmQtAutoGen::GenAutoRcc = "AutoRcc";
-std::string const cmQtAutoGen::GenNameGenUpper = "AUTOGEN";
-std::string const cmQtAutoGen::GenNameMocUpper = "AUTOMOC";
-std::string const cmQtAutoGen::GenNameUicUpper = "AUTOUIC";
-std::string const cmQtAutoGen::GenNameRccUpper = "AUTORCC";
+std::string const cmQtAutoGen::GenAUTOGEN = "AUTOGEN";
+std::string const cmQtAutoGen::GenAUTOMOC = "AUTOMOC";
+std::string const cmQtAutoGen::GenAUTOUIC = "AUTOUIC";
+std::string const cmQtAutoGen::GenAUTORCC = "AUTORCC";
std::string const& cmQtAutoGen::GeneratorName(GenT genType)
{
switch (genType) {
case GenT::GEN:
- return GenNameGen;
+ return GenAutoGen;
case GenT::MOC:
- return GenNameMoc;
+ return GenAutoMoc;
case GenT::UIC:
- return GenNameUic;
+ return GenAutoUic;
case GenT::RCC:
- return GenNameRcc;
+ return GenAutoRcc;
}
- return GenNameGen;
+ return GenAutoGen;
}
std::string const& cmQtAutoGen::GeneratorNameUpper(GenT genType)
{
switch (genType) {
case GenT::GEN:
- return GenNameGenUpper;
+ return GenAUTOGEN;
case GenT::MOC:
- return GenNameMocUpper;
+ return GenAUTOMOC;
case GenT::UIC:
- return GenNameUicUpper;
+ return GenAUTOUIC;
case GenT::RCC:
- return GenNameRccUpper;
+ return GenAUTORCC;
}
- return GenNameGenUpper;
+ return GenAUTOGEN;
}
std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
@@ -118,13 +118,13 @@ std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
std::string res;
std::vector<std::string> lst;
if (moc) {
- lst.emplace_back("AUTOMOC");
+ lst.emplace_back(GenAUTOMOC);
}
if (uic) {
- lst.emplace_back("AUTOUIC");
+ lst.emplace_back(GenAUTOUIC);
}
if (rcc) {
- lst.emplace_back("AUTORCC");
+ lst.emplace_back(GenAUTORCC);
}
switch (lst.size()) {
case 1:
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
index e62a947..6cc8df1 100644
--- a/Source/cmQtAutoGen.h
+++ b/Source/cmQtAutoGen.h
@@ -52,14 +52,14 @@ public:
/// @brief Nested lists separator
static std::string const ListSep;
// Generator names
- static std::string const GenNameGen;
- static std::string const GenNameMoc;
- static std::string const GenNameUic;
- static std::string const GenNameRcc;
- static std::string const GenNameGenUpper;
- static std::string const GenNameMocUpper;
- static std::string const GenNameUicUpper;
- static std::string const GenNameRccUpper;
+ static std::string const GenAutoGen;
+ static std::string const GenAutoMoc;
+ static std::string const GenAutoUic;
+ static std::string const GenAutoRcc;
+ static std::string const GenAUTOGEN;
+ static std::string const GenAUTOMOC;
+ static std::string const GenAUTOUIC;
+ static std::string const GenAUTORCC;
/// @brief Maximum number of parallel threads/processes in a generator
static unsigned int const ParallelMax;
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index 3ad91ee..7bd0e52 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -74,9 +74,9 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
continue;
}
- bool const moc = target->GetPropertyAsBool("AUTOMOC");
- bool const uic = target->GetPropertyAsBool("AUTOUIC");
- bool const rcc = target->GetPropertyAsBool("AUTORCC");
+ bool const moc = target->GetPropertyAsBool(cmQtAutoGen::GenAUTOMOC);
+ bool const uic = target->GetPropertyAsBool(cmQtAutoGen::GenAUTOUIC);
+ bool const rcc = target->GetPropertyAsBool(cmQtAutoGen::GenAUTORCC);
if (moc || uic || rcc) {
std::string const mocExec =
target->GetSafeProperty("AUTOMOC_EXECUTABLE");
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index a8c7960..700f16b 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -212,8 +212,8 @@ private:
/// @brief Constructor
MocT()
- : GenVarsT(cmQtAutoGen::GenT::MOC, cmQtAutoGen::GenNameMoc,
- cmQtAutoGen::GenNameMocUpper){};
+ : GenVarsT(cmQtAutoGen::GenT::MOC, cmQtAutoGen::GenAutoMoc,
+ cmQtAutoGen::GenAUTOMOC){};
} Moc;
/// @brief Uic only variables
@@ -228,8 +228,8 @@ private:
/// @brief Constructor
UicT()
- : GenVarsT(cmQtAutoGen::GenT::UIC, cmQtAutoGen::GenNameUic,
- cmQtAutoGen::GenNameUicUpper){};
+ : GenVarsT(cmQtAutoGen::GenT::UIC, cmQtAutoGen::GenAutoUic,
+ cmQtAutoGen::GenAUTOUIC){};
} Uic;
/// @brief Rcc only variables
@@ -241,8 +241,8 @@ private:
/// @brief Constructor
RccT()
- : GenVarsT(cmQtAutoGen::GenT::RCC, cmQtAutoGen::GenNameRcc,
- cmQtAutoGen::GenNameRccUpper){};
+ : GenVarsT(cmQtAutoGen::GenT::RCC, cmQtAutoGen::GenAutoRcc,
+ cmQtAutoGen::GenAUTORCC){};
} Rcc;
};
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 09068f8..e6f4021 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -500,7 +500,7 @@ static int do_build(int ac, char const* const* av)
return 1;
}
- cmake cm(cmake::RoleInternal, cmState::Unknown);
+ cmake cm(cmake::RoleInternal, cmState::Project);
cmSystemTools::SetMessageCallback(
[&cm](const std::string& msg, const char* title) {
cmakemainMessageCallback(msg, title, &cm);
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 3245f3e..1b5ed03 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1498,10 +1498,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_subdirectory(FindODBC)
endif()
- if(CMake_TEST_FindOctave)
- add_subdirectory(FindOctave)
- endif()
-
if(CMake_TEST_FindOpenCL)
add_subdirectory(FindOpenCL)
endif()
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index b0bc656..6ccdcc3 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -338,11 +338,11 @@ else()
add_executable(CompileFeaturesGenex2 genex_test.cpp)
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11)
- target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs})
+ target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1)
add_library(std_11_iface INTERFACE)
target_compile_features(std_11_iface INTERFACE cxx_std_11)
add_executable(CompileFeaturesGenex3 genex_test.cpp)
target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface)
- target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs})
+ target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1)
endif()
diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp
index 59f9006..4539789 100644
--- a/Tests/CompileFeatures/genex_test.cpp
+++ b/Tests/CompileFeatures/genex_test.cpp
@@ -15,10 +15,10 @@
# if !HAVE_CXX_STD_11
# error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11
# endif
-# if HAVE_CXX_STD_14
+# if HAVE_CXX_STD_14 && !defined(ALLOW_LATER_STANDARDS)
# error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11
# endif
-# if HAVE_CXX_STD_17
+# if HAVE_CXX_STD_17 && !defined(ALLOW_LATER_STANDARDS)
# error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11
# endif
#endif
diff --git a/Tests/FindOctave/CMakeLists.txt b/Tests/FindOctave/CMakeLists.txt
deleted file mode 100644
index 1acc966..0000000
--- a/Tests/FindOctave/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-add_test(NAME FindOctave.Test COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/FindOctave/Test"
- "${CMake_BINARY_DIR}/Tests/FindOctave/Test"
- ${build_generator_args}
- --build-project TestFindOctave
- --build-options ${build_options}
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
diff --git a/Tests/FindOctave/Test/CMakeLists.txt b/Tests/FindOctave/Test/CMakeLists.txt
deleted file mode 100644
index 73aa831..0000000
--- a/Tests/FindOctave/Test/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-cmake_minimum_required(VERSION 3.3)
-project(TestFindOctave CXX)
-enable_testing()
-
-find_package(Octave REQUIRED COMPONENTS Development Interpreter)
-
-add_definitions(-DCMAKE_EXPECTED_Octave_VERSION=${Octave_VERSION})
-
-add_executable(test_tgt main.cpp)
-target_link_libraries(test_tgt Octave::Octave)
-add_test(NAME test_tgt COMMAND test_tgt)
-
-add_executable(test_octinterp_tgt interp_main.cpp)
-target_link_libraries(test_octinterp_tgt Octave::Octinterp)
-add_test(NAME test_octinterp_tgt COMMAND test_octinterp_tgt)
-
-add_test(NAME test_tgt_exe
- COMMAND Octave::Interpreter -q --eval "runtests('.')"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
-add_executable(test_var main.cpp)
-target_include_directories(test_var PRIVATE ${Octave_INCLUDE_DIRS})
-target_link_libraries(test_var PRIVATE ${Octave_LIBRARIES})
-add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindOctave/Test/interp_main.cpp b/Tests/FindOctave/Test/interp_main.cpp
deleted file mode 100644
index 1efa187..0000000
--- a/Tests/FindOctave/Test/interp_main.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <iostream>
-#include <oct.h>
-#include <octave.h>
-#include <parse.h>
-#include <toplev.h>
-
-int main(void)
-{
- string_vector argv(2);
- argv(0) = "embedded";
- argv(1) = "-q";
-
- try {
- octave_main(2, argv.c_str_vec(), 1);
- octave_value_list in;
- in(0) = 72.0;
- const octave_value_list result = feval("sqrt", in);
- std::cout << "result is " << result(0).scalar_value() << std::endl;
- clean_up_and_exit(0);
- } catch (const octave::exit_exception& ex) {
- std::cerr << "Octave interpreter exited with status = " << ex.exit_status()
- << std::endl;
- } catch (const octave::execution_exception&) {
- std::cerr << "error encountered in Octave evaluator!" << std::endl;
- }
-}
diff --git a/Tests/FindOctave/Test/main.cpp b/Tests/FindOctave/Test/main.cpp
deleted file mode 100644
index 68270b1..0000000
--- a/Tests/FindOctave/Test/main.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <iostream>
-#include <oct.h>
-
-// http://www.dm.unibo.it/~achilles/calc/octave.html/Standalone-Programs.html
-int main(void)
-{
- int n = 2;
- Matrix a_matrix = Matrix(n, n);
- for (octave_idx_type i = 0; i < n; i++) {
- for (octave_idx_type j = 0; j < n; j++) {
- a_matrix(i, j) = (i + 1) * 10 + (j + 1);
- }
- }
-
- std::cout << a_matrix << std::endl;
-
- return EXIT_SUCCESS;
-}
diff --git a/Tests/FindOctave/Test/testtrue.m b/Tests/FindOctave/Test/testtrue.m
deleted file mode 100644
index 0c28a9e..0000000
--- a/Tests/FindOctave/Test/testtrue.m
+++ /dev/null
@@ -1 +0,0 @@
-%!assert(true)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1f3e5c3..f2b7ff1 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -284,11 +284,11 @@ function(add_RunCMake_test_try_compile)
if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
# Older CMake versions do not know about MSVC language standards.
# Approximate our logic from MSVC-CXX.cmake.
- if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND
+ if ((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.24215.1 AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR
- CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10.25017)
+ NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10.25017)
set(CMAKE_CXX_STANDARD_DEFAULT 14)
- elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
+ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
set(CMAKE_CXX_STANDARD_DEFAULT "")
else()
unset(CMAKE_CXX_STANDARD_DEFAULT)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake
index c0b6a48..22cad2b 100644
--- a/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake
@@ -1,4 +1,8 @@
get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+
+file(WRITE "${CMAKE_BINARY_DIR}/test.cmake" "# a")
+include("${CMAKE_BINARY_DIR}/test.cmake")
+
if(NOT role STREQUAL "PROJECT")
message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"")
endif()
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake
index 3cbd51d..7b29c28 100644
--- a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake
@@ -2,6 +2,9 @@ include(RunCMake)
include(RunCTest)
run_cmake(Project)
+file(WRITE "${RunCMake_BINARY_DIR}/Project-build/test.cmake" "# b")
+run_cmake_command(ProjectBuild "${CMAKE_COMMAND}" --build "${RunCMake_BINARY_DIR}/Project-build")
+
run_cmake_command(Script "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/Script.cmake")
run_cmake_command(FindPackage "${CMAKE_COMMAND}" --find-package -DNAME=DummyPackage -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}")
run_ctest(CTest)
diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake
new file mode 100644
index 0000000..91abbd6
--- /dev/null
+++ b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake
@@ -0,0 +1,5 @@
+set(mylist "b;c;b;a;a;c;b;a;c;b")
+list(REMOVE_DUPLICATES mylist)
+if(NOT mylist STREQUAL "b;c;a")
+ message(SEND_ERROR "Expected b;c;a, got ${mylist}")
+endif()
diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake
index 59c7ea5..b4a91bc 100644
--- a/Tests/RunCMake/list/RunCMakeTest.cmake
+++ b/Tests/RunCMake/list/RunCMakeTest.cmake
@@ -24,6 +24,8 @@ run_cmake(SUBLIST-TooManyArguments)
run_cmake(REMOVE_AT-EmptyList)
+run_cmake(REMOVE_DUPLICATES-PreserveOrder)
+
run_cmake(FILTER-NotList)
run_cmake(REMOVE_AT-NotList)
run_cmake(REMOVE_DUPLICATES-NotList)
diff --git a/Utilities/cmcompress/CMakeLists.txt b/Utilities/cmcompress/CMakeLists.txt
deleted file mode 100644
index 8063573..0000000
--- a/Utilities/cmcompress/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-PROJECT(CMCompress)
-
-ADD_LIBRARY(cmcompress cmcompress.c)
-
-INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmcompress)
diff --git a/Utilities/cmcompress/Copyright.txt b/Utilities/cmcompress/Copyright.txt
deleted file mode 100644
index 162332f..0000000
--- a/Utilities/cmcompress/Copyright.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-Copyright (c) 1985, 1986 The Regents of the University of California.
-All rights reserved.
-
-This code is derived from software contributed to Berkeley by
-James A. Woods, derived from original work by Spencer Thomas
-and Joseph Orost.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
- must display the following acknowledgement:
- This product includes software developed by the University of
- California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
diff --git a/Utilities/cmcompress/cmcompress.c b/Utilities/cmcompress/cmcompress.c
deleted file mode 100644
index ea845ed..0000000
--- a/Utilities/cmcompress/cmcompress.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "cmcompress.h"
-
-#include <errno.h>
-#include <string.h>
-
-static const char_type magic_header[] = { "\037\235" }; /* 1F 9D */
-
-/* Defines for third byte of header */
-#define BIT_MASK 0x1f
-#define BLOCK_MASK 0x80
-#define CHECK_GAP 10000 /* ratio check interval */
-/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
- a fourth header byte (for expansion).
- */
-#define INIT_BITS 9 /* initial number of bits/code */
-
-#ifdef COMPATIBLE /* But wrong! */
-# define MAXCODE(n_bits) (1 << (n_bits) - 1)
-#else
-# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
-#endif /* COMPATIBLE */
-
-#define htabof(i) cdata->htab[i]
-#define codetabof(i) cdata->codetab[i]
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define FIRST 257 /* first free entry */
-#define CLEAR 256 /* table clear output code */
-
-#ifdef DEBUG
-static void prratio( FILE *stream, long int num, long int den);
-#endif
-
-int cmcompress_compress_initialize(struct cmcompress_stream* cdata)
-{
- cdata->maxbits = BITS; /* user settable max # bits/code */
- cdata->maxmaxcode = 1 << BITS; /* should NEVER generate this code */
- cdata->hsize = HSIZE; /* for dynamic table sizing */
- cdata->free_ent = 0; /* first unused entry */
- cdata->nomagic = 0; /* Use a 3-byte magic number header, unless old file */
- cdata->block_compress = BLOCK_MASK;
- cdata->clear_flg = 0;
- cdata->ratio = 0;
- cdata->checkpoint = CHECK_GAP;
-
- cdata->input_stream = 0;
- cdata->output_stream = 0;
- cdata->client_data = 0;
- return 1;
-}
-
-static void cl_hash(struct cmcompress_stream* cdata, count_int hsize) /* reset code table */
-{
- register count_int *htab_p = cdata->htab+hsize;
- register long i;
- register long m1 = -1;
-
- i = hsize - 16;
- do
- { /* might use Sys V memset(3) here */
- *(htab_p-16) = m1;
- *(htab_p-15) = m1;
- *(htab_p-14) = m1;
- *(htab_p-13) = m1;
- *(htab_p-12) = m1;
- *(htab_p-11) = m1;
- *(htab_p-10) = m1;
- *(htab_p-9) = m1;
- *(htab_p-8) = m1;
- *(htab_p-7) = m1;
- *(htab_p-6) = m1;
- *(htab_p-5) = m1;
- *(htab_p-4) = m1;
- *(htab_p-3) = m1;
- *(htab_p-2) = m1;
- *(htab_p-1) = m1;
- htab_p -= 16;
- }
- while ((i -= 16) >= 0);
- for ( i += 16; i > 0; i-- )
- {
- *--htab_p = m1;
- }
-}
-
-/*-
- * Output the given code.
- * Inputs:
- * code: A n_bits-bit integer. If == -1, then EOF. This assumes
- * that n_bits =< (long)wordsize - 1.
- * Outputs:
- * Outputs code to the file.
- * Assumptions:
- * Chars are 8 bits long.
- * Algorithm:
- * Maintain a BITS character long buffer (so that 8 codes will
- * fit in it exactly). Use the VAX insv instruction to insert each
- * code in turn. When the buffer fills up empty it and start over.
- */
-
-static char buf[BITS];
-
-#ifndef vax
-char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
-char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
-#endif /* vax */
-
-static int output(struct cmcompress_stream* cdata, code_int code)
-{
-#ifdef DEBUG
- static int col = 0;
-#endif /* DEBUG */
-
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register int r_off = cdata->offset, bits= cdata->n_bits;
- register char * bp = buf;
-
-#ifdef DEBUG
- if ( verbose )
- {
- fprintf( stderr, "%5d%c", code,
- (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
- }
-#endif /* DEBUG */
- if ( code >= 0 )
- {
-#if defined(vax) && !defined(__GNUC__)
- /*
- * VAX and PCC DEPENDENT!! Implementation on other machines is
- * below.
- *
- * Translation: Insert BITS bits from the argument starting at
- * cdata->offset bits from the beginning of buf.
- */
- 0; /* Work around for pcc -O bug with asm and if stmt */
- asm( "insv 4(ap),r11,r10,(r9)" );
-#else
- /*
- * byte/bit numbering on the VAX is simulated by the following code
- */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /*
- * Since code is always >= 8 bits, only need to mask the first
- * hunk on the left.
- */
- *bp = (char)((*bp & rmask[r_off]) | ((code << r_off) & lmask[r_off]));
- bp++;
- bits -= (8 - r_off);
- code >>= 8 - r_off;
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 )
- {
- *bp++ = (char)(code);
- code >>= 8;
- bits -= 8;
- }
- /* Last bits. */
- if(bits)
- {
- *bp = (char)(code);
- }
-#endif /* vax */
- cdata->offset += cdata->n_bits;
- if ( cdata->offset == (cdata->n_bits << 3) )
- {
- bp = buf;
- bits = cdata->n_bits;
- cdata->bytes_out += bits;
- do
- {
- if ( cdata->output_stream(cdata, bp, 1) != 1 )
- {
- return 0;
- }
- bp++;
- }
- while(--bits);
- cdata->offset = 0;
- }
-
- /*
- * If the next entry is going to be too big for the code size,
- * then increase it, if possible.
- */
- if ( cdata->free_ent > cdata->maxcode || (cdata->clear_flg > 0))
- {
- /*
- * Write the whole buffer, because the input side won't
- * discover the size increase until after it has read it.
- */
- if ( cdata->offset > 0 )
- {
- if ( cdata->output_stream(cdata, buf, cdata->n_bits) != cdata->n_bits )
- {
- return 0;
- }
- cdata->bytes_out += cdata->n_bits;
- }
- cdata->offset = 0;
-
- if ( cdata->clear_flg )
- {
- cdata->maxcode = MAXCODE (cdata->n_bits = INIT_BITS);
- cdata->clear_flg = 0;
- }
- else
- {
- cdata->n_bits++;
- if ( cdata->n_bits == cdata->maxbits )
- {
- cdata->maxcode = cdata->maxmaxcode;
- }
- else
- {
- cdata->maxcode = MAXCODE(cdata->n_bits);
- }
- }
-#ifdef DEBUG
- if ( debug )
- {
- fprintf( stderr, "\nChange to %d bits\n", cdata->n_bits );
- col = 0;
- }
-#endif /* DEBUG */
- }
- }
- else
- {
- /*
- * At EOF, write the rest of the buffer.
- */
- if ( cdata->offset > 0 )
- {
- cdata->offset = (cdata->offset + 7) / 8;
- if ( cdata->output_stream(cdata, buf, cdata->offset ) != cdata->offset )
- {
- return 0;
- }
- cdata->bytes_out += cdata->offset;
- }
- cdata->offset = 0;
- (void)fflush( stdout );
- if( ferror( stdout ) )
- {
- return 0;
- }
-#ifdef DEBUG
- if ( verbose )
- {
- fprintf( stderr, "\n" );
- }
-#endif
- }
- return 1;
-}
-
-/*
- * compress stdin to stdout
- *
- * Algorithm: use open addressing double hashing (no chaining) on the
- * prefix code / next character combination. We do a variant of Knuth's
- * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- * secondary probe. Here, the modular division first probe is gives way
- * to a faster exclusive-or manipulation. Also do block compression with
- * an adaptive reset, whereby the code table is cleared when the compression
- * ratio decreases, but after the table fills. The variable-length output
- * codes are re-sized at this point, and a special CLEAR code is generated
- * for the decompressor. Late addition: construct the table according to
- * file size for noticeable speed improvement on small files. Please direct
- * questions about this implementation to ames!jaw.
- */
-
-int cmcompress_compress_start(struct cmcompress_stream* cdata)
-{
-#ifndef COMPATIBLE
- if (cdata->nomagic == 0)
- {
- char headLast = (char)(cdata->maxbits | cdata->block_compress);
- cdata->output_stream(cdata, (const char*)magic_header, 2);
- cdata->output_stream(cdata, &headLast, 1);
- if(ferror(stdout))
- {
- printf("Error...\n");
- }
- }
-#endif /* COMPATIBLE */
-
- cdata->offset = 0;
- cdata->bytes_out = 3; /* includes 3-byte header mojo */
- cdata->out_count = 0;
- cdata->clear_flg = 0;
- cdata->ratio = 0;
- cdata->in_count = 1;
- cdata->checkpoint = CHECK_GAP;
- cdata->maxcode = MAXCODE(cdata->n_bits = INIT_BITS);
- cdata->free_ent = ((cdata->block_compress) ? FIRST : 256 );
-
- cdata->first_pass = 1;
-
- cdata->hshift = 0;
- for ( cdata->fcode = (long) cdata->hsize; cdata->fcode < 65536L; cdata->fcode *= 2L )
- {
- cdata->hshift++;
- }
- cdata->hshift = 8 - cdata->hshift; /* set hash code range bound */
-
- cdata->hsize_reg = cdata->hsize;
- cl_hash(cdata, (count_int) cdata->hsize_reg); /* clear hash table */
-
- return 1;
-}
-
-static int cl_block (struct cmcompress_stream* cdata) /* table clear for block compress */
-{
- register long int rat;
-
- cdata->checkpoint = cdata->in_count + CHECK_GAP;
-#ifdef DEBUG
- if ( cdata->debug )
- {
- fprintf ( stderr, "count: %ld, ratio: ", cdata->in_count );
- prratio ( stderr, cdata->in_count, cdata->bytes_out );
- fprintf ( stderr, "\n");
- }
-#endif /* DEBUG */
-
- if(cdata->in_count > 0x007fffff)
- { /* shift will overflow */
- rat = cdata->bytes_out >> 8;
- if(rat == 0)
- { /* Don't divide by zero */
- rat = 0x7fffffff;
- }
- else
- {
- rat = cdata->in_count / rat;
- }
- }
- else
- {
- rat = (cdata->in_count << 8) / cdata->bytes_out; /* 8 fractional bits */
- }
- if ( rat > cdata->ratio )
- {
- cdata->ratio = rat;
- }
- else
- {
- cdata->ratio = 0;
-#ifdef DEBUG
- if(cdata->verbose)
- {
- dump_tab(); /* dump string table */
- }
-#endif
- cl_hash (cdata, (count_int) cdata->hsize );
- cdata->free_ent = FIRST;
- cdata->clear_flg = 1;
- if ( !output (cdata, (code_int) CLEAR ) )
- {
- return 0;
- }
-#ifdef DEBUG
- if(cdata->debug)
- {
- fprintf ( stderr, "clear\n" );
- }
-#endif /* DEBUG */
- }
- return 1;
-}
-
-
-int cmcompress_compress(struct cmcompress_stream* cdata, void* buff, size_t n)
-{
- register code_int i;
- register int c;
- register int disp;
-
- unsigned char* input_buffer = (unsigned char*)buff;
-
- size_t cc;
-
- /*printf("cmcompress_compress(%p, %p, %d)\n", cdata, buff, n);*/
-
- if ( cdata->first_pass )
- {
- cdata->ent = input_buffer[0];
- ++ input_buffer;
- -- n;
- cdata->first_pass = 0;
- }
-
- for ( cc = 0; cc < n; ++ cc )
- {
- c = input_buffer[cc];
- cdata->in_count++;
- cdata->fcode = (long) (((long) c << cdata->maxbits) + cdata->ent);
- i = ((c << cdata->hshift) ^ cdata->ent); /* xor hashing */
-
- if ( htabof (i) == cdata->fcode )
- {
- cdata->ent = codetabof (i);
- continue;
- }
- else if ( (long)htabof (i) < 0 ) /* empty slot */
- {
- goto nomatch;
- }
- disp = (int)(cdata->hsize_reg - i); /* secondary hash (after G. Knott) */
- if ( i == 0 )
- {
- disp = 1;
- }
-probe:
- if ( (i -= disp) < 0 )
- {
- i += cdata->hsize_reg;
- }
-
- if ( htabof (i) == cdata->fcode )
- {
- cdata->ent = codetabof (i);
- continue;
- }
- if ( (long)htabof (i) > 0 )
- {
- goto probe;
- }
-nomatch:
- if ( !output(cdata, (code_int) cdata->ent ) )
- {
- return 0;
- }
- cdata->out_count++;
- cdata->ent = c;
- if (
-#ifdef SIGNED_COMPARE_SLOW
- (unsigned) cdata->free_ent < (unsigned) cdata->maxmaxcode
-#else
- cdata->free_ent < cdata->maxmaxcode
-#endif
- )
- {
- codetabof (i) = (unsigned short)(cdata->free_ent++); /* code -> hashtable */
- htabof (i) = cdata->fcode;
- }
- else if ( (count_int)cdata->in_count >= cdata->checkpoint && cdata->block_compress )
- {
- if ( !cl_block (cdata) )
- {
- return 0;
- }
- }
- }
-
- return 1;
-}
-
-int cmcompress_compress_finalize(struct cmcompress_stream* cdata)
-{
- /*
- * Put out the final code.
- */
- if ( !output(cdata, (code_int)cdata->ent ) )
- {
- return 0;
- }
- cdata->out_count++;
- if ( !output(cdata, (code_int)-1 ) )
- {
- return 0;
- }
-
- if(cdata->bytes_out > cdata->in_count) /* exit(2) if no savings */
- {
- return 0;
- }
- return 1;
-}
-
-
-#if defined(DEBUG)
-static void prratio(FILE *stream, long int num, long int den)
-{
- register int q; /* Doesn't need to be long */
-
- if(num > 214748L)
- { /* 2147483647/10000 */
- q = num / (den / 10000L);
- }
- else
- {
- q = 10000L * num / den; /* Long calculations, though */
- }
- if (q < 0)
- {
- putc('-', stream);
- q = -q;
- }
- fprintf(stream, "%d.%02d%%", q / 100, q % 100);
-}
-#endif
-
diff --git a/Utilities/cmcompress/cmcompress.h b/Utilities/cmcompress/cmcompress.h
deleted file mode 100644
index 4cd3a1c..0000000
--- a/Utilities/cmcompress/cmcompress.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef cmcompress__h_
-#define cmcompress__h_
-
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*
- * Set USERMEM to the maximum amount of physical user memory available
- * in bytes. USERMEM is used to determine the maximum BITS that can be used
- * for compression.
- *
- * SACREDMEM is the amount of physical memory saved for others; compress
- * will hog the rest.
- */
-#ifndef SACREDMEM
-#define SACREDMEM 0
-#endif
-
-#ifndef USERMEM
-# define USERMEM 450000 /* default user memory */
-#endif
-
-#ifdef pdp11
-# define BITS 12 /* max bits/code for 16-bit machine */
-# define NO_UCHAR /* also if "unsigned char" functions as signed char */
-# undef USERMEM
-#endif /* pdp11 */ /* don't forget to compile with -i */
-
-#ifdef USERMEM
-# if USERMEM >= (433484+SACREDMEM)
-# define PBITS 16
-# else
-# if USERMEM >= (229600+SACREDMEM)
-# define PBITS 15
-# else
-# if USERMEM >= (127536+SACREDMEM)
-# define PBITS 14
-# else
-# if USERMEM >= (73464+SACREDMEM)
-# define PBITS 13
-# else
-# define PBITS 12
-# endif
-# endif
-# endif
-# endif
-# undef USERMEM
-#endif /* USERMEM */
-
-#ifdef PBITS /* Preferred BITS for this memory size */
-# ifndef BITS
-# define BITS PBITS
-# endif /* BITS */
-#endif /* PBITS */
-
-#if BITS == 16
-# define HSIZE 69001 /* 95% occupancy */
-#endif
-#if BITS == 15
-# define HSIZE 35023 /* 94% occupancy */
-#endif
-#if BITS == 14
-# define HSIZE 18013 /* 91% occupancy */
-#endif
-#if BITS == 13
-# define HSIZE 9001 /* 91% occupancy */
-#endif
-#if BITS <= 12
-# define HSIZE 5003 /* 80% occupancy */
-#endif
-
- /*
- * a code_int must be able to hold 2**BITS values of type int, and also -1
- */
-#if BITS > 15
- typedef long int code_int;
-#else
- typedef int code_int;
-#endif
-
-#ifdef SIGNED_COMPARE_SLOW
- typedef unsigned long int count_int;
- typedef unsigned short int count_short;
-#else
- typedef long int count_int;
-#endif
-
-#ifdef NO_UCHAR
- typedef char char_type;
-#else
- typedef unsigned char char_type;
-#endif /* UCHAR */
-
-
-
- struct cmcompress_stream
- {
- int n_bits; /* number of bits/code */
- int maxbits; /* user settable max # bits/code */
- code_int maxcode; /* maximum code, given n_bits */
- code_int maxmaxcode; /* should NEVER generate this code */
-
- count_int htab [HSIZE];
- unsigned short codetab [HSIZE];
-
- code_int hsize; /* for dynamic table sizing */
- code_int free_ent; /* first unused entry */
- int nomagic; /* Use a 3-byte magic number header, unless old file */
-
- /*
- * block compression parameters -- after all codes are used up,
- * and compression rate changes, start over.
- */
- int block_compress;
- int clear_flg;
- long int ratio;
- count_int checkpoint;
-
-#ifdef DEBUG
- int debug;
- int verbose;
-#endif
-
- /* compress internals */
- int offset;
- long int in_count; /* length of input */
- long int bytes_out; /* length of compressed output */
- long int out_count; /* # of codes output (for debugging) */
-
- /* internals */
- code_int ent;
- code_int hsize_reg;
- int hshift;
-
- long fcode;
- int first_pass;
-
- /* For input and output */
- int (*input_stream)(void*);
- int (*output_stream)(void*, const char*,int);
- void* client_data;
- };
-
- int cmcompress_compress_initialize(struct cmcompress_stream* cdata);
- int cmcompress_compress_start(struct cmcompress_stream* cdata);
- int cmcompress_compress(struct cmcompress_stream* cdata, void* buff, size_t n);
- int cmcompress_compress_finalize(struct cmcompress_stream* cdata);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* cmcompress__h_ */
diff --git a/Utilities/cmcompress/compress.c.original b/Utilities/cmcompress/compress.c.original
deleted file mode 100644
index 5062bda..0000000
--- a/Utilities/cmcompress/compress.c.original
+++ /dev/null
@@ -1,1308 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1985, 1986 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)compress.c 5.19 (Berkeley) 3/18/91";
-#endif /* not lint */
-
-/*
- * compress.c - File compression ala IEEE Computer, June 1984.
- *
- * Authors: Spencer W. Thomas (decvax!utah-cs!thomas)
- * Jim McKie (decvax!mcvax!jim)
- * Steve Davies (decvax!vax135!petsd!peora!srd)
- * Ken Turkowski (decvax!decwrl!turtlevax!ken)
- * James A. Woods (decvax!ihnp4!ames!jaw)
- * Joe Orost (decvax!vax135!petsd!joe)
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <utime.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * Set USERMEM to the maximum amount of physical user memory available
- * in bytes. USERMEM is used to determine the maximum BITS that can be used
- * for compression.
- *
- * SACREDMEM is the amount of physical memory saved for others; compress
- * will hog the rest.
- */
-#ifndef SACREDMEM
-#define SACREDMEM 0
-#endif
-
-#ifndef USERMEM
-# define USERMEM 450000 /* default user memory */
-#endif
-
-#ifdef pdp11
-# define BITS 12 /* max bits/code for 16-bit machine */
-# define NO_UCHAR /* also if "unsigned char" functions as signed char */
-# undef USERMEM
-#endif /* pdp11 */ /* don't forget to compile with -i */
-
-#ifdef USERMEM
-# if USERMEM >= (433484+SACREDMEM)
-# define PBITS 16
-# else
-# if USERMEM >= (229600+SACREDMEM)
-# define PBITS 15
-# else
-# if USERMEM >= (127536+SACREDMEM)
-# define PBITS 14
-# else
-# if USERMEM >= (73464+SACREDMEM)
-# define PBITS 13
-# else
-# define PBITS 12
-# endif
-# endif
-# endif
-# endif
-# undef USERMEM
-#endif /* USERMEM */
-
-#ifdef PBITS /* Preferred BITS for this memory size */
-# ifndef BITS
-# define BITS PBITS
-# endif BITS
-#endif /* PBITS */
-
-#if BITS == 16
-# define HSIZE 69001 /* 95% occupancy */
-#endif
-#if BITS == 15
-# define HSIZE 35023 /* 94% occupancy */
-#endif
-#if BITS == 14
-# define HSIZE 18013 /* 91% occupancy */
-#endif
-#if BITS == 13
-# define HSIZE 9001 /* 91% occupancy */
-#endif
-#if BITS <= 12
-# define HSIZE 5003 /* 80% occupancy */
-#endif
-
-/*
- * a code_int must be able to hold 2**BITS values of type int, and also -1
- */
-#if BITS > 15
-typedef long int code_int;
-#else
-typedef int code_int;
-#endif
-
-#ifdef SIGNED_COMPARE_SLOW
-typedef unsigned long int count_int;
-typedef unsigned short int count_short;
-#else
-typedef long int count_int;
-#endif
-
-#ifdef NO_UCHAR
- typedef char char_type;
-#else
- typedef unsigned char char_type;
-#endif /* UCHAR */
-char_type magic_header[] = { "\037\235" }; /* 1F 9D */
-
-/* Defines for third byte of header */
-#define BIT_MASK 0x1f
-#define BLOCK_MASK 0x80
-/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
- a fourth header byte (for expansion).
-*/
-#define INIT_BITS 9 /* initial number of bits/code */
-
-int n_bits; /* number of bits/code */
-int maxbits = BITS; /* user settable max # bits/code */
-code_int maxcode; /* maximum code, given n_bits */
-code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */
-#ifdef COMPATIBLE /* But wrong! */
-# define MAXCODE(n_bits) (1 << (n_bits) - 1)
-#else
-# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
-#endif /* COMPATIBLE */
-
-count_int htab [HSIZE];
-unsigned short codetab [HSIZE];
-
-#define htabof(i) htab[i]
-#define codetabof(i) codetab[i]
-code_int hsize = HSIZE; /* for dynamic table sizing */
-count_int fsize;
-
-/*
- * To save much memory, we overlay the table used by compress() with those
- * used by decompress(). The tab_prefix table is the same size and type
- * as the codetab. The tab_suffix table needs 2**BITS characters. We
- * get this from the beginning of htab. The output stack uses the rest
- * of htab, and contains characters. There is plenty of room for any
- * possible stack (stack used to be 8000 characters).
- */
-
-#define tab_prefixof(i) codetabof(i)
-# define tab_suffixof(i) ((char_type *)(htab))[i]
-# define de_stack ((char_type *)&tab_suffixof(1<<BITS))
-
-code_int free_ent = 0; /* first unused entry */
-int exit_stat = 0; /* per-file status */
-int perm_stat = 0; /* permanent status */
-
-code_int getcode();
-
-int nomagic = 0; /* Use a 3-byte magic number header, unless old file */
-int zcat_flg = 0; /* Write output on stdout, suppress messages */
-int precious = 1; /* Don't unlink output file on interrupt */
-int quiet = 1; /* don't tell me about compression */
-
-/*
- * block compression parameters -- after all codes are used up,
- * and compression rate changes, start over.
- */
-int block_compress = BLOCK_MASK;
-int clear_flg = 0;
-long int ratio = 0;
-#define CHECK_GAP 10000 /* ratio check interval */
-count_int checkpoint = CHECK_GAP;
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define FIRST 257 /* first free entry */
-#define CLEAR 256 /* table clear output code */
-
-int force = 0;
-char ofname [100];
-#ifdef DEBUG
-int debug, verbose;
-#endif
-sig_t oldint;
-int bgnd_flag;
-
-int do_decomp = 0;
-
-/*-
- * Algorithm from "A Technique for High Performance Data Compression",
- * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19.
- *
- * Usage: compress [-dfvc] [-b bits] [file ...]
- * Inputs:
- * -d: If given, decompression is done instead.
- *
- * -c: Write output on stdout, don't remove original.
- *
- * -b: Parameter limits the max number of bits/code.
- *
- * -f: Forces output file to be generated, even if one already
- * exists, and even if no space is saved by compressing.
- * If -f is not used, the user will be prompted if stdin is
- * a tty, otherwise, the output file will not be overwritten.
- *
- * -v: Write compression statistics
- *
- * file ...: Files to be compressed. If none specified, stdin
- * is used.
- * Outputs:
- * file.Z: Compressed form of file with same mode, owner, and utimes
- * or stdout (if stdin used as input)
- *
- * Assumptions:
- * When filenames are given, replaces with the compressed version
- * (.Z suffix) only if the file decreases in size.
- * Algorithm:
- * Modified Lempel-Ziv method (LZW). Basically finds common
- * substrings and replaces them with a variable size code. This is
- * deterministic, and can be done on the fly. Thus, the decompression
- * procedure needs no input table, but tracks the way the table was built.
- */
-
-main(argc, argv)
- int argc;
- char **argv;
-{
- extern int optind;
- extern char *optarg;
- struct stat statbuf;
- int ch, overwrite;
- char **filelist, **fileptr, *cp, tempname[MAXPATHLEN];
- void onintr(), oops();
-
- /* This bg check only works for sh. */
- if ((oldint = signal(SIGINT, SIG_IGN)) != SIG_IGN) {
- (void)signal(SIGINT, onintr);
- (void)signal(SIGSEGV, oops); /* XXX */
- }
- bgnd_flag = oldint != SIG_DFL;
-
-#ifdef COMPATIBLE
- nomagic = 1; /* Original didn't have a magic number */
-#endif
-
- if (cp = rindex(argv[0], '/'))
- ++cp;
- else
- cp = argv[0];
- if (strcmp(cp, "uncompress") == 0)
- do_decomp = 1;
- else if(strcmp(cp, "zcat") == 0) {
- do_decomp = 1;
- zcat_flg = 1;
- }
-
- /*
- * -b maxbits => maxbits.
- * -C => generate output compatible with compress 2.0.
- * -c => cat all output to stdout
- * -D => debug
- * -d => do_decomp
- * -f => force overwrite of output file
- * -n => no header: useful to uncompress old files
- * -V => print Version; debug verbose
- * -v => unquiet
- */
-
- overwrite = 0;
-#ifdef DEBUG
- while ((ch = getopt(argc, argv, "b:CcDdfnVv")) != EOF)
-#else
- while ((ch = getopt(argc, argv, "b:Ccdfnv")) != EOF)
-#endif
- switch(ch) {
- case 'b':
- maxbits = atoi(optarg);
- break;
- case 'C':
- block_compress = 0;
- break;
- case 'c':
- zcat_flg = 1;
- break;
-#ifdef DEBUG
- case 'D':
- debug = 1;
- break;
-#endif
- case 'd':
- do_decomp = 1;
- break;
- case 'f':
- overwrite = 1;
- force = 1;
- break;
- case 'n':
- nomagic = 1;
- break;
- case 'q':
- quiet = 1;
- break;
-#ifdef DEBUG
- case 'V':
- verbose = 1;
- break;
-#endif
- case 'v':
- quiet = 0;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (maxbits < INIT_BITS)
- maxbits = INIT_BITS;
- if (maxbits > BITS)
- maxbits = BITS;
- maxmaxcode = 1 << maxbits;
-
- /* Build useless input file list. */
- filelist = fileptr = (char **)(malloc(argc * sizeof(*argv)));
- while (*argv)
- *fileptr++ = *argv++;
- *fileptr = NULL;
-
- if (*filelist != NULL) {
- for (fileptr = filelist; *fileptr; fileptr++) {
- exit_stat = 0;
- if (do_decomp) { /* DECOMPRESSION */
- /* Check for .Z suffix */
- if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") != 0) {
- /* No .Z: tack one on */
- strcpy(tempname, *fileptr);
- strcat(tempname, ".Z");
- *fileptr = tempname;
- }
- /* Open input file */
- if ((freopen(*fileptr, "r", stdin)) == NULL) {
- perror(*fileptr);
- perm_stat = 1;
- continue;
- }
- /* Check the magic number */
- if (nomagic == 0) {
- if ((getchar() != (magic_header[0] & 0xFF))
- || (getchar() != (magic_header[1] & 0xFF))) {
- fprintf(stderr, "%s: not in compressed format\n",
- *fileptr);
- continue;
- }
- maxbits = getchar(); /* set -b from file */
- block_compress = maxbits & BLOCK_MASK;
- maxbits &= BIT_MASK;
- maxmaxcode = 1 << maxbits;
- if(maxbits > BITS) {
- fprintf(stderr,
- "%s: compressed with %d bits, can only handle %d bits\n",
- *fileptr, maxbits, BITS);
- continue;
- }
- }
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- ofname[strlen(*fileptr) - 2] = '\0'; /* Strip off .Z */
- } else { /* COMPRESSION */
- if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") == 0) {
- fprintf(stderr, "%s: already has .Z suffix -- no change\n",
- *fileptr);
- continue;
- }
- /* Open input file */
- if ((freopen(*fileptr, "r", stdin)) == NULL) {
- perror(*fileptr);
- perm_stat = 1;
- continue;
- }
- stat ( *fileptr, &statbuf );
- fsize = (long) statbuf.st_size;
- /*
- * tune hash table size for small files -- ad hoc,
- * but the sizes match earlier #defines, which
- * serve as upper bounds on the number of output codes.
- */
- hsize = HSIZE;
- if ( fsize < (1 << 12) )
- hsize = MIN ( 5003, HSIZE );
- else if ( fsize < (1 << 13) )
- hsize = MIN ( 9001, HSIZE );
- else if ( fsize < (1 << 14) )
- hsize = MIN ( 18013, HSIZE );
- else if ( fsize < (1 << 15) )
- hsize = MIN ( 35023, HSIZE );
- else if ( fsize < 47000 )
- hsize = MIN ( 50021, HSIZE );
-
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- strcat(ofname, ".Z");
- }
- /* Check for overwrite of existing file */
- if (overwrite == 0 && zcat_flg == 0) {
- if (stat(ofname, &statbuf) == 0) {
- char response[2];
- response[0] = 'n';
- fprintf(stderr, "%s already exists;", ofname);
- if (bgnd_flag == 0 && isatty(2)) {
- fprintf(stderr, " do you wish to overwrite %s (y or n)? ",
- ofname);
- fflush(stderr);
- read(2, response, 2);
- while (response[1] != '\n') {
- if (read(2, response+1, 1) < 0) { /* Ack! */
- perror("stderr"); break;
- }
- }
- }
- if (response[0] != 'y') {
- fprintf(stderr, "\tnot overwritten\n");
- continue;
- }
- }
- }
- if(zcat_flg == 0) { /* Open output file */
- if (freopen(ofname, "w", stdout) == NULL) {
- perror(ofname);
- perm_stat = 1;
- continue;
- }
- precious = 0;
- if(!quiet)
- fprintf(stderr, "%s: ", *fileptr);
- }
-
- /* Actually do the compression/decompression */
- if (do_decomp == 0) compress();
-#ifndef DEBUG
- else decompress();
-#else
- else if (debug == 0) decompress();
- else printcodes();
- if (verbose) dump_tab();
-#endif /* DEBUG */
- if(zcat_flg == 0) {
- copystat(*fileptr, ofname); /* Copy stats */
- precious = 1;
- if((exit_stat == 1) || (!quiet))
- putc('\n', stderr);
- }
- }
- } else { /* Standard input */
- if (do_decomp == 0) {
- compress();
-#ifdef DEBUG
- if(verbose) dump_tab();
-#endif /* DEBUG */
- if(!quiet)
- putc('\n', stderr);
- } else {
- /* Check the magic number */
- if (nomagic == 0) {
- if ((getchar()!=(magic_header[0] & 0xFF))
- || (getchar()!=(magic_header[1] & 0xFF))) {
- fprintf(stderr, "stdin: not in compressed format\n");
- exit(1);
- }
- maxbits = getchar(); /* set -b from file */
- block_compress = maxbits & BLOCK_MASK;
- maxbits &= BIT_MASK;
- maxmaxcode = 1 << maxbits;
- fsize = 100000; /* assume stdin large for USERMEM */
- if(maxbits > BITS) {
- fprintf(stderr,
- "stdin: compressed with %d bits, can only handle %d bits\n",
- maxbits, BITS);
- exit(1);
- }
- }
-#ifndef DEBUG
- decompress();
-#else
- if (debug == 0) decompress();
- else printcodes();
- if (verbose) dump_tab();
-#endif /* DEBUG */
- }
- }
- exit(perm_stat ? perm_stat : exit_stat);
-}
-
-static int offset;
-long int in_count = 1; /* length of input */
-long int bytes_out; /* length of compressed output */
-long int out_count = 0; /* # of codes output (for debugging) */
-
-/*
- * compress stdin to stdout
- *
- * Algorithm: use open addressing double hashing (no chaining) on the
- * prefix code / next character combination. We do a variant of Knuth's
- * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- * secondary probe. Here, the modular division first probe is gives way
- * to a faster exclusive-or manipulation. Also do block compression with
- * an adaptive reset, whereby the code table is cleared when the compression
- * ratio decreases, but after the table fills. The variable-length output
- * codes are re-sized at this point, and a special CLEAR code is generated
- * for the decompressor. Late addition: construct the table according to
- * file size for noticeable speed improvement on small files. Please direct
- * questions about this implementation to ames!jaw.
- */
-
-compress()
-{
- register long fcode;
- register code_int i = 0;
- register int c;
- register code_int ent;
- register int disp;
- register code_int hsize_reg;
- register int hshift;
-
-#ifndef COMPATIBLE
- if (nomagic == 0) {
- putchar(magic_header[0]);
- putchar(magic_header[1]);
- putchar((char)(maxbits | block_compress));
- if(ferror(stdout))
- writeerr();
- }
-#endif /* COMPATIBLE */
-
- offset = 0;
- bytes_out = 3; /* includes 3-byte header mojo */
- out_count = 0;
- clear_flg = 0;
- ratio = 0;
- in_count = 1;
- checkpoint = CHECK_GAP;
- maxcode = MAXCODE(n_bits = INIT_BITS);
- free_ent = ((block_compress) ? FIRST : 256 );
-
- ent = getchar ();
-
- hshift = 0;
- for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L )
- hshift++;
- hshift = 8 - hshift; /* set hash code range bound */
-
- hsize_reg = hsize;
- cl_hash( (count_int) hsize_reg); /* clear hash table */
-
-#ifdef SIGNED_COMPARE_SLOW
- while ( (c = getchar()) != (unsigned) EOF ) {
-#else
- while ( (c = getchar()) != EOF ) {
-#endif
- in_count++;
- fcode = (long) (((long) c << maxbits) + ent);
- i = ((c << hshift) ^ ent); /* xor hashing */
-
- if ( htabof (i) == fcode ) {
- ent = codetabof (i);
- continue;
- } else if ( (long)htabof (i) < 0 ) /* empty slot */
- goto nomatch;
- disp = hsize_reg - i; /* secondary hash (after G. Knott) */
- if ( i == 0 )
- disp = 1;
-probe:
- if ( (i -= disp) < 0 )
- i += hsize_reg;
-
- if ( htabof (i) == fcode ) {
- ent = codetabof (i);
- continue;
- }
- if ( (long)htabof (i) > 0 )
- goto probe;
-nomatch:
- output ( (code_int) ent );
- out_count++;
- ent = c;
-#ifdef SIGNED_COMPARE_SLOW
- if ( (unsigned) free_ent < (unsigned) maxmaxcode) {
-#else
- if ( free_ent < maxmaxcode ) {
-#endif
- codetabof (i) = free_ent++; /* code -> hashtable */
- htabof (i) = fcode;
- }
- else if ( (count_int)in_count >= checkpoint && block_compress )
- cl_block ();
- }
- /*
- * Put out the final code.
- */
- output( (code_int)ent );
- out_count++;
- output( (code_int)-1 );
-
- /*
- * Print out stats on stderr
- */
- if(zcat_flg == 0 && !quiet) {
-#ifdef DEBUG
- fprintf( stderr,
- "%ld chars in, %ld codes (%ld bytes) out, compression factor: ",
- in_count, out_count, bytes_out );
- prratio( stderr, in_count, bytes_out );
- fprintf( stderr, "\n");
- fprintf( stderr, "\tCompression as in compact: " );
- prratio( stderr, in_count-bytes_out, in_count );
- fprintf( stderr, "\n");
- fprintf( stderr, "\tLargest code (of last block) was %d (%d bits)\n",
- free_ent - 1, n_bits );
-#else /* !DEBUG */
- fprintf( stderr, "Compression: " );
- prratio( stderr, in_count-bytes_out, in_count );
-#endif /* DEBUG */
- }
- if(bytes_out > in_count) /* exit(2) if no savings */
- exit_stat = 2;
- return;
-}
-
-/*-
- * Output the given code.
- * Inputs:
- * code: A n_bits-bit integer. If == -1, then EOF. This assumes
- * that n_bits =< (long)wordsize - 1.
- * Outputs:
- * Outputs code to the file.
- * Assumptions:
- * Chars are 8 bits long.
- * Algorithm:
- * Maintain a BITS character long buffer (so that 8 codes will
- * fit in it exactly). Use the VAX insv instruction to insert each
- * code in turn. When the buffer fills up empty it and start over.
- */
-
-static char buf[BITS];
-
-#ifndef vax
-char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
-char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
-#endif /* vax */
-
-output( code )
-code_int code;
-{
-#ifdef DEBUG
- static int col = 0;
-#endif /* DEBUG */
-
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register int r_off = offset, bits= n_bits;
- register char * bp = buf;
-
-#ifdef DEBUG
- if ( verbose )
- fprintf( stderr, "%5d%c", code,
- (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
-#endif /* DEBUG */
- if ( code >= 0 ) {
-#if defined(vax) && !defined(__GNUC__)
- /*
- * VAX and PCC DEPENDENT!! Implementation on other machines is
- * below.
- *
- * Translation: Insert BITS bits from the argument starting at
- * offset bits from the beginning of buf.
- */
- 0; /* Work around for pcc -O bug with asm and if stmt */
- asm( "insv 4(ap),r11,r10,(r9)" );
-#else
-/*
- * byte/bit numbering on the VAX is simulated by the following code
- */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /*
- * Since code is always >= 8 bits, only need to mask the first
- * hunk on the left.
- */
- *bp = (*bp & rmask[r_off]) | (code << r_off) & lmask[r_off];
- bp++;
- bits -= (8 - r_off);
- code >>= 8 - r_off;
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 ) {
- *bp++ = code;
- code >>= 8;
- bits -= 8;
- }
- /* Last bits. */
- if(bits)
- *bp = code;
-#endif /* vax */
- offset += n_bits;
- if ( offset == (n_bits << 3) ) {
- bp = buf;
- bits = n_bits;
- bytes_out += bits;
- do {
- putchar(*bp++);
- if (ferror(stdout))
- writeerr();
- } while(--bits);
- offset = 0;
- }
-
- /*
- * If the next entry is going to be too big for the code size,
- * then increase it, if possible.
- */
- if ( free_ent > maxcode || (clear_flg > 0))
- {
- /*
- * Write the whole buffer, because the input side won't
- * discover the size increase until after it has read it.
- */
- if ( offset > 0 ) {
- if( fwrite( buf, 1, n_bits, stdout ) != n_bits)
- writeerr();
- bytes_out += n_bits;
- }
- offset = 0;
-
- if ( clear_flg ) {
- maxcode = MAXCODE (n_bits = INIT_BITS);
- clear_flg = 0;
- }
- else {
- n_bits++;
- if ( n_bits == maxbits )
- maxcode = maxmaxcode;
- else
- maxcode = MAXCODE(n_bits);
- }
-#ifdef DEBUG
- if ( debug ) {
- fprintf( stderr, "\nChange to %d bits\n", n_bits );
- col = 0;
- }
-#endif /* DEBUG */
- }
- } else {
- /*
- * At EOF, write the rest of the buffer.
- */
- if ( offset > 0 ) {
- offset = (offset + 7) / 8;
- if( fwrite( buf, 1, offset, stdout ) != offset )
- writeerr();
- bytes_out += offset;
- }
- offset = 0;
- (void)fflush( stdout );
- if( ferror( stdout ) )
- writeerr();
-#ifdef DEBUG
- if ( verbose )
- fprintf( stderr, "\n" );
-#endif
- }
-}
-
-/*
- * Decompress stdin to stdout. This routine adapts to the codes in the
- * file building the "string" table on-the-fly; requiring no table to
- * be stored in the compressed file. The tables used herein are shared
- * with those of the compress() routine. See the definitions above.
- */
-
-decompress() {
- register char_type *stackp;
- register int finchar;
- register code_int code, oldcode, incode;
- int n, nwritten, offset; /* Variables for buffered write */
- char buff[BUFSIZ]; /* Buffer for buffered write */
-
-
- /*
- * As above, initialize the first 256 entries in the table.
- */
- maxcode = MAXCODE(n_bits = INIT_BITS);
- for ( code = 255; code >= 0; code-- ) {
- tab_prefixof(code) = 0;
- tab_suffixof(code) = (char_type)code;
- }
- free_ent = ((block_compress) ? FIRST : 256 );
-
- finchar = oldcode = getcode();
- if(oldcode == -1) /* EOF already? */
- return; /* Get out of here */
-
- /* first code must be 8 bits = char */
- n=0;
- buff[n++] = (char)finchar;
-
- stackp = de_stack;
-
- while ( (code = getcode()) > -1 ) {
-
- if ( (code == CLEAR) && block_compress ) {
- for ( code = 255; code >= 0; code-- )
- tab_prefixof(code) = 0;
- clear_flg = 1;
- free_ent = FIRST - 1;
- if ( (code = getcode ()) == -1 ) /* O, untimely death! */
- break;
- }
- incode = code;
- /*
- * Special case for KwKwK string.
- */
- if ( code >= free_ent ) {
- *stackp++ = finchar;
- code = oldcode;
- }
-
- /*
- * Generate output characters in reverse order
- */
-#ifdef SIGNED_COMPARE_SLOW
- while ( ((unsigned long)code) >= ((unsigned long)256) ) {
-#else
- while ( code >= 256 ) {
-#endif
- *stackp++ = tab_suffixof(code);
- code = tab_prefixof(code);
- }
- *stackp++ = finchar = tab_suffixof(code);
-
- /*
- * And put them out in forward order
- */
- do {
- /*
- * About 60% of the time is spent in the putchar() call
- * that appeared here. It was originally
- * putchar ( *--stackp );
- * If we buffer the writes ourselves, we can go faster (about
- * 30%).
- *
- * At this point, the next line is the next *big* time
- * sink in the code. It takes up about 10% of the time.
- */
- buff[n++] = *--stackp;
- if (n == BUFSIZ) {
- offset = 0;
- do {
- nwritten = write(fileno(stdout), &buff[offset], n);
- if (nwritten < 0)
- writeerr();
- offset += nwritten;
- } while ((n -= nwritten) > 0);
- }
- } while ( stackp > de_stack );
-
- /*
- * Generate the new entry.
- */
- if ( (code=free_ent) < maxmaxcode ) {
- tab_prefixof(code) = (unsigned short)oldcode;
- tab_suffixof(code) = finchar;
- free_ent = code+1;
- }
- /*
- * Remember previous code.
- */
- oldcode = incode;
- }
- /*
- * Flush the stuff remaining in our buffer...
- */
- offset = 0;
- while (n > 0) {
- nwritten = write(fileno(stdout), &buff[offset], n);
- if (nwritten < 0)
- writeerr();
- offset += nwritten;
- n -= nwritten;
- }
-}
-
-/*-
- * Read one code from the standard input. If EOF, return -1.
- * Inputs:
- * stdin
- * Outputs:
- * code or -1 is returned.
- */
-code_int
-getcode() {
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register code_int code;
- static int offset = 0, size = 0;
- static char_type buf[BITS];
- register int r_off, bits;
- register char_type *bp = buf;
-
- if ( clear_flg > 0 || offset >= size || free_ent > maxcode ) {
- /*
- * If the next entry will be too big for the current code
- * size, then we must increase the size. This implies reading
- * a new buffer full, too.
- */
- if ( free_ent > maxcode ) {
- n_bits++;
- if ( n_bits == maxbits )
- maxcode = maxmaxcode; /* won't get any bigger now */
- else
- maxcode = MAXCODE(n_bits);
- }
- if ( clear_flg > 0) {
- maxcode = MAXCODE (n_bits = INIT_BITS);
- clear_flg = 0;
- }
- size = fread( buf, 1, n_bits, stdin );
- if ( size <= 0 )
- return -1; /* end of file */
- offset = 0;
- /* Round size down to integral number of codes */
- size = (size << 3) - (n_bits - 1);
- }
- r_off = offset;
- bits = n_bits;
-#ifdef vax
- asm( "extzv r10,r9,(r8),r11" );
-#else /* not a vax */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /* Get first part (low order bits) */
-#ifdef NO_UCHAR
- code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
-#else
- code = (*bp++ >> r_off);
-#endif /* NO_UCHAR */
- bits -= (8 - r_off);
- r_off = 8 - r_off; /* now, offset into code word */
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 ) {
-#ifdef NO_UCHAR
- code |= (*bp++ & 0xff) << r_off;
-#else
- code |= *bp++ << r_off;
-#endif /* NO_UCHAR */
- r_off += 8;
- bits -= 8;
- }
- /* high order bits. */
- code |= (*bp & rmask[bits]) << r_off;
-#endif /* vax */
- offset += n_bits;
-
- return code;
-}
-
-#ifdef DEBUG
-printcodes()
-{
- /*
- * Just print out codes from input file. For debugging.
- */
- code_int code;
- int col = 0, bits;
-
- bits = n_bits = INIT_BITS;
- maxcode = MAXCODE(n_bits);
- free_ent = ((block_compress) ? FIRST : 256 );
- while ( ( code = getcode() ) >= 0 ) {
- if ( (code == CLEAR) && block_compress ) {
- free_ent = FIRST - 1;
- clear_flg = 1;
- }
- else if ( free_ent < maxmaxcode )
- free_ent++;
- if ( bits != n_bits ) {
- fprintf(stderr, "\nChange to %d bits\n", n_bits );
- bits = n_bits;
- col = 0;
- }
- fprintf(stderr, "%5d%c", code, (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
- }
- putc( '\n', stderr );
- exit( 0 );
-}
-
-code_int sorttab[1<<BITS]; /* sorted pointers into htab */
-
-dump_tab() /* dump string table */
-{
- register int i, first;
- register ent;
-#define STACK_SIZE 15000
- int stack_top = STACK_SIZE;
- register c;
-
- if(do_decomp == 0) { /* compressing */
- register int flag = 1;
-
- for(i=0; i<hsize; i++) { /* build sort pointers */
- if((long)htabof(i) >= 0) {
- sorttab[codetabof(i)] = i;
- }
- }
- first = block_compress ? FIRST : 256;
- for(i = first; i < free_ent; i++) {
- fprintf(stderr, "%5d: \"", i);
- de_stack[--stack_top] = '\n';
- de_stack[--stack_top] = '"';
- stack_top = in_stack((htabof(sorttab[i])>>maxbits)&0xff,
- stack_top);
- for(ent=htabof(sorttab[i]) & ((1<<maxbits)-1);
- ent > 256;
- ent=htabof(sorttab[ent]) & ((1<<maxbits)-1)) {
- stack_top = in_stack(htabof(sorttab[ent]) >> maxbits,
- stack_top);
- }
- stack_top = in_stack(ent, stack_top);
- fwrite( &de_stack[stack_top], 1, STACK_SIZE-stack_top, stderr);
- stack_top = STACK_SIZE;
- }
- } else if(!debug) { /* decompressing */
-
- for ( i = 0; i < free_ent; i++ ) {
- ent = i;
- c = tab_suffixof(ent);
- if ( isascii(c) && isprint(c) )
- fprintf( stderr, "%5d: %5d/'%c' \"",
- ent, tab_prefixof(ent), c );
- else
- fprintf( stderr, "%5d: %5d/\\%03o \"",
- ent, tab_prefixof(ent), c );
- de_stack[--stack_top] = '\n';
- de_stack[--stack_top] = '"';
- for ( ; ent != NULL;
- ent = (ent >= FIRST ? tab_prefixof(ent) : NULL) ) {
- stack_top = in_stack(tab_suffixof(ent), stack_top);
- }
- fwrite( &de_stack[stack_top], 1, STACK_SIZE - stack_top, stderr );
- stack_top = STACK_SIZE;
- }
- }
-}
-
-int
-in_stack(c, stack_top)
- register c, stack_top;
-{
- if ( (isascii(c) && isprint(c) && c != '\\') || c == ' ' ) {
- de_stack[--stack_top] = c;
- } else {
- switch( c ) {
- case '\n': de_stack[--stack_top] = 'n'; break;
- case '\t': de_stack[--stack_top] = 't'; break;
- case '\b': de_stack[--stack_top] = 'b'; break;
- case '\f': de_stack[--stack_top] = 'f'; break;
- case '\r': de_stack[--stack_top] = 'r'; break;
- case '\\': de_stack[--stack_top] = '\\'; break;
- default:
- de_stack[--stack_top] = '0' + c % 8;
- de_stack[--stack_top] = '0' + (c / 8) % 8;
- de_stack[--stack_top] = '0' + c / 64;
- break;
- }
- de_stack[--stack_top] = '\\';
- }
- return stack_top;
-}
-#endif /* DEBUG */
-
-writeerr()
-{
- (void)fprintf(stderr, "compress: %s: %s\n",
- ofname[0] ? ofname : "stdout", strerror(errno));
- (void)unlink(ofname);
- exit(1);
-}
-
-copystat(ifname, ofname)
-char *ifname, *ofname;
-{
- struct stat statbuf;
- int mode;
- struct utimbuf tp;
-
- fclose(stdout);
- if (stat(ifname, &statbuf)) { /* Get stat on input file */
- perror(ifname);
- return;
- }
- if ((statbuf.st_mode & S_IFMT/*0170000*/) != S_IFREG/*0100000*/) {
- if(quiet)
- fprintf(stderr, "%s: ", ifname);
- fprintf(stderr, " -- not a regular file: unchanged");
- exit_stat = 1;
- perm_stat = 1;
- } else if (statbuf.st_nlink > 1) {
- if(quiet)
- fprintf(stderr, "%s: ", ifname);
- fprintf(stderr, " -- has %d other links: unchanged",
- statbuf.st_nlink - 1);
- exit_stat = 1;
- perm_stat = 1;
- } else if (exit_stat == 2 && (!force)) { /* No compression: remove file.Z */
- if(!quiet)
- fprintf(stderr, " -- file unchanged");
- } else { /* ***** Successful Compression ***** */
- exit_stat = 0;
- mode = statbuf.st_mode & 07777;
- if (chmod(ofname, mode)) /* Copy modes */
- perror(ofname);
- chown(ofname, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */
- tp.actime = statbuf.st_atime;
- tp.modtime = statbuf.st_mtime;
- utime(ofname, &tp); /* Update last accessed and modified times */
- if (unlink(ifname)) /* Remove input file */
- perror(ifname);
- if(!quiet)
- fprintf(stderr, " -- replaced with %s", ofname);
- return; /* Successful return */
- }
-
- /* Unsuccessful return -- one of the tests failed */
- if (unlink(ofname))
- perror(ofname);
-}
-
-void
-onintr ( )
-{
- if (!precious)
- unlink ( ofname );
- exit ( 1 );
-}
-
-void
-oops ( ) /* wild pointer -- assume bad input */
-{
- if ( do_decomp )
- fprintf ( stderr, "uncompress: corrupt input\n" );
- unlink ( ofname );
- exit ( 1 );
-}
-
-cl_block () /* table clear for block compress */
-{
- register long int rat;
-
- checkpoint = in_count + CHECK_GAP;
-#ifdef DEBUG
- if ( debug ) {
- fprintf ( stderr, "count: %ld, ratio: ", in_count );
- prratio ( stderr, in_count, bytes_out );
- fprintf ( stderr, "\n");
- }
-#endif /* DEBUG */
-
- if(in_count > 0x007fffff) { /* shift will overflow */
- rat = bytes_out >> 8;
- if(rat == 0) { /* Don't divide by zero */
- rat = 0x7fffffff;
- } else {
- rat = in_count / rat;
- }
- } else {
- rat = (in_count << 8) / bytes_out; /* 8 fractional bits */
- }
- if ( rat > ratio ) {
- ratio = rat;
- } else {
- ratio = 0;
-#ifdef DEBUG
- if(verbose)
- dump_tab(); /* dump string table */
-#endif
- cl_hash ( (count_int) hsize );
- free_ent = FIRST;
- clear_flg = 1;
- output ( (code_int) CLEAR );
-#ifdef DEBUG
- if(debug)
- fprintf ( stderr, "clear\n" );
-#endif /* DEBUG */
- }
-}
-
-cl_hash(hsize) /* reset code table */
- register count_int hsize;
-{
- register count_int *htab_p = htab+hsize;
- register long i;
- register long m1 = -1;
-
- i = hsize - 16;
- do { /* might use Sys V memset(3) here */
- *(htab_p-16) = m1;
- *(htab_p-15) = m1;
- *(htab_p-14) = m1;
- *(htab_p-13) = m1;
- *(htab_p-12) = m1;
- *(htab_p-11) = m1;
- *(htab_p-10) = m1;
- *(htab_p-9) = m1;
- *(htab_p-8) = m1;
- *(htab_p-7) = m1;
- *(htab_p-6) = m1;
- *(htab_p-5) = m1;
- *(htab_p-4) = m1;
- *(htab_p-3) = m1;
- *(htab_p-2) = m1;
- *(htab_p-1) = m1;
- htab_p -= 16;
- } while ((i -= 16) >= 0);
- for ( i += 16; i > 0; i-- )
- *--htab_p = m1;
-}
-
-prratio(stream, num, den)
-FILE *stream;
-long int num, den;
-{
- register int q; /* Doesn't need to be long */
-
- if(num > 214748L) { /* 2147483647/10000 */
- q = num / (den / 10000L);
- } else {
- q = 10000L * num / den; /* Long calculations, though */
- }
- if (q < 0) {
- putc('-', stream);
- q = -q;
- }
- fprintf(stream, "%d.%02d%%", q / 100, q % 100);
-}
-
-usage()
-{
- (void)fprintf(stderr,
-#ifdef DEBUG
- "compress [-CDVcdfnv] [-b maxbits] [file ...]\n");
-#else
- "compress [-Ccdfnv] [-b maxbits] [file ...]\n");
-#endif
- exit(1);
-}