summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/file.rst12
-rw-r--r--Help/guide/user-interaction/index.rst2
-rw-r--r--Help/release/dev/FindOpenSSL-version-range.rst4
-rw-r--r--Help/release/dev/file-generate-new-line-style.rst5
-rw-r--r--Modules/FindCUDAToolkit.cmake2
-rw-r--r--Modules/FindOpenSSL.cmake8
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmFileCommand.cxx28
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx31
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx7
-rw-r--r--Source/cmLocalGenerator.cxx23
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx3
-rw-r--r--Source/cmMakefile.cxx6
-rw-r--r--Source/cmMakefile.h3
-rw-r--r--Source/cmMakefileTargetGenerator.cxx4
-rw-r--r--Source/kwsys/FStream.hxx.in46
-rw-r--r--Source/kwsys/testFStream.cxx38
-rw-r--r--Tests/CMakeTests/FileDownloadTest.cmake.in3
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-shlibdeps-with-private-lib-failure.cmake2
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CPack/CPackTestHelpers.cmake6
-rw-r--r--Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake6
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-Default.cmake35
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-stderr.txt5
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg.cmake7
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-NoArg-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-NoArg-stderr.txt4
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-NoArg.cmake7
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-Unix.cmake33
-rw-r--r--Tests/RunCMake/File_Generate/NewLineStyle-Win32.cmake33
-rw-r--r--Tests/RunCMake/File_Generate/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/File_Generate/VerifyContent.cmake4
-rw-r--r--Tests/RunCMake/FindOpenSSL/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindOpenSSL/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/FindOpenSSL/version-exact.cmake19
-rw-r--r--Tests/RunCMake/FindOpenSSL/version-range.cmake37
-rw-r--r--Tests/RunCMake/FindOpenSSL/version.cmake19
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromObjLib.cmake131
-rw-r--r--Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/ctest_submit/CTestConfig.cmake.in4
42 files changed, 577 insertions, 30 deletions
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 76a07f9..3db605d 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -481,7 +481,8 @@ modified.
<INPUT input-file|CONTENT content>
[CONDITION expression] [TARGET target]
[FILE_PERMISSIONS <permissions>...]
- [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS])
+ [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
+ [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
Generate an output file for each build configuration supported by the current
:manual:`CMake Generator <cmake-generators(7)>`. Evaluate
@@ -533,6 +534,13 @@ from the input content to produce the output content. The options are:
Transfer the file permissions of the original file to the generated file.
This option expects INPUT option.
+``NEWLINE_STYLE <style>``
+ .. versionadded:: 3.20
+
+ Specify the newline style for the generated file. Specify
+ ``UNIX`` or ``LF`` for ``\n`` newlines, or specify
+ ``DOS``, ``WIN32``, or ``CRLF`` for ``\r\n`` newlines.
+
Exactly one ``CONTENT`` or ``INPUT`` option must be given. A specific
``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``.
Generated files are modified and their timestamp updated on subsequent cmake
@@ -825,7 +833,7 @@ which would make them unable to support a hard link.
Set the permissions for the ``<files>...`` and ``<directories>...`` specified.
Valid permissions are ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``,
``GROUP_READ``, ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``,
-``WORLD_WRITE``, ``WORLD_EXECUTE``.
+``WORLD_WRITE``, ``WORLD_EXECUTE``, ``SETUID``, ``SETGID``.
Valid combination of keywords are:
diff --git a/Help/guide/user-interaction/index.rst b/Help/guide/user-interaction/index.rst
index 9e9f2a5..ba8196b 100644
--- a/Help/guide/user-interaction/index.rst
+++ b/Help/guide/user-interaction/index.rst
@@ -228,7 +228,7 @@ The Visual Studio toolset can be specified with the
.. code-block:: console
$ # Build with the clang-cl toolset
- $ cmake.exe .. -G "Visual Studio 16 2019" -A x64 -T LLVM
+ $ cmake.exe .. -G "Visual Studio 16 2019" -A x64 -T ClangCL
$ # Build targeting Windows XP
$ cmake.exe .. -G "Visual Studio 16 2019" -A x64 -T v120_xp
diff --git a/Help/release/dev/FindOpenSSL-version-range.rst b/Help/release/dev/FindOpenSSL-version-range.rst
new file mode 100644
index 0000000..660bc75
--- /dev/null
+++ b/Help/release/dev/FindOpenSSL-version-range.rst
@@ -0,0 +1,4 @@
+FindOpenSSL-version-range
+-------------------------
+
+* :module:`FindOpenSSL` module gains the capability to manage a version range.
diff --git a/Help/release/dev/file-generate-new-line-style.rst b/Help/release/dev/file-generate-new-line-style.rst
new file mode 100644
index 0000000..b629b46
--- /dev/null
+++ b/Help/release/dev/file-generate-new-line-style.rst
@@ -0,0 +1,5 @@
+file-generate-new-line-style
+----------------------------
+
+* The :command:`file(GENERATE)` command gained ``NEWLINE_STYLE`` option to
+ support newline style of the generated file.
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 0d80c80..ac2516c 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -578,7 +578,7 @@ else()
_CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH)
endif()
if(NOT CUDAToolkit_ROOT_DIR)
- _CUDAToolkit_find_root_dir(FIND_FLAGS PATHS "ENV CUDA_PATH" PATH_SUFFIXES bin)
+ _CUDAToolkit_find_root_dir(FIND_FLAGS PATHS ENV CUDA_PATH PATH_SUFFIXES bin)
endif()
# If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error.
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index d574790..b1afa5f 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -7,6 +7,13 @@ FindOpenSSL
Find the OpenSSL encryption library.
+This module finds an installed OpenSSL library and determines its version.
+
+.. versionadded:: 3.19
+ When a version is requested, it can be specified as a simple value or as a
+ range. For a detailed description of version range usage and capabilities,
+ refer to the :command:`find_package` command.
+
.. versionadded:: 3.18
Support for OpenSSL 3.0.
@@ -566,6 +573,7 @@ find_package_handle_standard_args(OpenSSL
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
+ HANDLE_VERSION_RANGE
HANDLE_COMPONENTS
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 649d5e0..685baf2 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 19)
-set(CMake_VERSION_PATCH 20210201)
+set(CMake_VERSION_PATCH 20210203)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 9377baa..031e0d7 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2290,7 +2290,8 @@ void AddEvaluationFile(const std::string& inputName,
const std::string& targetName,
const std::string& outputExpr,
const std::string& condition, bool inputIsContent,
- mode_t permissions, cmExecutionStatus& status)
+ const std::string& newLineCharacter, mode_t permissions,
+ cmExecutionStatus& status)
{
cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace();
@@ -2304,7 +2305,7 @@ void AddEvaluationFile(const std::string& inputName,
status.GetMakefile().AddEvaluationFile(
inputName, targetName, std::move(outputCge), std::move(conditionCge),
- permissions, inputIsContent);
+ newLineCharacter, permissions, inputIsContent);
}
bool HandleGenerateCommand(std::vector<std::string> const& args,
@@ -2322,6 +2323,7 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
std::string Content;
std::string Condition;
std::string Target;
+ std::string NewLineStyle;
bool NoSourcePermissions = false;
bool UseSourcePermissions = false;
std::vector<std::string> FilePermissions;
@@ -2336,7 +2338,8 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
.Bind("TARGET"_s, &Arguments::Target)
.Bind("NO_SOURCE_PERMISSIONS"_s, &Arguments::NoSourcePermissions)
.Bind("USE_SOURCE_PERMISSIONS"_s, &Arguments::UseSourcePermissions)
- .Bind("FILE_PERMISSIONS"_s, &Arguments::FilePermissions);
+ .Bind("FILE_PERMISSIONS"_s, &Arguments::FilePermissions)
+ .Bind("NEWLINE_STYLE"_s, &Arguments::NewLineStyle);
std::vector<std::string> unparsedArguments;
std::vector<std::string> keywordsMissingValues;
@@ -2400,6 +2403,18 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
status.SetError("Unknown argument to GENERATE subcommand.");
}
+ const bool newLineStyleSpecified =
+ std::find(parsedKeywords.begin(), parsedKeywords.end(),
+ "NEWLINE_STYLE"_s) != parsedKeywords.end();
+ cmNewLineStyle newLineStyle;
+ if (newLineStyleSpecified) {
+ std::string errorMessage;
+ if (!newLineStyle.ReadFromArguments(args, errorMessage)) {
+ status.SetError(cmStrCat("GENERATE ", errorMessage));
+ return false;
+ }
+ }
+
std::string input = arguments.Input;
if (inputIsContent) {
input = arguments.Content;
@@ -2463,7 +2478,8 @@ bool HandleGenerateCommand(std::vector<std::string> const& args,
}
AddEvaluationFile(input, arguments.Target, arguments.Output,
- arguments.Condition, inputIsContent, permisiions, status);
+ arguments.Condition, inputIsContent,
+ newLineStyle.GetCharacters(), permisiions, status);
return true;
}
@@ -3106,12 +3122,14 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
}
std::string newLineCharacters = "\n";
+ bool open_with_binary_flag = false;
if (newLineStyle.IsValid()) {
newLineCharacters = newLineStyle.GetCharacters();
+ open_with_binary_flag = true;
}
cmGeneratedFileStream fout;
- fout.Open(outputFile, false, true);
+ fout.Open(outputFile, false, open_with_binary_flag);
if (!fout) {
cmSystemTools::Error("Could not open file for write in copy operation " +
outputFile);
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index ec44df3..9fae15a 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -21,13 +21,14 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
std::string input, std::string target,
std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
- bool inputIsContent, mode_t permissions,
+ bool inputIsContent, std::string newLineCharacter, mode_t permissions,
cmPolicies::PolicyStatus policyStatusCMP0070)
: Input(std::move(input))
, Target(std::move(target))
, OutputFileExpr(std::move(outputFileExpr))
, Condition(std::move(condition))
, InputIsContent(inputIsContent)
+ , NewLineCharacter(std::move(newLineCharacter))
, PolicyStatusCMP0070(policyStatusCMP0070)
, Permissions(permissions)
{
@@ -82,9 +83,33 @@ void cmGeneratorExpressionEvaluationFile::Generate(
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
- cmGeneratedFileStream fout(outputFileName);
+ bool openWithBinaryFlag = false;
+ if (!this->NewLineCharacter.empty()) {
+ openWithBinaryFlag = true;
+ }
+ cmGeneratedFileStream fout;
+ fout.Open(outputFileName, false, openWithBinaryFlag);
+ if (!fout) {
+ lg->IssueMessage(MessageType::FATAL_ERROR,
+ "Could not open file for write in copy operation " +
+ outputFileName);
+ return;
+ }
fout.SetCopyIfDifferent(true);
- fout << outputContent;
+ std::istringstream iss(outputContent);
+ std::string line;
+ bool hasNewLine = false;
+ while (cmSystemTools::GetLineFromStream(iss, line, &hasNewLine)) {
+ fout << line;
+ if (!this->NewLineCharacter.empty()) {
+ fout << this->NewLineCharacter;
+ } else if (hasNewLine) {
+ // if new line character is not specified, the file will be opened in
+ // text mode. So, "\n" will be translated to the correct newline
+ // ending based on the platform.
+ fout << "\n";
+ }
+ }
if (fout.Close() && perm) {
cmSystemTools::SetPermissions(outputFileName.c_str(), perm);
}
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 9a870ac..0eb78ac 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -24,7 +24,7 @@ public:
std::string input, std::string target,
std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
- bool inputIsContent, mode_t permissions,
+ bool inputIsContent, std::string newLineCharacter, mode_t permissions,
cmPolicies::PolicyStatus policyStatusCMP0070);
void Generate(cmLocalGenerator* lg);
@@ -58,6 +58,7 @@ private:
const std::unique_ptr<cmCompiledGeneratorExpression> Condition;
std::vector<std::string> Files;
const bool InputIsContent;
+ const std::string NewLineCharacter;
cmPolicies::PolicyStatus PolicyStatusCMP0070;
mode_t Permissions;
};
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 8a1ccd1..60d108b 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -47,8 +47,11 @@
struct cmLinkImplementation;
#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__)
-# define HAVE_APPLICATION_SERVICES
-# include <ApplicationServices/ApplicationServices.h>
+# include <CoreFoundation/CoreFoundation.h>
+# if !TARGET_OS_IPHONE
+# define HAVE_APPLICATION_SERVICES
+# include <ApplicationServices/ApplicationServices.h>
+# endif
#endif
#if !defined(CMAKE_BOOTSTRAP)
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 349b53b..3111911 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2610,16 +2610,25 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
}
}
- if (reuseTarget->GetType() != cmStateEnums::OBJECT_LIBRARY) {
- std::string pchSourceObj =
- reuseTarget->GetPchFileObject(config, lang, arch);
-
- // Link to the pch object file
+ // Link to the pch object file
+ std::string pchSourceObj =
+ reuseTarget->GetPchFileObject(config, lang, arch);
+
+ if (target->GetType() != cmStateEnums::OBJECT_LIBRARY) {
+ std::string linkerProperty = "LINK_FLAGS_";
+ if (target->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ linkerProperty = "STATIC_LIBRARY_FLAGS_";
+ }
target->Target->AppendProperty(
- cmStrCat("LINK_FLAGS_", configUpper),
+ cmStrCat(linkerProperty, configUpper),
cmStrCat(" ",
this->ConvertToOutputFormat(pchSourceObj, SHELL)),
true);
+ } else {
+ target->Target->AppendProperty(
+ "INTERFACE_LINK_LIBRARIES",
+ cmStrCat("$<$<CONFIG:", config,
+ ">:$<LINK_ONLY:", pchSourceObj, ">>"));
}
}
} else {
@@ -2738,7 +2747,7 @@ void cmLocalGenerator::CopyPchCompilePdb(
this->AddCustomCommandToTarget(
target->GetName(), outputs, no_deps, commandLines,
cmCustomCommandType::PRE_BUILD, no_message, no_current_dir, true, false,
- "", "", false, cmObjectLibraryCommands::Reject, stdPipesUTF8);
+ "", "", false, cmObjectLibraryCommands::Accept, stdPipesUTF8);
} else {
cmImplicitDependsList no_implicit_depends;
cmSourceFile* copy_rule = this->AddCustomCommandToOutput(
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index d2cdb99..97869c2 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1010,7 +1010,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
this->GetStaticLibraryFlags(
libflags, configName, target->GetLinkerLanguage(configName), target);
if (!libflags.empty()) {
- fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
+ fout << "\t\t\t\tAdditionalOptions=\"" << this->EscapeForXML(libflags)
+ << "\"\n";
}
fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(libpath) << "\"/>\n";
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f479af1..e485986 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -865,13 +865,13 @@ void cmMakefile::EnforceDirectoryLevelRules() const
void cmMakefile::AddEvaluationFile(
const std::string& inputFile, const std::string& targetName,
std::unique_ptr<cmCompiledGeneratorExpression> outputName,
- std::unique_ptr<cmCompiledGeneratorExpression> condition, mode_t permissions,
- bool inputIsContent)
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ const std::string& newLineCharacter, mode_t permissions, bool inputIsContent)
{
this->EvaluationFiles.push_back(
cm::make_unique<cmGeneratorExpressionEvaluationFile>(
inputFile, targetName, std::move(outputName), std::move(condition),
- inputIsContent, permissions,
+ inputIsContent, newLineCharacter, permissions,
this->GetPolicyStatus(cmPolicies::CMP0070)));
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 60b66a2..6341abc 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -899,7 +899,8 @@ public:
const std::string& inputFile, const std::string& targetName,
std::unique_ptr<cmCompiledGeneratorExpression> outputName,
std::unique_ptr<cmCompiledGeneratorExpression> condition,
- mode_t permissions, bool inputIsContent);
+ const std::string& newLineCharacter, mode_t permissions,
+ bool inputIsContent);
const std::vector<std::unique_ptr<cmGeneratorExpressionEvaluationFile>>&
GetEvaluationFiles() const;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index adf40b0..4918bf6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -815,6 +815,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// avoiding a trailing backslash in the argument.
targetOutPathCompilePDB.back() = '/';
}
+
+ std::string compilePdbOutputPath =
+ this->GeneratorTarget->GetCompilePDBDirectory(this->GetConfigName());
+ cmSystemTools::MakeDirectory(compilePdbOutputPath);
}
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GeneratorTarget->GetName().c_str();
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index b424488..55a7fb1 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -167,6 +167,50 @@ protected:
};
template <typename CharType, typename Traits = std::char_traits<CharType> >
+class basic_fstream
+ : public std::basic_iostream<CharType, Traits>
+ , public basic_efilebuf<CharType, Traits>
+{
+public:
+ typedef typename basic_efilebuf<CharType, Traits>::internal_buffer_type
+ internal_buffer_type;
+ typedef std::basic_iostream<CharType, Traits> internal_stream_type;
+
+ basic_fstream()
+ : internal_stream_type(new internal_buffer_type())
+ {
+ this->buf_ =
+ static_cast<internal_buffer_type*>(internal_stream_type::rdbuf());
+ }
+ explicit basic_fstream(char const* file_name,
+ std::ios_base::openmode mode = std::ios_base::in |
+ std::ios_base::out)
+ : internal_stream_type(new internal_buffer_type())
+ {
+ this->buf_ =
+ static_cast<internal_buffer_type*>(internal_stream_type::rdbuf());
+ open(file_name, mode);
+ }
+
+ void open(char const* file_name,
+ std::ios_base::openmode mode = std::ios_base::in |
+ std::ios_base::out)
+ {
+ this->_set_state(this->_open(file_name, mode), this, this);
+ }
+
+ bool is_open() { return this->_is_open(); }
+
+ void close() { this->_set_state(this->_close(), this, this); }
+
+ using basic_efilebuf<CharType, Traits>::_is_open;
+
+ internal_buffer_type* rdbuf() const { return this->buf_; }
+
+ ~basic_fstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT { close(); }
+};
+
+template <typename CharType, typename Traits = std::char_traits<CharType> >
class basic_ifstream
: public std::basic_istream<CharType, Traits>
, public basic_efilebuf<CharType, Traits>
@@ -251,11 +295,13 @@ public:
~basic_ofstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT { close(); }
};
+typedef basic_fstream<char> fstream;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
# undef @KWSYS_NAMESPACE@_FStream_NOEXCEPT
#else
+using std::fstream;
using std::ofstream;
using std::ifstream;
#endif
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index afba953..3325e20 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -99,12 +99,50 @@ static int testBOM()
return 0;
}
+static int testBOMIO()
+{
+ // test various encodings in binary mode
+ for (int i = 0; i < num_test_files; i++) {
+ kwsys::fstream f("bomio.txt",
+ kwsys::fstream::in | kwsys::fstream::out |
+ kwsys::fstream::binary | kwsys::fstream::trunc);
+ f.write(reinterpret_cast<const char*>(expected_bom_data[i] + 1),
+ *expected_bom_data[i]);
+ f.write(reinterpret_cast<const char*>(file_data[i] + 1), file_data[i][0]);
+ if (!f.good()) {
+ std::cout << "Unable to write data " << i << std::endl;
+ return 1;
+ }
+ f.seekp(0);
+
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(f);
+ if (bom != expected_bom[i]) {
+ std::cout << "Unexpected BOM " << i << std::endl;
+ return 1;
+ }
+ char data[max_test_file_size];
+ f.read(data, file_data[i][0]);
+ if (!f.good()) {
+ std::cout << "Unable to read data " << i << std::endl;
+ return 1;
+ }
+
+ if (memcmp(data, file_data[i] + 1, file_data[i][0]) != 0) {
+ std::cout << "Incorrect read data " << i << std::endl;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
int testFStream(int, char* [])
{
int ret = 0;
ret |= testNoFile();
ret |= testBOM();
+ ret |= testBOMIO();
return ret;
}
diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in
index 69d9a14..e0ce99a 100644
--- a/Tests/CMakeTests/FileDownloadTest.cmake.in
+++ b/Tests/CMakeTests/FileDownloadTest.cmake.in
@@ -136,6 +136,9 @@ __reportIfWrongStatus("${status}" 0)
# Print status because we check its message too
message(STATUS "${status}")
+# do not use proxy for lookup of invalid site (DNS failure by proxy looks
+# different than DNS failure without proxy)
+set(ENV{no_proxy} "$ENV{no_proxy},badhostname.invalid")
message(STATUS "FileDownload:11")
file(DOWNLOAD
badhostname.invalid
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-shlibdeps-with-private-lib-failure.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-shlibdeps-with-private-lib-failure.cmake
index 547852d7..962a1fb 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-shlibdeps-with-private-lib-failure.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-shlibdeps-with-private-lib-failure.cmake
@@ -13,7 +13,7 @@ run_cpack(actual_output
CONFIG_ARGS ${config_args}
CONFIG_VERBOSE ${config_verbose})
-string(REGEX MATCH "dpkg-shlibdeps: error: (cannot|couldn't) find library\n[ \t]*libmyprivatelib.so.1 needed by ./usr/bin/mylibapp3" expected_error ${CPack_error})
+string(REGEX MATCH "dpkg-shlibdeps: error: (cannot|couldn't) find[ \n\t]+library[ \n\t]+libmyprivatelib.so.1[ \n\t]+needed[ \n\t]+by[ \n\t]+./usr/bin/mylibapp3" expected_error ${CPack_error})
if(NOT expected_error)
message(FATAL_ERROR "Did not get the expected error-message!")
endif()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 323306a..f58e2f3 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -239,6 +239,9 @@ add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
add_RunCMake_test(FindBoost)
add_RunCMake_test(FindLua)
add_RunCMake_test(FindOpenGL)
+if(CMake_TEST_FindOpenSSL)
+ add_RunCMake_test(FindOpenSSL)
+endif()
if(CMake_TEST_UseSWIG)
add_RunCMake_test(FindSWIG)
add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython})
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
index 24f54c6..3ec4c69 100644
--- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -21,6 +21,12 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK
# TODO this should be executed only once per ctest run (not per generator)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ # Set permissions to those expected by the test
+ file(CHMOD "${RunCMake_TEST_BINARY_DIR}"
+ PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake")
include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake")
diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake
index 09aec45..5e35e5c 100644
--- a/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake
+++ b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake
@@ -22,4 +22,8 @@ test_eol(CRLF "c" "630d0a")
test_eol(UNIX "d" "640a")
test_eol(LF "e" "650a")
-test_eol("" "a\nb" "610a62")
+if (WIN32)
+ test_eol("" "a\nb" "610d0a62")
+elseif(UNIX)
+ test_eol("" "a\nb" "610a62")
+endif()
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-Default.cmake b/Tests/RunCMake/File_Generate/NewLineStyle-Default.cmake
new file mode 100644
index 0000000..9df8ffe
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-Default.cmake
@@ -0,0 +1,35 @@
+function(generate_from_file in out)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt "${in}")
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ INPUT ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt
+ )
+
+ add_custom_target(verifyContentFromFile ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+function(generate_from_content in out)
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ CONTENT ${in}
+ )
+
+ add_custom_target(verifyContentFromContent ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+if (WIN32)
+ generate_from_file("a" "610d0a") # 62->b, 0d0a->\r\n
+elseif(UNIX)
+ generate_from_file("a" "610a") # 62->b, 0a->\n
+endif()
+generate_from_content("a" "61")
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-result.txt b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-stderr.txt b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-stderr.txt
new file mode 100644
index 0000000..44e32d0
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at NewLineStyle-InvalidArg.cmake:[0-9]+ \(file\):
+ file GENERATE NEWLINE_STYLE sets an unknown style, only LF, CRLF, UNIX,
+ DOS, and WIN32 are supported
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg.cmake b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg.cmake
new file mode 100644
index 0000000..578cf21
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-InvalidArg.cmake
@@ -0,0 +1,7 @@
+file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
+ CONTENT "int main() { return 0; }\n"
+ NEWLINE_STYLE FOO
+ )
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-result.txt b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-stderr.txt b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-stderr.txt
new file mode 100644
index 0000000..bc71f2f
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NewLineStyle-NoArg.cmake:[0-9]+ \(file\):
+ file Incorrect arguments to GENERATE subcommand.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-NoArg.cmake b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg.cmake
new file mode 100644
index 0000000..9bd2ffa
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-NoArg.cmake
@@ -0,0 +1,7 @@
+file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
+ CONTENT "int main() { return 0; }\n"
+ NEWLINE_STYLE
+ )
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-Unix.cmake b/Tests/RunCMake/File_Generate/NewLineStyle-Unix.cmake
new file mode 100644
index 0000000..7c26217
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-Unix.cmake
@@ -0,0 +1,33 @@
+function(generate_from_file in out)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt "${in}")
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ INPUT ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt
+ NEWLINE_STYLE UNIX
+ )
+
+ add_custom_target(verifyContentFromFile ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+function(generate_from_content in out)
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ CONTENT ${in}
+ NEWLINE_STYLE UNIX
+ )
+
+ add_custom_target(verifyContentFromContent ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+generate_from_file("a" "610a") # 62->b, 0a->\n
+generate_from_content("a" "610a")
diff --git a/Tests/RunCMake/File_Generate/NewLineStyle-Win32.cmake b/Tests/RunCMake/File_Generate/NewLineStyle-Win32.cmake
new file mode 100644
index 0000000..394ef75
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/NewLineStyle-Win32.cmake
@@ -0,0 +1,33 @@
+function(generate_from_file in out)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt "${in}")
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ INPUT ${CMAKE_CURRENT_BINARY_DIR}/file_ip.txt
+ NEWLINE_STYLE WIN32
+ )
+
+ add_custom_target(verifyContentFromFile ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/file_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+function(generate_from_content in out)
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ CONTENT ${in}
+ NEWLINE_STYLE WIN32
+ )
+
+ add_custom_target(verifyContentFromContent ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DgeneratedFile=${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>>/content_op.txt
+ -DexpectedContent=${out}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyContent.cmake"
+ )
+endfunction()
+
+generate_from_file("a" "610d0a") # 62->b, 0d0a->\r\n
+generate_from_content("a" "610d0a")
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index 51491af..be3bf04 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -135,6 +135,11 @@ function(run_cmake_and_verify_after_build case)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
set(RunCMake_TEST_NO_CLEAN 1)
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug)
+ else()
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
run_cmake(${case})
run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .)
unset(RunCMake_TEST_NO_CLEAN)
@@ -144,3 +149,9 @@ endfunction()
run_cmake_and_verify_after_build(NoSourcePermissions)
run_cmake_and_verify_after_build(UseSourcePermissions)
run_cmake_and_verify_after_build(CustomFilePermissions)
+
+run_cmake(NewLineStyle-NoArg)
+run_cmake(NewLineStyle-InvalidArg)
+run_cmake_and_verify_after_build(NewLineStyle-Default)
+run_cmake_and_verify_after_build(NewLineStyle-Unix)
+run_cmake_and_verify_after_build(NewLineStyle-Win32)
diff --git a/Tests/RunCMake/File_Generate/VerifyContent.cmake b/Tests/RunCMake/File_Generate/VerifyContent.cmake
new file mode 100644
index 0000000..8563708
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/VerifyContent.cmake
@@ -0,0 +1,4 @@
+file(READ ${generatedFile} actualContent HEX)
+if(NOT "${actualContent}" STREQUAL "${expectedContent}")
+ message(SEND_ERROR "Content mismatch actual: \"${actualContent}\" expected: \"${expectedContent}\"")
+endif()
diff --git a/Tests/RunCMake/FindOpenSSL/CMakeLists.txt b/Tests/RunCMake/FindOpenSSL/CMakeLists.txt
new file mode 100644
index 0000000..4fc11ae
--- /dev/null
+++ b/Tests/RunCMake/FindOpenSSL/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.19...3.20)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindOpenSSL/RunCMakeTest.cmake b/Tests/RunCMake/FindOpenSSL/RunCMakeTest.cmake
new file mode 100644
index 0000000..f941a85
--- /dev/null
+++ b/Tests/RunCMake/FindOpenSSL/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(version)
+run_cmake(version-exact)
+run_cmake(version-range)
diff --git a/Tests/RunCMake/FindOpenSSL/version-exact.cmake b/Tests/RunCMake/FindOpenSSL/version-exact.cmake
new file mode 100644
index 0000000..29c2ce3
--- /dev/null
+++ b/Tests/RunCMake/FindOpenSSL/version-exact.cmake
@@ -0,0 +1,19 @@
+cmake_minimum_required (VERSION 3.19...3.20)
+
+find_package (OpenSSL REQUIRED COMPONENTS Crypto)
+# Store version without a possibly trailing letter.
+string (REGEX MATCH "^([0-9.]+)" version "${OPENSSL_VERSION}")
+
+# clean-up OpenSSL variables
+unset (OPENSSL_INCLUDE_DIR)
+unset (OPENSSL_CRYPTO_LIBRARY)
+unset (OPENSSL_CRYPTO_LIBRARIES)
+unset (OPENSSL_LIBRARIES)
+unset (OPENSSL_VERSION)
+unset (OPENSSL_FOUND)
+
+
+find_package (OpenSSL ${version} EXACT COMPONENTS Crypto)
+if (NOT OPENSSL_FOUND)
+ message (FATAL_ERROR "Failed to find OpenSSL with version ${version} EXACT")
+endif()
diff --git a/Tests/RunCMake/FindOpenSSL/version-range.cmake b/Tests/RunCMake/FindOpenSSL/version-range.cmake
new file mode 100644
index 0000000..9390032
--- /dev/null
+++ b/Tests/RunCMake/FindOpenSSL/version-range.cmake
@@ -0,0 +1,37 @@
+cmake_minimum_required (VERSION 3.19...3.20)
+
+find_package (OpenSSL REQUIRED COMPONENTS Crypto)
+# Store version without a possibly trailing letter.
+string (REGEX MATCH "^([0-9.]+)" version "${OPENSSL_VERSION}")
+
+# clean-up OpenSSL variables
+unset (OPENSSL_INCLUDE_DIR)
+unset (OPENSSL_CRYPTO_LIBRARY)
+unset (OPENSSL_CRYPTO_LIBRARIES)
+unset (OPENSSL_LIBRARIES)
+unset (OPENSSL_VERSION)
+unset (OPENSSL_FOUND)
+
+## Specify a range including current OpenSSL version
+string (REGEX MATCH "^([0-9]+)" upper_version "${version}")
+math (EXPR upper_version "${upper_version} + 1")
+
+find_package (OpenSSL 0.9...${upper_version}.0 COMPONENTS Crypto)
+if (NOT OPENSSL_FOUND)
+ message (FATAL_ERROR "Failed to find OpenSSL with version range 0.9...${upper_version}.0")
+endif()
+
+# clean-up OpenSSL variables
+unset (OPENSSL_INCLUDE_DIR)
+unset (OPENSSL_CRYPTO_LIBRARY)
+unset (OPENSSL_CRYPTO_LIBRARIES)
+unset (OPENSSL_LIBRARIES)
+unset (OPENSSL_VERSION)
+unset (OPENSSL_FOUND)
+
+## Specify a range excluding current OpenSSL version
+set (range 0.9...<${version})
+find_package (OpenSSL ${range} COMPONENTS Crypto)
+if (OPENSSL_FOUND)
+ message (FATAL_ERROR "Unexpectedly find OpenSSL with version range ${range}")
+endif()
diff --git a/Tests/RunCMake/FindOpenSSL/version.cmake b/Tests/RunCMake/FindOpenSSL/version.cmake
new file mode 100644
index 0000000..d06cd1f
--- /dev/null
+++ b/Tests/RunCMake/FindOpenSSL/version.cmake
@@ -0,0 +1,19 @@
+cmake_minimum_required (VERSION 3.19...3.20)
+
+find_package (OpenSSL REQUIRED COMPONENTS Crypto)
+# Store version without a possibly trailing letter.
+string (REGEX MATCH "^([0-9.]+)" version "${OPENSSL_VERSION}")
+
+# clean-up OpenSSL variables
+unset (OPENSSL_INCLUDE_DIR)
+unset (OPENSSL_CRYPTO_LIBRARY)
+unset (OPENSSL_CRYPTO_LIBRARIES)
+unset (OPENSSL_LIBRARIES)
+unset (OPENSSL_VERSION)
+unset (OPENSSL_FOUND)
+
+
+find_package (OpenSSL ${version} COMPONENTS Crypto)
+if (NOT OPENSSL_FOUND)
+ message (FATAL_ERROR "Failed to find OpenSSL with version ${version}")
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromObjLib.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromObjLib.cmake
new file mode 100644
index 0000000..ba504a3
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromObjLib.cmake
@@ -0,0 +1,131 @@
+cmake_minimum_required(VERSION 3.18)
+
+project(PchReuseFromObjLib)
+
+set(CMAKE_PCH_WARN_INVALID OFF)
+
+if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH)
+ add_definitions(-DHAVE_PCH_SUPPORT)
+endif()
+
+######################################################################
+
+file(WRITE ${CMAKE_BINARY_DIR}/CONFIG/config.hxx "/*empty*/\n")
+
+file(WRITE ${CMAKE_BINARY_DIR}/pch.cxx [=[
+void nothing()
+{
+}
+]=])
+
+file(WRITE ${CMAKE_BINARY_DIR}/string.hxx [=[
+#include <string.h>
+
+namespace std {
+ struct string
+ {
+ char storage[20];
+
+ string(const char* s) {
+ strcpy(storage, s);
+ }
+
+ const char* c_str() const {
+ return storage;
+ }
+ };
+}
+]=])
+
+add_library(pch-generator OBJECT ${CMAKE_BINARY_DIR}/pch.cxx)
+set_property(TARGET pch-generator PROPERTY POSITION_INDEPENDENT_CODE ON)
+target_precompile_headers(pch-generator PRIVATE ${CMAKE_BINARY_DIR}/string.hxx)
+
+target_include_directories(pch-generator PRIVATE ${CMAKE_BINARY_DIR}/CONFIG)
+
+######################################################################
+
+file(WRITE ${CMAKE_BINARY_DIR}/message.cxx [=[
+#include "message.hxx"
+
+#ifndef HAVE_PCH_SUPPORT
+ #include "string.hxx"
+#endif
+
+const char* message()
+{
+ static std::string greeting("hi there");
+ return greeting.c_str();
+}
+]=])
+
+file(WRITE ${CMAKE_BINARY_DIR}/message.hxx [=[
+#include "config.hxx"
+#ifdef WIN32_BUILD_SHARED
+ #ifdef BUILD_LIBRARY
+ #define MESSAGE_EXPORT __declspec(dllexport)
+ #else
+ #define MESSAGE_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define MESSAGE_EXPORT
+#endif
+
+MESSAGE_EXPORT const char* message();
+]=])
+
+######################################################################
+
+file(WRITE ${CMAKE_BINARY_DIR}/main.cxx [=[
+#include "message.hxx"
+#include <string.h>
+
+int main()
+{
+ return strcmp(message(), "hi there");
+}
+]=])
+
+######################################################################
+
+enable_testing()
+
+function(add_library_and_executable type)
+ add_library(message_${type} ${type} ${CMAKE_BINARY_DIR}/message.cxx)
+ target_precompile_headers(message_${type} REUSE_FROM pch-generator)
+
+ set_property(TARGET message_${type} PROPERTY POSITION_INDEPENDENT_CODE ON)
+ set_property(TARGET message_${type} PROPERTY DEFINE_SYMBOL "")
+
+ if (WIN32 AND type STREQUAL "SHARED")
+ file(WRITE ${CMAKE_BINARY_DIR}/SHARED/config.hxx [=[
+ #define BUILD_LIBRARY
+ #define WIN32_BUILD_SHARED
+ ]=])
+ target_include_directories(message_${type} PRIVATE ${CMAKE_BINARY_DIR}/SHARED)
+
+ # Workaround for VS2008, the compiler fails with
+ # c1xx : fatal error C1083: Cannot open source file: '_WINDLL': No such file or directory
+ file(WRITE ${CMAKE_BINARY_DIR}/_WINDLL "/*empty*/\n")
+ else()
+ target_include_directories(message_${type} PRIVATE ${CMAKE_BINARY_DIR}/CONFIG)
+ endif()
+
+ add_executable(main_${type} ${CMAKE_BINARY_DIR}/main.cxx)
+ target_include_directories(main_${type} PRIVATE ${CMAKE_BINARY_DIR})
+
+ if (WIN32 AND type STREQUAL "SHARED")
+ file(WRITE ${CMAKE_BINARY_DIR}/main_SHARED/config.hxx "#define WIN32_BUILD_SHARED\n")
+ target_include_directories(main_${type} PRIVATE ${CMAKE_BINARY_DIR}/main_SHARED)
+ else()
+ target_include_directories(main_${type} PRIVATE ${CMAKE_BINARY_DIR}/CONFIG)
+ endif()
+
+ target_link_libraries(main_${type} PRIVATE message_${type})
+
+ add_test(NAME main_${type} COMMAND main_${type})
+endfunction()
+
+foreach(type OBJECT STATIC SHARED)
+ add_library_and_executable(${type})
+endforeach()
diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
index 74670ba..a5a3770 100644
--- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
@@ -26,3 +26,4 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
run_cmake(PchInstantiateTemplates)
endif()
endif()
+run_test(PchReuseFromObjLib)
diff --git a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
index 140e4be..c35397c 100644
--- a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
+++ b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
@@ -3,3 +3,7 @@
# so that any ctest_submit calls fail with an error message.
set(CTEST_DROP_METHOD "@CASE_DROP_METHOD@")
set(CTEST_DROP_SITE "@CASE_DROP_SITE@")
+
+# do not use proxy for lookup of invalid site (DNS failure by proxy looks
+# different than DNS failure without proxy)
+set(ENV{no_proxy} "$ENV{no_proxy},@CASE_DROP_SITE@")