diff options
-rw-r--r-- | Modules/BundleUtilities.cmake | 152 | ||||
-rw-r--r-- | Modules/FindBoost.cmake | 4 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 446 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.h | 19 | ||||
-rw-r--r-- | Tests/CFBundleTest/Localized.rsrc | bin | 496 -> 472 bytes | |||
-rw-r--r-- | Tests/FindBoost/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/FindBoost/TestHeaders/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindBoost/TestHeaders/main.cxx | 9 |
9 files changed, 436 insertions, 217 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 4b52afa..cfb6450 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -52,6 +52,9 @@ # Then clear all the keys and call verify_app on the final bundle to # ensure that it is truly standalone. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>) @@ -67,6 +70,9 @@ # analysis tools on it. Calls "message(FATAL_ERROR" if the application # is not verified. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>) @@ -140,6 +146,9 @@ # all of them and copy prerequisite libs into the bundle and then do # appropriate install_name_tool fixups. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>) @@ -196,6 +205,9 @@ # bundle are contained within the bundle or are "system" libraries, # presumed to exist everywhere. # +# As an optional parameter (IGNORE_ITEM) a list of file names can be passed, +# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +# # :: # # VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>) @@ -525,6 +537,11 @@ endfunction() function(get_bundle_keys app libs dirs keys_var) set(${keys_var} PARENT_SCOPE) + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_and_executable("${app}" bundle executable valid) if(valid) # Always use the exepath of the main bundle executable for @executable_path @@ -554,10 +571,24 @@ function(get_bundle_keys app libs dirs keys_var) set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}") set(prereqs "") - get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}") - foreach(pr ${prereqs}) - set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}") - endforeach() + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${lib} NAME) + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() + + if(NOT ignoreFile) + get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}") + endforeach() + else() + message(STATUS "Ignoring file: ${prereq_filename}") + endif() endforeach() # For each executable found in the bundle, accumulate keys as we go. @@ -583,10 +614,24 @@ function(get_bundle_keys app libs dirs keys_var) # Add each prerequisite to the keys: # set(prereqs "") - get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}") - foreach(pr ${prereqs}) - set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}") - endforeach() + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${exe} NAME) + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() + + if(NOT ignoreFile) + get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}") + endforeach() + else() + message(STATUS "Ignoring file: ${prereq_filename}") + endif() endforeach() # Propagate values to caller's scope: @@ -798,12 +843,19 @@ function(fixup_bundle app libs dirs) message(STATUS " libs='${libs}'") message(STATUS " dirs='${dirs}'") + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + + message(STATUS " ignoreItems='${CFG_IGNORE_ITEM}'") + get_bundle_and_executable("${app}" bundle executable valid) if(valid) get_filename_component(exepath "${executable}" PATH) message(STATUS "fixup_bundle: preparing...") - get_bundle_keys("${app}" "${libs}" "${dirs}" keys) + get_bundle_keys("${app}" "${libs}" "${dirs}" keys IGNORE_ITEM "${CFG_IGNORE_ITEM}") message(STATUS "fixup_bundle: copying...") list(LENGTH keys n) @@ -857,7 +909,7 @@ function(fixup_bundle app libs dirs) clear_bundle_keys(keys) message(STATUS "fixup_bundle: verifying...") - verify_app("${app}") + verify_app("${app}" IGNORE_ITEM "${CFG_IGNORE_ITEM}") else() message(SEND_ERROR "error: fixup_bundle: not a valid bundle") endif() @@ -877,6 +929,11 @@ function(verify_bundle_prerequisites bundle result_var info_var) set(info "") set(count 0) + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_main_executable("${bundle}" main_bundle_exe) get_bundle_all_executables("${bundle}" file_list) @@ -887,37 +944,53 @@ function(verify_bundle_prerequisites bundle result_var info_var) message(STATUS "executable file ${count}: ${f}") set(prereqs "") - get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") + set(ignoreFile FALSE) + get_filename_component(prereq_filename ${f} NAME) + + if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" ) + foreach(item ${CFG_IGNORE_ITEM}) + if("${item}" STREQUAL "${prereq_filename}") + set(ignoreFile TRUE) + endif() + endforeach() + endif() - # On the Mac, - # "embedded" and "system" prerequisites are fine... anything else means - # the bundle's prerequisites are not verified (i.e., the bundle is not - # really "standalone") - # - # On Windows (and others? Linux/Unix/...?) - # "local" and "system" prereqs are fine... - # - set(external_prereqs "") + if(NOT ignoreFile) + get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") - foreach(p ${prereqs}) - set(p_type "") - gp_file_type("${f}" "${p}" p_type) + # On the Mac, + # "embedded" and "system" prerequisites are fine... anything else means + # the bundle's prerequisites are not verified (i.e., the bundle is not + # really "standalone") + # + # On Windows (and others? Linux/Unix/...?) + # "local" and "system" prereqs are fine... + # - if(APPLE) - if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") - set(external_prereqs ${external_prereqs} "${p}") - endif() - else() - if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system") - set(external_prereqs ${external_prereqs} "${p}") + set(external_prereqs "") + + foreach(p ${prereqs}) + set(p_type "") + gp_file_type("${f}" "${p}" p_type) + + if(APPLE) + if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") + set(external_prereqs ${external_prereqs} "${p}") + endif() + else() + if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system") + set(external_prereqs ${external_prereqs} "${p}") + endif() endif() - endif() - endforeach() + endforeach() - if(external_prereqs) - # Found non-system/somehow-unacceptable prerequisites: - set(result 0) - set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n") + if(external_prereqs) + # Found non-system/somehow-unacceptable prerequisites: + set(result 0) + set(info ${info} "external prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n") + endif() + else() + message(STATUS "Ignoring file: ${prereq_filename}") endif() endforeach() @@ -947,6 +1020,11 @@ function(verify_app app) set(verified 0) set(info "") + set(options) + set(oneValueArgs) + set(multiValueArgs IGNORE_ITEM) + cmake_parse_arguments(CFG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) + get_bundle_and_executable("${app}" bundle executable valid) message(STATUS "===========================================================================") @@ -957,7 +1035,7 @@ function(verify_app app) # Verify that the bundle does not have any "external" prerequisites: # - verify_bundle_prerequisites("${bundle}" verified info) + verify_bundle_prerequisites("${bundle}" verified info IGNORE_ITEM "${CFG_IGNORE_ITEM}") message(STATUS "verified='${verified}'") message(STATUS "info='${info}'") message(STATUS "") diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 9e6083db..38ccf78 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1573,7 +1573,7 @@ endif() # Add imported targets # ------------------------------------------------------------------------ -if(Boost_FOUND AND _Boost_IMPORTED_TARGETS) +if(Boost_FOUND) # For header-only libraries if(NOT TARGET Boost::boost) add_library(Boost::boost INTERFACE IMPORTED) @@ -1584,7 +1584,7 @@ if(Boost_FOUND AND _Boost_IMPORTED_TARGETS) endif() foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - if(NOT TARGET Boost::${COMPONENT}) + if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) if(Boost_${UPPERCOMPONENT}_FOUND) if(Boost_USE_STATIC_LIBS) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3304213..c23d20d 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 5) -set(CMake_VERSION_PATCH 20160419) +set(CMake_VERSION_PATCH 20160420) #set(CMake_VERSION_RC 1) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index ebe08b0..c07a0a6 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -410,9 +410,11 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile( void cmQtAutoGenerators::Init() { + this->OutMocCppFilenameRel = this->TargetName; + this->OutMocCppFilenameRel += ".cpp"; + this->OutMocCppFilename = this->Builddir; - this->OutMocCppFilename += this->TargetName; - this->OutMocCppFilename += ".cpp"; + this->OutMocCppFilename += this->OutMocCppFilenameRel; std::vector<std::string> cdefList; cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList); @@ -464,7 +466,7 @@ void cmQtAutoGenerators::Init() std::list<std::string>::iterator it = this->MocIncludes.begin(); while (it != this->MocIncludes.end()) { - if (this->StartsWith(*it, binDir)) + if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str())) { sortedMocIncludes.push_back(*it); it = this->MocIncludes.erase(it); @@ -477,7 +479,7 @@ void cmQtAutoGenerators::Init() it = this->MocIncludes.begin(); while (it != this->MocIncludes.end()) { - if (this->StartsWith(*it, srcDir)) + if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str())) { sortedMocIncludes.push_back(*it); it = this->MocIncludes.erase(it); @@ -589,56 +591,17 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::map<std::string, std::string> notIncludedMocs; this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); - // run moc on all the moc's that are #included in source files - for(std::map<std::string, std::string>::const_iterator - it = includedMocs.begin(); - it != includedMocs.end(); - ++it) + if(!this->MocExecutable.empty()) { - this->GenerateMoc(it->first, it->second); + this->GenerateMocFiles ( includedMocs, notIncludedMocs ); } - for(std::map<std::string, std::vector<std::string> >::const_iterator - it = includedUis.begin(); - it != includedUis.end(); - ++it) + if(!this->UicExecutable.empty()) { - for (std::vector<std::string>::const_iterator nit = it->second.begin(); - nit != it->second.end(); - ++nit) - { - this->GenerateUi(it->first, *nit); - } + this->GenerateUiFiles ( includedUis ); } - if(!this->RccExecutable.empty()) { - this->GenerateQrc(); - } - - std::stringstream outStream; - outStream << "/* This file is autogenerated, do not edit*/\n"; - - bool automocCppChanged = false; - if (notIncludedMocs.empty()) - { - outStream << "enum some_compilers { need_more_than_nothing };\n"; - } - else - { - // run moc on the remaining headers and include them in - // the _automoc.cpp file - for(std::map<std::string, std::string>::const_iterator - it = notIncludedMocs.begin(); - it != notIncludedMocs.end(); - ++it) - { - bool mocSuccess = this->GenerateMoc(it->first, it->second); - if (mocSuccess) - { - automocCppChanged = true; - } - outStream << "#include \"" << it->second << "\"\n"; - } + this->GenerateQrcFiles(); } if (this->RunMocFailed) @@ -646,7 +609,6 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::cerr << "moc failed..." << std::endl; return false; } - if (this->RunUicFailed) { std::cerr << "uic failed..." << std::endl; @@ -657,25 +619,6 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::cerr << "rcc failed..." << std::endl; return false; } - outStream.flush(); - std::string automocSource = outStream.str(); - if (!automocCppChanged) - { - // compare contents of the _automoc.cpp file - const std::string oldContents = ReadAll(this->OutMocCppFilename); - if (oldContents == automocSource) - { - // nothing changed: don't touch the _automoc.cpp file - return true; - } - } - - // source file that includes all remaining moc files (_automoc.cpp file) - cmsys::ofstream outfile; - outfile.open(this->OutMocCppFilename.c_str(), - std::ios::trunc); - outfile << automocSource; - outfile.close(); return true; } @@ -762,7 +705,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, std::cerr << "AUTOGEN: error: " << absFilename << ": The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename - << '{' << this->Join(headerExtensions, ',') << "}\" "; + << '{' << this->JoinExts(headerExtensions) << "}\" "; if (mocSubDir.empty()) { std::cerr << "in " << absPath << "\n" << std::endl; @@ -937,7 +880,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, std::cerr << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename - << '{' << this->Join(headerExtensions, ',') << "}\" "; + << '{' << this->JoinExts(headerExtensions) << "}\" "; if (mocSubDir.empty()) { std::cerr << "in " << absPath << "\n" << std::endl; @@ -1119,6 +1062,102 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, } } + +bool cmQtAutoGenerators::GenerateMocFiles( + const std::map<std::string, std::string>& includedMocs, + const std::map<std::string, std::string>& notIncludedMocs ) +{ + // generate moc files that are included by source files. + for(std::map<std::string, std::string>::const_iterator + it = includedMocs.begin(); it != includedMocs.end(); ++it) + { + if (!this->GenerateMoc(it->first, it->second)) + { + if (this->RunMocFailed) + { + return false; + } + } + } + + // generate moc files that are _not_ included by source files. + bool automocCppChanged = false; + for(std::map<std::string, std::string>::const_iterator + it = notIncludedMocs.begin(); it != notIncludedMocs.end(); ++it) + { + if (this->GenerateMoc(it->first, it->second)) + { + automocCppChanged = true; + } + else + { + if (this->RunMocFailed) + { + return false; + } + } + } + + // compose _automoc.cpp content + std::string automocSource; + { + std::stringstream outStream; + outStream << "/* This file is autogenerated, do not edit*/\n"; + if( notIncludedMocs.empty() ) + { + outStream << "enum some_compilers { need_more_than_nothing };\n"; + } + else + { + for(std::map<std::string, std::string>::const_iterator + it = notIncludedMocs.begin(); + it != notIncludedMocs.end(); + ++it) + { + outStream << "#include \"" << it->second << "\"\n"; + } + } + outStream.flush(); + automocSource = outStream.str(); + } + + // check if we even need to update _automoc.cpp + if (!automocCppChanged) + { + // compare contents of the _automoc.cpp file + const std::string oldContents = ReadAll(this->OutMocCppFilename); + if (oldContents == automocSource) + { + // nothing changed: don't touch the _automoc.cpp file + if (this->Verbose) + { + std::cout << "AUTOGEN: " << this->OutMocCppFilenameRel + << " still up to date" << std::endl; + } + return true; + } + } + + // actually write _automoc.cpp + { + std::string msg = "Generating "; + msg += this->OutMocCppFilenameRel; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); + } + { + cmsys::ofstream outfile; + outfile.open(this->OutMocCppFilename.c_str(), + std::ios::trunc); + outfile << automocSource; + outfile.close(); + } + + return true; +} + + bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, const std::string& mocFileName) { @@ -1159,13 +1198,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, if (this->Verbose) { - for(std::vector<std::string>::const_iterator cmdIt = command.begin(); - cmdIt != command.end(); - ++cmdIt) - { - std::cout << *cmdIt << " "; - } - std::cout << std::endl; + this->LogCommand(command); } std::string output; @@ -1184,28 +1217,74 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, return false; } + +bool cmQtAutoGenerators::GenerateUiFiles( + const std::map<std::string, std::vector<std::string> >& includedUis ) +{ + // single map with input / output names + std::map<std::string, std::map<std::string, std::string> > uiGenMap; + for(std::map<std::string, std::vector<std::string> >::const_iterator + it = includedUis.begin(); it != includedUis.end(); ++it) + { + // source file path + std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first); + sourcePath += '/'; + // insert new map for source file an use new reference + uiGenMap[it->first] = std::map<std::string, std::string>(); + std::map<std::string, std::string>& sourceMap = uiGenMap[it->first]; + for (std::vector<std::string>::const_iterator sit = it->second.begin(); + sit != it->second.end(); + ++sit) + { + const std::string & uiFileName = *sit; + const std::string uiInputFile = sourcePath + uiFileName + ".ui"; + const std::string uiOutputFile = "ui_" + uiFileName + ".h"; + sourceMap[uiInputFile] = uiOutputFile; + } + } + + // generate ui files + for(std::map<std::string, std::map<std::string, std::string> >:: + const_iterator it = uiGenMap.begin(); it != uiGenMap.end(); ++it) + { + for(std::map<std::string, std::string>::const_iterator + sit = it->second.begin(); + sit != it->second.end(); + ++sit) + { + if (!this->GenerateUi(it->first, sit->first, sit->second) ) + { + if (this->RunUicFailed) + { + return false; + } + } + } + } + + return true; +} + + bool cmQtAutoGenerators::GenerateUi(const std::string& realName, - const std::string& uiFileName) + const std::string& uiInputFile, + const std::string& uiOutputFile) { if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) { cmsys::SystemTools::MakeDirectory(this->Builddir.c_str()); } - const std::string path = cmsys::SystemTools::GetFilenamePath( - realName) + '/'; - - std::string ui_output_file = "ui_" + uiFileName + ".h"; - std::string ui_input_file = path + uiFileName + ".ui"; + const ::std::string uiBuildFile = this->Builddir + uiOutputFile; int sourceNewerThanUi = 0; - bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file, - this->Builddir + ui_output_file, + bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile, + uiBuildFile, &sourceNewerThanUi); if (this->GenerateAll || !success || sourceNewerThanUi >= 0) { std::string msg = "Generating "; - msg += ui_output_file; + msg += uiOutputFile; cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |cmsysTerminal_Color_ForegroundBold, msg.c_str(), true, this->ColorOutput); @@ -1215,7 +1294,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, std::vector<std::string> opts = this->UicTargetOptions; std::map<std::string, std::string>::const_iterator optionIt - = this->UicOptions.find(ui_input_file); + = this->UicOptions.find(uiInputFile); if (optionIt != this->UicOptions.end()) { std::vector<std::string> fileOpts; @@ -1226,18 +1305,12 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, command.insert(command.end(), opts.begin(), opts.end()); command.push_back("-o"); - command.push_back(this->Builddir + ui_output_file); - command.push_back(ui_input_file); + command.push_back(uiBuildFile); + command.push_back(uiInputFile); if (this->Verbose) { - for(std::vector<std::string>::const_iterator cmdIt = command.begin(); - cmdIt != command.end(); - ++cmdIt) - { - std::cout << *cmdIt << " "; - } - std::cout << std::endl; + this->LogCommand(command); } std::string output; int retVal = 0; @@ -1245,11 +1318,11 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, &retVal); if (!result || retVal) { - std::cerr << "AUTOUIC: error: process for " << ui_output_file << + std::cerr << "AUTOUIC: error: process for " << uiOutputFile << " needed by\n \"" << realName << "\"\nfailed:\n" << output << std::endl; this->RunUicFailed = true; - cmSystemTools::RemoveFile(ui_output_file); + cmSystemTools::RemoveFile(uiOutputFile); return false; } return true; @@ -1276,79 +1349,121 @@ bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile, return false; } -bool cmQtAutoGenerators::GenerateQrc() +bool cmQtAutoGenerators::GenerateQrcFiles() { + // generate single map with input / output names + std::map<std::string, std::string> qrcGenMap; for(std::vector<std::string>::const_iterator si = this->RccSources.begin(); si != this->RccSources.end(); ++si) { - std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); - - if (ext != ".qrc") + const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); + if (ext == ".qrc") { - continue; + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(*si); + std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName + + ".dir/qrc_" + basename + ".cpp"; + qrcGenMap[*si] = qrcOutputFile; } - std::vector<std::string> command; - command.push_back(this->RccExecutable); + } - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(*si); + // generate qrc files + for(std::map<std::string, std::string>::const_iterator + si = qrcGenMap.begin(); si != qrcGenMap.end(); ++si) + { + if (!this->GenerateQrc( si->first, si->second)) + { + if (this->RunRccFailed) + { + return false; + } + } + } + return true; +} - std::string rcc_output_file = this->Builddir - + "CMakeFiles/" + this->OriginTargetName - + ".dir/qrc_" + basename + ".cpp"; +bool cmQtAutoGenerators::GenerateQrc ( + const std::string& qrcInputFile, + const std::string& qrcOutputFile ) +{ + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(qrcInputFile); + const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile; + + int sourceNewerThanQrc = 0; + bool generateQrc = !cmsys::SystemTools::FileTimeCompare(qrcInputFile, + qrcBuildFile, + &sourceNewerThanQrc); + generateQrc = generateQrc || (sourceNewerThanQrc >= 0); + generateQrc = generateQrc || this->InputFilesNewerThanQrc(qrcInputFile, + qrcBuildFile); + + if (this->GenerateAll || generateQrc) + { + std::string msg = "Generating "; + msg += qrcOutputFile; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); - int sourceNewerThanQrc = 0; - bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si, - rcc_output_file, - &sourceNewerThanQrc); - generateQrc = generateQrc || (sourceNewerThanQrc >= 0); - generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si, - rcc_output_file); + std::vector<std::string> command; + command.push_back(this->RccExecutable); - if (this->GenerateAll || generateQrc) + std::map<std::string, std::string>::const_iterator optionIt + = this->RccOptions.find(qrcInputFile); + if (optionIt != this->RccOptions.end()) { - std::map<std::string, std::string>::const_iterator optionIt - = this->RccOptions.find(*si); - if (optionIt != this->RccOptions.end()) - { - cmSystemTools::ExpandListArgument(optionIt->second, command); - } + cmSystemTools::ExpandListArgument(optionIt->second, command); + } - command.push_back("-name"); - command.push_back(basename); - command.push_back("-o"); - command.push_back(rcc_output_file); - command.push_back(*si); + command.push_back("-name"); + command.push_back(basename); + command.push_back("-o"); + command.push_back(qrcBuildFile); + command.push_back(qrcInputFile); - if (this->Verbose) - { - for(std::vector<std::string>::const_iterator cmdIt = command.begin(); - cmdIt != command.end(); - ++cmdIt) - { - std::cout << *cmdIt << " "; - } - std::cout << std::endl; - } - std::string output; - int retVal = 0; - bool result = cmSystemTools::RunSingleCommand(command, &output, &output, - &retVal); - if (!result || retVal) - { - std::cerr << "AUTORCC: error: process for " << rcc_output_file << - " failed:\n" << output << std::endl; - this->RunRccFailed = true; - cmSystemTools::RemoveFile(rcc_output_file); - return false; - } + if (this->Verbose) + { + this->LogCommand(command); + } + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &output, + &retVal); + if (!result || retVal) + { + std::cerr << "AUTORCC: error: process for " << qrcOutputFile << + " failed:\n" << output << std::endl; + this->RunRccFailed = true; + cmSystemTools::RemoveFile(qrcBuildFile); + return false; } } return true; } -std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst, - char separator) +void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) +{ + std::stringstream sbuf; + for(std::vector<std::string>::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + if ( cmdIt != command.begin() ) + { + sbuf << " "; + } + sbuf << *cmdIt; + } + sbuf.flush(); + if ( !sbuf.str().empty() ) + { + std::cout << sbuf.str(); + std::cout << std::endl; + } +} + +std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst) { if (lst.empty()) { @@ -1356,30 +1471,17 @@ std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst, } std::string result; + std::string separator = ","; for (std::vector<std::string>::const_iterator it = lst.begin(); it != lst.end(); ++it) { - result += "." + (*it) + separator; + if(it != lst.begin()) + { + result += separator; + } + result += '.' + (*it); } result.erase(result.end() - 1); return result; } - - -bool cmQtAutoGenerators::StartsWith(const std::string& str, - const std::string& with) -{ - return (str.substr(0, with.length()) == with); -} - - -bool cmQtAutoGenerators::EndsWith(const std::string& str, - const std::string& with) -{ - if (with.length() > (str.length())) - { - return false; - } - return (str.substr(str.length() - with.length(), with.length()) == with); -} diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index ab7b6ed..68ab480 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -39,10 +39,19 @@ private: std::string MakeCompileSettingsString(cmMakefile* makefile); bool RunAutogen(cmMakefile* makefile); + bool GenerateMocFiles( + const std::map<std::string, std::string>& includedMocs, + const std::map<std::string, std::string>& notIncludedMocs); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); - bool GenerateUi(const std::string& realName, const std::string& uiFileName); - bool GenerateQrc(); + bool GenerateUiFiles( + const std::map<std::string, std::vector<std::string> >& includedUis ); + bool GenerateUi(const std::string& realName, + const std::string& uiInputFile, + const std::string& uiOutputFile ); + bool GenerateQrcFiles(); + bool GenerateQrc(const std::string& qrcInputFile, + const std::string& qrcOutputFile); void ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::map<std::string, std::string>& includedMocs, @@ -69,9 +78,8 @@ private: void Init(); - std::string Join(const std::vector<std::string>& lst, char separator); - bool EndsWith(const std::string& str, const std::string& with); - bool StartsWith(const std::string& str, const std::string& with); + void LogCommand(const std::vector<std::string>& command); + std::string JoinExts(const std::vector<std::string>& lst); static void MergeUicOptions(std::vector<std::string> &opts, const std::vector<std::string> &fileOpts, bool isQt5); @@ -101,6 +109,7 @@ private: std::string CurrentCompileSettingsStr; std::string OldCompileSettingsStr; + std::string OutMocCppFilenameRel; std::string OutMocCppFilename; std::list<std::string> MocIncludes; std::list<std::string> MocDefinitions; diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc Binary files differindex cbf3523..7973c1f 100644 --- a/Tests/CFBundleTest/Localized.rsrc +++ b/Tests/CFBundleTest/Localized.rsrc diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt index 259ee26..0e9527d 100644 --- a/Tests/FindBoost/CMakeLists.txt +++ b/Tests/FindBoost/CMakeLists.txt @@ -8,3 +8,14 @@ add_test(NAME FindBoost.Test COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) + +add_test(NAME FindBoost.TestHeaders COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBoost/TestHeaders" + "${CMake_BINARY_DIR}/Tests/FindBoost/TestHeaders" + ${build_generator_args} + --build-project TestFindBoostHeaders + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindBoost/TestHeaders/CMakeLists.txt b/Tests/FindBoost/TestHeaders/CMakeLists.txt new file mode 100644 index 0000000..d7be327 --- /dev/null +++ b/Tests/FindBoost/TestHeaders/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindBoostHeaders CXX) +include(CTest) + +find_package(Boost REQUIRED) + +add_executable(test_boost_headers_tgt main.cxx) +target_link_libraries(test_boost_headers_tgt + Boost::boost) +add_test(NAME test_boost_headers_tgt COMMAND test_boost_headers_tgt) diff --git a/Tests/FindBoost/TestHeaders/main.cxx b/Tests/FindBoost/TestHeaders/main.cxx new file mode 100644 index 0000000..0400d6d --- /dev/null +++ b/Tests/FindBoost/TestHeaders/main.cxx @@ -0,0 +1,9 @@ +#include <boost/any.hpp> + +int main() { + boost::any a; + a = 5; + a = std::string("A string"); + + return 0; +} |