diff options
29 files changed, 301 insertions, 111 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9e0efe9..d9da3d6 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -396,6 +396,7 @@ Variables for Languages /variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS /variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES /variable/CMAKE_LANG_STANDARD_LIBRARIES + /variable/CMAKE_Swift_LANGUAGE_VERSION /variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG Variables for CTest diff --git a/Help/release/dev/FindMatlab-simulink.rst b/Help/release/dev/FindMatlab-simulink.rst new file mode 100644 index 0000000..cd25412 --- /dev/null +++ b/Help/release/dev/FindMatlab-simulink.rst @@ -0,0 +1,4 @@ +FindMatlab-simulink +------------------- + +* The :module:`FindMatlab` module learned to find a SIMULINK component. diff --git a/Help/release/dev/cpack-deb-package-description-fallback.rst b/Help/release/dev/cpack-deb-package-description-fallback.rst deleted file mode 100644 index 71ca821..0000000 --- a/Help/release/dev/cpack-deb-package-description-fallback.rst +++ /dev/null @@ -1,15 +0,0 @@ -cpack-deb-package-description-fallback --------------------------------------- - -* The :module:`CPackDeb` module gained a new - :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DESCRIPTION` - variable for component-specific package descriptions. - -* The :module:`CPackDeb` module changed its package description - override rules to match :module:`CPackRPM` module behavior. - If the :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` variable is set to - a non-default location then it is preferred to the - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` variable. - This is a behavior change from previous versions but produces - more consistent and expected behavior. - See :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION`. diff --git a/Help/release/dev/xcode-swift-version.rst b/Help/release/dev/xcode-swift-version.rst new file mode 100644 index 0000000..5dff23c --- /dev/null +++ b/Help/release/dev/xcode-swift-version.rst @@ -0,0 +1,6 @@ +xcode-swift-version +------------------- + +* The :generator:`Xcode` generator's rudimentary Swift language support + learned to honor a new :variable:`CMAKE_Swift_LANGUAGE_VERSION` variable + to tell Xcode what version of Swift is used by the source. diff --git a/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst new file mode 100644 index 0000000..50121e2 --- /dev/null +++ b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst @@ -0,0 +1,5 @@ +CMAKE_Swift_LANGUAGE_VERSION +---------------------------- + +Set to the Swift language version number. If not set, the legacy "2.3" +version is assumed. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 64d9bed..3d1ca6d 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -266,6 +266,11 @@ Id flags: ${testflags} else() set(id_toolset "") endif() + if("${lang}" STREQUAL "Swift") + set(id_lang_version "SWIFT_VERSION = 2.3;") + else() + set(id_lang_version "") + endif() if(CMAKE_OSX_DEPLOYMENT_TARGET) set(id_deployment_target "MACOSX_DEPLOYMENT_TARGET = \"${CMAKE_OSX_DEPLOYMENT_TARGET}\";") diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 423bb00..1a7b923 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -156,18 +156,16 @@ # * Default : :code:`CPACK_PACKAGE_CONTACT` # # .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION -# CPACK_DEBIAN_<COMPONENT>_PACKAGE_DESCRIPTION +# CPACK_COMPONENT_<COMPONENT>_DESCRIPTION # # The Debian package description # # * Mandatory : YES # * Default : # -# - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component based installers only) if set, -# - :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` if set to non default location, -# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` if set, -# - :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` default value if set, -# - or "no package description available" +# - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or +# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` +# # # .. variable:: CPACK_DEBIAN_PACKAGE_SECTION # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION @@ -831,23 +829,24 @@ function(cpack_deb_prepare_package_vars) endif() # Description: (mandatory) - if(CPACK_DEB_PACKAGE_COMPONENT) - if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_DESCRIPTION) - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_DESCRIPTION}") - elseif(CPACK_COMPONENT_${_local_component_name}_DESCRIPTION) - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_COMPONENT_${_local_component_name}_DESCRIPTION}") + if(NOT CPACK_DEB_PACKAGE_COMPONENT) + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) + if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) + message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + endif() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) endif() - endif() - - if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(CPACK_PACKAGE_DESCRIPTION_FILE AND NOT "${CPACK_PACKAGE_DESCRIPTION_FILE}" STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") - file(READ "${CPACK_PACKAGE_DESCRIPTION_FILE}" CPACK_DEBIAN_PACKAGE_DESCRIPTION) - elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY) - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") - elseif(CPACK_PACKAGE_DESCRIPTION_FILE) # use default package description file content - file(READ "${CPACK_PACKAGE_DESCRIPTION_FILE}" CPACK_DEBIAN_PACKAGE_DESCRIPTION) - else() - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "no package description available") + else() + set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION) + + # component description overrides package description + if(${component_description_var}) + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}}) + elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) + if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) + message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}") + endif() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) endif() endif() diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 20f3da3..22ad4f6 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -84,6 +84,7 @@ CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; SYMROOT = .; @id_toolset@ + @id_lang_version@ @id_deployment_target@ @id_sdkroot@ }; diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index c813f8f..8b41bb9 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -18,6 +18,8 @@ # * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX, # ENG and MAT libraries of Matlab # * ``MAIN_PROGRAM`` the Matlab binary program. +# * ``MEX_COMPILER`` the MEX compiler. +# * ``SIMULINK`` the Simulink environment. # # .. note:: # @@ -819,12 +821,13 @@ endfunction() # order to produce a MEX file. The final name of the produced output may be # specified, as well as additional link libraries, and a documentation entry # for the MEX file. Remaining arguments of the call are passed to the -# :command:`add_library` command. +# :command:`add_library` or :command:`add_executable` command. # # :: # # matlab_add_mex( # NAME <name> +# [EXECUTABLE | MODULE | SHARED] # SRC src1 [src2 ...] # [OUTPUT_NAME output_name] # [DOCUMENTATION file.txt] @@ -835,7 +838,7 @@ endfunction() # ``NAME`` # name of the target. # ``SRC`` -# list of tje source files. +# list of source files. # ``LINK_TO`` # a list of additional link dependencies. The target links to ``libmex`` # by default. If ``Matlab_MX_LIBRARY`` is defined, it also @@ -851,6 +854,10 @@ endfunction() # mex file, and with extension `.m`. In that case, typing ``help <name>`` # in Matlab prints the documentation contained in this file. # +# ``MODULE`` or ``SHARED`` may be given to specify the type of library to be +# created. ``EXECUTABLE`` may be given to create an executable instead of +# a library. If no type is given explicitly, the type is ``SHARED``. +# # The documentation file is not processed and should be in the following # format: # @@ -859,7 +866,7 @@ endfunction() # % This is the documentation # function ret = mex_target_output_name(input1) # -function(matlab_add_mex ) +function(matlab_add_mex) if(NOT WIN32) # we do not need all this on Windows @@ -871,6 +878,7 @@ function(matlab_add_mex ) endif() + set(options EXECUTABLE MODULE SHARED) set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME) set(multiValueArgs LINK_TO SRC) @@ -885,11 +893,25 @@ function(matlab_add_mex ) set(${prefix}_OUTPUT_NAME ${${prefix}_NAME}) endif() - add_library(${${prefix}_NAME} - SHARED + if(${prefix}_EXECUTABLE) + add_executable(${${prefix}_NAME} + ${${prefix}_SRC} + ${${prefix}_DOCUMENTATION} + ${${prefix}_UNPARSED_ARGUMENTS}) + else() + if(${prefix}_MODULE) + set(type MODULE) + else() + set(type SHARED) + endif() + + add_library(${${prefix}_NAME} + ${type} ${${prefix}_SRC} ${${prefix}_DOCUMENTATION} ${${prefix}_UNPARSED_ARGUMENTS}) + endif() + target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS}) if(DEFINED Matlab_MX_LIBRARY) @@ -1463,6 +1485,21 @@ if(_matlab_find_mat GREATER -1) endif() unset(_matlab_find_mat) +# Component Simulink +list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink) +if(_matlab_find_simulink GREATER -1) + find_path( + Matlab_SIMULINK_INCLUDE_DIR + simstruc.h + PATHS "${Matlab_ROOT_DIR}/simulink/include" + NO_DEFAULT_PATH + ) + if(Matlab_SIMULINK_INCLUDE_DIR) + set(Matlab_SIMULINK_FOUND TRUE) + list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}") + endif() +endif() +unset(_matlab_find_simulink) unset(_matlab_lib_dir_for_search) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index faef86b..9a10ddb 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 6) -set(CMake_VERSION_PATCH 20160925) +set(CMake_VERSION_PATCH 20160926) #set(CMake_VERSION_RC 1) diff --git a/Source/Checks/cm_cxx_auto_ptr.cxx b/Source/Checks/cm_cxx_auto_ptr.cxx new file mode 100644 index 0000000..d3100fd --- /dev/null +++ b/Source/Checks/cm_cxx_auto_ptr.cxx @@ -0,0 +1,18 @@ +#include <memory> + +std::auto_ptr<int> get_auto_ptr() +{ + std::auto_ptr<int> ptr; + ptr = std::auto_ptr<int>(new int(0)); + return ptr; +} + +int use_auto_ptr(std::auto_ptr<int> ptr) +{ + return *ptr; +} + +int main() +{ + return use_auto_ptr(get_auto_ptr()); +} diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index c6a532f..80c9f3b 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -32,6 +32,7 @@ function(cm_check_cxx_feature name) endfunction() if(CMAKE_CXX_STANDARD) + cm_check_cxx_feature(auto_ptr) cm_check_cxx_feature(make_unique) if(CMake_HAVE_CXX_MAKE_UNIQUE) set(CMake_HAVE_CXX_UNIQUE_PTR 1) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 6523e3e..9b5248e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1506,22 +1506,17 @@ std::string cmCTest::Base64EncodeFile(std::string const& file) | std::ios::binary #endif ); - unsigned char* file_buffer = new unsigned char[len + 1]; - ifs.read(reinterpret_cast<char*>(file_buffer), len); + std::vector<char> file_buffer(len + 1); + ifs.read(&file_buffer[0], len); ifs.close(); - unsigned char* encoded_buffer = new unsigned char[(len * 3) / 2 + 5]; + std::vector<char> encoded_buffer((len * 3) / 2 + 5); - size_t const rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + size_t const rlen = cmsysBase64_Encode( + reinterpret_cast<unsigned char*>(&file_buffer[0]), len, + reinterpret_cast<unsigned char*>(&encoded_buffer[0]), 1); - std::string base64 = ""; - for (size_t i = 0; i < rlen; i++) { - base64 += encoded_buffer[i]; - } - delete[] file_buffer; - delete[] encoded_buffer; - - return base64; + return std::string(&encoded_buffer[0], rlen); } bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files) @@ -2795,48 +2790,42 @@ bool cmCTest::CompressString(std::string& str) int ret; z_stream strm; - unsigned char* in = - reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str())); - // zlib makes the guarantee that this is the maximum output size - int outSize = - static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0); - unsigned char* out = new unsigned char[outSize]; - strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = deflateInit(&strm, -1); // default compression level if (ret != Z_OK) { - delete[] out; return false; } + unsigned char* in = + reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str())); + // zlib makes the guarantee that this is the maximum output size + int outSize = + static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0); + std::vector<unsigned char> out(outSize); + strm.avail_in = static_cast<uInt>(str.size()); strm.next_in = in; strm.avail_out = outSize; - strm.next_out = out; + strm.next_out = &out[0]; ret = deflate(&strm, Z_FINISH); if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) { cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." << std::endl); - delete[] out; return false; } (void)deflateEnd(&strm); // Now base64 encode the resulting binary string - unsigned char* base64EncodedBuffer = new unsigned char[(outSize * 3) / 2]; + std::vector<unsigned char> base64EncodedBuffer((outSize * 3) / 2); size_t rlen = - cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1); - - str = ""; - str.append(reinterpret_cast<char*>(base64EncodedBuffer), rlen); + cmsysBase64_Encode(&out[0], strm.total_out, &base64EncodedBuffer[0], 1); - delete[] base64EncodedBuffer; - delete[] out; + str.assign(reinterpret_cast<char*>(&base64EncodedBuffer[0]), rlen); return true; } diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 8365367..8a1e81f 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -30,6 +30,7 @@ #cmakedefine CMAKE_USE_MACH_PARSER #cmakedefine CMAKE_USE_LIBUV #cmakedefine CMAKE_ENCODING_UTF8 +#cmakedefine CMake_HAVE_CXX_AUTO_PTR #cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE #cmakedefine CMake_HAVE_CXX_NULLPTR #cmakedefine CMake_HAVE_CXX_OVERRIDE diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 997f46c..0d5de06 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2996,6 +2996,15 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( buildSettings->AddAttribute("GCC_VERSION", this->CreateString(this->GeneratorToolset)); } + if (this->GetLanguageEnabled("Swift")) { + std::string swiftVersion = "2.3"; + if (const char* vers = this->CurrentMakefile->GetDefinition( + "CMAKE_Swift_LANGUAGE_VERSION")) { + swiftVersion = vers; + } + buildSettings->AddAttribute("SWIFT_VERSION", + this->CreateString(swiftVersion)); + } std::string symroot = root->GetCurrentBinaryDirectory(); symroot += "/build"; diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index d5dac4e..46c1946 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -123,8 +123,9 @@ void cmServer::RegisterProtocol(cmServerProtocol* protocol) [version](cmServerProtocol* p) { return p->ProtocolVersion() == version; }); - if (it == this->SupportedProtocols.end()) + if (it == this->SupportedProtocols.end()) { this->SupportedProtocols.push_back(protocol); + } } void cmServer::PrintHello() const @@ -181,37 +182,44 @@ void cmServer::reportMessage(const char* msg, const char* title, cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) { - if (request.Type != kHANDSHAKE_TYPE) + if (request.Type != kHANDSHAKE_TYPE) { return request.ReportError("Waiting for type \"" + kHANDSHAKE_TYPE + "\"."); + } Json::Value requestedProtocolVersion = request.Data[kPROTOCOL_VERSION_KEY]; - if (requestedProtocolVersion.isNull()) + if (requestedProtocolVersion.isNull()) { return request.ReportError("\"" + kPROTOCOL_VERSION_KEY + "\" is required for \"" + kHANDSHAKE_TYPE + "\"."); + } - if (!requestedProtocolVersion.isObject()) + if (!requestedProtocolVersion.isObject()) { return request.ReportError("\"" + kPROTOCOL_VERSION_KEY + "\" must be a JSON object."); + } Json::Value majorValue = requestedProtocolVersion[kMAJOR_KEY]; - if (!majorValue.isInt()) + if (!majorValue.isInt()) { return request.ReportError("\"" + kMAJOR_KEY + "\" must be set and an integer."); + } Json::Value minorValue = requestedProtocolVersion[kMINOR_KEY]; - if (!minorValue.isNull() && !minorValue.isInt()) + if (!minorValue.isNull() && !minorValue.isInt()) { return request.ReportError("\"" + kMINOR_KEY + "\" must be unset or an integer."); + } const int major = majorValue.asInt(); const int minor = minorValue.isNull() ? -1 : minorValue.asInt(); - if (major < 0) + if (major < 0) { return request.ReportError("\"" + kMAJOR_KEY + "\" must be >= 0."); - if (!minorValue.isNull() && minor < 0) + } + if (!minorValue.isNull() && minor < 0) { return request.ReportError("\"" + kMINOR_KEY + "\" must be >= 0 when set."); + } this->Protocol = this->FindMatchingProtocol(this->SupportedProtocols, major, minor); @@ -284,12 +292,15 @@ cmServerProtocol* cmServer::FindMatchingProtocol( cmServerProtocol* bestMatch = nullptr; for (auto protocol : protocols) { auto version = protocol->ProtocolVersion(); - if (major != version.first) + if (major != version.first) { continue; - if (minor == version.second) + } + if (minor == version.second) { return protocol; - if (!bestMatch || bestMatch->ProtocolVersion().second < version.second) + } + if (!bestMatch || bestMatch->ProtocolVersion().second < version.second) { bestMatch = protocol; + } } return minor < 0 ? bestMatch : nullptr; } @@ -317,8 +328,9 @@ void cmServer::WriteMessage(const cmServerRequest& request, const std::string& message, const std::string& title) const { - if (message.empty()) + if (message.empty()) { return; + } Json::Value obj = Json::objectValue; obj[kTYPE_KEY] = kMESSAGE_TYPE; diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index 112cafd..0b3db9f 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -146,8 +146,9 @@ void cmServerConnection::ReadData(const std::string& data) } std::string line = this->RawReadBuffer.substr(0, needle); const auto ls = line.size(); - if (ls > 1 && line.at(ls - 1) == '\r') + if (ls > 1 && line.at(ls - 1) == '\r') { line.erase(ls - 1, 1); + } this->RawReadBuffer.erase(this->RawReadBuffer.begin(), this->RawReadBuffer.begin() + static_cast<long>(needle) + 1); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index e42b18a..755de0c 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -97,10 +97,10 @@ bool cmServerResponse::IsError() const std::string cmServerResponse::ErrorMessage() const { - if (this->m_Payload == PAYLOAD_ERROR) + if (this->m_Payload == PAYLOAD_ERROR) { return this->m_ErrorMessage; - else - return std::string(); + } + return std::string(); } Json::Value cmServerResponse::Data() const @@ -117,16 +117,18 @@ bool cmServerProtocol::Activate(cmServer* server, this->m_Server = server; this->m_CMakeInstance = std::make_unique<cmake>(); const bool result = this->DoActivate(request, errorMessage); - if (!result) + if (!result) { this->m_CMakeInstance = CM_NULLPTR; + } return result; } void cmServerProtocol::SendSignal(const std::string& name, const Json::Value& data) const { - if (this->m_Server) + if (this->m_Server) { this->m_Server->WriteSignal(name, data); + } } cmake* cmServerProtocol::CMakeInstance() const @@ -155,17 +157,19 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string extraGenerator = request.Data[kEXTRA_GENERATOR_KEY].asString(); if (buildDirectory.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kBUILD_DIRECTORY_KEY + "\" is missing."; + } return false; } cmake* cm = CMakeInstance(); if (cmSystemTools::PathExists(buildDirectory)) { if (!cmSystemTools::FileIsDirectory(buildDirectory)) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kBUILD_DIRECTORY_KEY + "\" exists but is not a directory."; + } return false; } @@ -177,18 +181,20 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, const std::string cachedGenerator = std::string(state->GetCacheEntryValue("CMAKE_GENERATOR")); if (cachedGenerator.empty() && generator.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" is required but unset."; + } return false; } if (generator.empty()) { generator = cachedGenerator; } if (generator != cachedGenerator) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" set but incompatible with configured generator."; + } return false; } @@ -197,9 +203,10 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string(state->GetCacheEntryValue("CMAKE_EXTRA_GENERATOR")); if (!cachedExtraGenerator.empty() && !extraGenerator.empty() && cachedExtraGenerator != extraGenerator) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kEXTRA_GENERATOR_KEY + "\" is set but incompatible with configured extra generator."; + } return false; } if (extraGenerator.empty()) { @@ -211,9 +218,10 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY")); if (!cachedSourceDirectory.empty() && !sourceDirectory.empty() && cachedSourceDirectory != sourceDirectory) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is set but incompatible with configured source directory."; + } return false; } if (sourceDirectory.empty()) { @@ -223,21 +231,24 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, } if (sourceDirectory.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is unset but required."; + } return false; } if (!cmSystemTools::FileIsDirectory(sourceDirectory)) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kSOURCE_DIRECTORY_KEY + "\" is not a directory."; + } return false; } if (generator.empty()) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("\"") + kGENERATOR_KEY + "\" is unset but required."; + } return false; } @@ -247,10 +258,11 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, cmGlobalGenerator* gg = cm->CreateGlobalGenerator(fullGeneratorName); if (!gg) { - if (errorMessage) + if (errorMessage) { *errorMessage = std::string("Could not set up the requested combination of \"") + kGENERATOR_KEY + "\" and \"" + kEXTRA_GENERATOR_KEY + "\""; + } return false; } diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx index f6c4362..f38eda5 100644 --- a/Source/cm_auto_ptr.hxx +++ b/Source/cm_auto_ptr.hxx @@ -14,7 +14,13 @@ #include <cmConfigure.h> -// FIXME: Use std::auto_ptr on compilers that do not warn about it. +#ifdef CMake_HAVE_CXX_AUTO_PTR + +#include <memory> +#define CM_AUTO_PTR std::auto_ptr + +#else + #define CM_AUTO_PTR cm::auto_ptr // The HP compiler cannot handle the conversions necessary to use @@ -219,3 +225,5 @@ public: #endif #endif + +#endif diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 235e38a..3681843 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3109,6 +3109,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-project FortranModules --build-options ${build_options} -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} + -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES} ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules") endif() diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in index 6c5a655..74d816c 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in @@ -15,8 +15,8 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) #set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) # overriding previous descriptions -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") -set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DESCRIPTION "applications_description") -set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") +set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") # libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION) diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in index 92226d8..cda79bc 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in @@ -17,12 +17,10 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) # overriding previous descriptions set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description 2") -# and override CPACK_PACKAGE_DESCRIPTION_SUMMARY because of precedence -set(CPACK_PACKAGE_DESCRIPTION_FILE - "@CPackComponentsDEB_SOURCE_DIR@/pkg_description.txt") - # Components do not have any description unset(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION) unset(CPACK_COMPONENT_HEADERS_DESCRIPTION) +unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION) + set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "library description") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 7b94ca0..35ca74c 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -55,12 +55,12 @@ if(DPKGDEB_EXECUTABLE) message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'") if("${dpkg_package_name}" STREQUAL "mylib-applications") - if(NOT "${dpkg_description}" STREQUAL "Debian package description file") + if(NOT "${dpkg_description}" STREQUAL "main description 2") set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description") endif() elseif("${dpkg_package_name}" STREQUAL "mylib-headers") - if(NOT "${dpkg_description}" STREQUAL "Debian package description file") + if(NOT "${dpkg_description}" STREQUAL "main description 2") set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description") endif() diff --git a/Tests/CPackComponentsDEB/pkg_description.txt b/Tests/CPackComponentsDEB/pkg_description.txt deleted file mode 100644 index 99f8f9b..0000000 --- a/Tests/CPackComponentsDEB/pkg_description.txt +++ /dev/null @@ -1 +0,0 @@ -Debian package description file diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index b406df3..ff12771 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -5,6 +5,33 @@ if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "V set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() +if("x${CMake_TEST_Fortran_SUBMODULES}" STREQUAL "x" + AND NOT CMAKE_VERSION VERSION_LESS 3.6.20160923 # for CheckFortranSourceCompiles SRC_EXT + ) + include(CheckFortranSourceCompiles) + CHECK_Fortran_SOURCE_COMPILES([[ +module parent + interface + module function id(x) + real, intent(in) :: x + real :: id + end function id + end interface +end module parent +submodule ( parent ) child +contains + module procedure id + f = x + end procedure id +end submodule child +program main +end program +]] HAVE_SUBMODULES SRC_EXT F90) + set(CMake_TEST_Fortran_SUBMODULES ${HAVE_SUBMODULES}) +elseif(CMake_TEST_Fortran_SUBMODULES) + message(STATUS "Enabling Fortran submodule tests by explicit request.") +endif() + add_executable(test_module test_module_main.f90 test_module_implementation.f90 @@ -76,3 +103,7 @@ endif() add_subdirectory(Library) add_subdirectory(Subdir) add_subdirectory(Executable) + +if(CMake_TEST_Fortran_SUBMODULES) + add_subdirectory(Submodules) +endif() diff --git a/Tests/FortranModules/Submodules/CMakeLists.txt b/Tests/FortranModules/Submodules/CMakeLists.txt new file mode 100644 index 0000000..bf0152f --- /dev/null +++ b/Tests/FortranModules/Submodules/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(submod main.f90 provide.f90) diff --git a/Tests/FortranModules/Submodules/main.f90 b/Tests/FortranModules/Submodules/main.f90 new file mode 100644 index 0000000..3c750ce --- /dev/null +++ b/Tests/FortranModules/Submodules/main.f90 @@ -0,0 +1,5 @@ +program main + use parent, only : child_function,grandchild_subroutine + implicit none + if (child_function()) call grandchild_subroutine +end program diff --git a/Tests/FortranModules/Submodules/provide.f90 b/Tests/FortranModules/Submodules/provide.f90 new file mode 100644 index 0000000..0ad216a --- /dev/null +++ b/Tests/FortranModules/Submodules/provide.f90 @@ -0,0 +1,57 @@ +! The program units in this file consist of a +! module/submodule tree represented by the following +! graph: +! +! parent +! | +! / \ +! / \ +! child sibling +! | +! grandchild +! +! where the parent node is a module and all other +! nodes are submodules. + +module parent + implicit none + + interface + + ! Test Fortran 2008 "module function" syntax + module function child_function() result(child_stuff) + logical :: child_stuff + end function + + ! Test Fortran 2008 "module subroutine" syntax + module subroutine grandchild_subroutine() + end subroutine + + end interface + +end module parent + +! Test the notation for a 1st-generation direct +! descendant of a parent module +submodule ( parent ) child + implicit none +contains + module function child_function() result(child_stuff) + logical :: child_stuff + child_stuff=.true. + end function +end submodule child + +! Empty submodule for checking disambiguation of +! nodes at the same vertical level in the tree +submodule ( parent ) sibling +end submodule sibling + +! Test the notation for an Nth-generation descendant +! for N>1, which necessitates the colon. +submodule ( parent : child ) grandchild +contains + module subroutine grandchild_subroutine() + print *,"Test passed." + end subroutine +end submodule grandchild diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt index 5cb9739..cf4463c 100644 --- a/Tests/SwiftOnly/CMakeLists.txt +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -1,4 +1,8 @@ cmake_minimum_required(VERSION 3.3) project(SwiftOnly Swift) +if(NOT XCODE_VERSION VERSION_LESS 8.0) + set(CMAKE_Swift_LANGUAGE_VERSION 3.0) +endif() + add_executable(SwiftOnly main.swift) |