diff options
-rw-r--r-- | Help/release/dev/cpack-rpm-omit-unsupported-tags.rst | 8 | ||||
-rw-r--r-- | Modules/CPackRPM.cmake | 24 | ||||
-rw-r--r-- | Modules/FortranCInterface/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 2 | ||||
-rw-r--r-- | Source/cmCPluginAPI.cxx | 8 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake | 31 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RPM_SUGGESTS.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RunCMakeTest.cmake | 1 |
12 files changed, 85 insertions, 9 deletions
diff --git a/Help/release/dev/cpack-rpm-omit-unsupported-tags.rst b/Help/release/dev/cpack-rpm-omit-unsupported-tags.rst new file mode 100644 index 0000000..abcb7a6 --- /dev/null +++ b/Help/release/dev/cpack-rpm-omit-unsupported-tags.rst @@ -0,0 +1,8 @@ +cpack-rpm-omit-unsupported-tags +------------------------------- + +* The :module:`CPackRPM` module learned to omit + tags that are not supported by provided + rpmbuild tool. If unsupported tags are set + they are ignored and a developer warning is + printed out. diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 2483a13..39697f0 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -1844,6 +1844,12 @@ function(cpack_rpm_generate_package) set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM endif() + execute_process( + COMMAND "${RPMBUILD_EXECUTABLE}" --querytags + OUTPUT_VARIABLE RPMBUILD_TAG_LIST + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}") + # Check if additional fields for RPM spec header are given # There may be some COMPONENT specific variables as well # If component specific var is not provided we use the global one @@ -1852,6 +1858,7 @@ function(cpack_rpm_generate_package) if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") endif() + if(CPACK_RPM_PACKAGE_COMPONENT) cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}" @@ -1859,9 +1866,24 @@ function(cpack_rpm_generate_package) endif() if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + # Prefix can be replaced by Prefixes but the old version stil works so we'll ignore it for now + # Requires* is a special case because it gets transformed to Requires(pre/post/preun/postun) + # Auto* is a special case because the tags can not be queried by querytags rpmbuild flag + set(special_case_tags_ PREFIX REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN AUTOPROV AUTOREQ AUTOREQPROV) + if(NOT _RPM_SPEC_HEADER IN_LIST RPMBUILD_TAG_LIST AND NOT _RPM_SPEC_HEADER IN_LIST special_case_tags_) + cmake_policy(POP) + message(AUTHOR_WARNING "CPackRPM:Warning: ${_RPM_SPEC_HEADER} not " + "supported in provided rpmbuild. Tag will not be used.") + continue() + endif() + cmake_policy(POP) + if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") endif() + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) endif() @@ -2416,6 +2438,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_PROVIDES\@ \@TMP_RPM_OBSOLETES\@ \@TMP_RPM_CONFLICTS\@ +\@TMP_RPM_SUGGESTS\@ \@TMP_RPM_AUTOPROV\@ \@TMP_RPM_AUTOREQ\@ \@TMP_RPM_AUTOREQPROV\@ @@ -2470,6 +2493,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_PROVIDES\@ \@TMP_RPM_OBSOLETES\@ \@TMP_RPM_CONFLICTS\@ +\@TMP_RPM_SUGGESTS\@ \@TMP_RPM_AUTOPROV\@ \@TMP_RPM_AUTOREQ\@ \@TMP_RPM_AUTOREQPROV\@ diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index dee57b5..3a66f68 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -94,6 +94,9 @@ add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules}) # Provide symbols through C but fall back to Fortran. add_library(symbols STATIC ${symbol_sources}) target_link_libraries(symbols myfort) +# In case the Fortran compiler produces PIC by default make sure +# the C compiler produces PIC even if it is not its default. +set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) # Require symbols through Fortran. add_executable(FortranCInterface main.F call_sub.f ${call_mod}) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 59e5c7e..817af3b 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 7) -set(CMake_VERSION_PATCH 20161105) +set(CMake_VERSION_PATCH 20161108) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index d21471d..d10f7ad 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -926,7 +926,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC( return false; } size_t fileSize = static_cast<size_t>(st.st_size); - FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); + FILE* fp = cmsys::SystemTools::Fopen(local_file, "rb"); if (!fp) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: " << local_file << std::endl); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index b70074e..d1f8446 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -408,7 +408,7 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source, std::string result = mf->ExpandVariablesInString( barf, (escapeQuotes ? true : false), (atOnly ? true : false)); char* res = static_cast<char*>(malloc(result.size() + 1)); - if (result.size()) { + if (!result.empty()) { strcpy(res, result.c_str()); } res[result.size()] = '\0'; @@ -570,7 +570,7 @@ void* CCONV cmAddSource(void* arg, void* arg2) rsf->GetProperties() = osf->Properties; for (std::vector<std::string>::iterator i = osf->Depends.begin(); i != osf->Depends.end(); ++i) { - rsf->AddDepend(i->c_str()); + rsf->AddDepend(*i); } // Create the proxy for the real source file. @@ -676,7 +676,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir, std::string hname = pathname; if (cmSystemTools::FileExists(hname.c_str())) { sf->SourceName = cmSystemTools::GetFilenamePath(name); - if (sf->SourceName.size() > 0) { + if (!sf->SourceName.empty()) { sf->SourceName += "/"; } sf->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name); @@ -756,7 +756,7 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir, fname += "."; fname += ext; } - sf->FullPath = cmSystemTools::CollapseFullPath(fname.c_str(), dir); + sf->FullPath = cmSystemTools::CollapseFullPath(fname, dir); cmSystemTools::ConvertToUnixSlashes(sf->FullPath); sf->SourceExtension = ext; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 882de85..1a454ac 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3947,9 +3947,9 @@ std::string cmGeneratorTarget::GetFortranModuleDirectory( std::string const& working_dir) const { if (!this->FortranModuleDirectoryCreated) { - this->FortranModuleDirectory = true; this->FortranModuleDirectory = this->CreateFortranModuleDirectory(working_dir); + this->FortranModuleDirectoryCreated = true; } return this->FortranModuleDirectory; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f62c8ec..1bdef53 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -136,7 +136,7 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit) std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path) { - std::string result = path; + std::string result = path; // NOLINT(clang-tidy) #ifdef _WIN32 if (this->IsGCCOnWindows()) std::replace(result.begin(), result.end(), '\\', '/'); @@ -289,7 +289,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( bool restat, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, const cmNinjaDeps& orderOnly) { - std::string cmd = command; + std::string cmd = command; // NOLINT(clang-tidy) #ifdef _WIN32 if (cmd.empty()) // TODO Shouldn't an empty command be handled by ninja? diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake new file mode 100644 index 0000000..02ebb44 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "rpm_suggests*.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake new file mode 100644 index 0000000..32cc6d1 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake @@ -0,0 +1,31 @@ +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags + OUTPUT_VARIABLE RPMBUILD_CAPS + RESULT_VARIABLE RPMBUILD_CAPS_RESULT) + +if(NOT RPMBUILD_CAPS_RESULT) + string(REPLACE "\n" ";" RPMBUILD_CAPS "${RPMBUILD_CAPS}") + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + if(SUGGESTS IN_LIST RPMBUILD_CAPS) + set(should_contain_suggests_tag_ true) + endif() + cmake_policy(POP) +endif() + +# Only verify that suggests tag is present only if that tag is supported. +# If it is not supported the rpm package was corretly generated by ignoring +# that tag and that was already checked by expected files test. +if(should_contain_suggests_tag_) + execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE rpm_result_ + OUTPUT_VARIABLE rpm_output_ + ERROR_VARIABLE error_variable_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(rpm_result_ OR NOT rpm_output_ STREQUAL "libsuggested") + message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages" + " (result: '${rpm_result_}'; output: '${rpm_output_}';" + " error: '${error_variable_}')") + endif() +endif() diff --git a/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake b/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake new file mode 100644 index 0000000..e6e0c1f --- /dev/null +++ b/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake @@ -0,0 +1,4 @@ +install(FILES CMakeLists.txt DESTINATION foo) + +set(CPACK_RPM_PACKAGE_SUGGESTS "libsuggested") +set(CPACK_PACKAGE_NAME "rpm_suggests") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 474ee33..38bd0ea 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -15,6 +15,7 @@ run_cpack_test(CUSTOM_NAMES "RPM;DEB" true) run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false) run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) run_cpack_test(RPM_DIST "RPM" false) +run_cpack_test(RPM_SUGGESTS "RPM" false) run_cpack_test(INSTALL_SCRIPTS "RPM" false) run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) |