diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-05-17 17:20:44 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-05-17 17:20:44 (GMT) |
commit | 61d3444f93600955ca12840b0e62503584bb8910 (patch) | |
tree | ed21dca2d6c506618088533bcfe62f734b497272 /Source | |
parent | 9bfe711ef10a02db0cb63c7fcb797fbc0df705ab (diff) | |
download | CMake-61d3444f93600955ca12840b0e62503584bb8910.zip CMake-61d3444f93600955ca12840b0e62503584bb8910.tar.gz CMake-61d3444f93600955ca12840b0e62503584bb8910.tar.bz2 |
ENH: merge CMake-CrossCompileBasic to HEAD
-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions
Alex
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 45 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 5 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 950 | ||||
-rw-r--r-- | Source/cmFileCommand.h | 38 | ||||
-rw-r--r-- | Source/cmFindBase.cxx | 89 | ||||
-rw-r--r-- | Source/cmFindBase.h | 11 | ||||
-rw-r--r-- | Source/cmIncludeCommand.cxx | 59 | ||||
-rw-r--r-- | Source/cmIncludeCommand.h | 8 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 69 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 7 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefile.h | 4 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 18 | ||||
-rw-r--r-- | Source/cmUtilitySourceCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmUtilitySourceCommand.h | 9 |
15 files changed, 789 insertions, 537 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 7552f75..e33d62b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -214,51 +214,6 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass( } //---------------------------------------------------------------------- -// Try to find an executable, if found fullPath will be set to the full path -// of where it was found. The directory and filename to search for are passed -// in as well an a subdir (typically used for configuraitons such as -// Release/Debug/etc) -bool cmCTestTestHandler::TryExecutable(const char *dir, - const char *file, - std::string *fullPath, - const char *subdir) -{ - // try current directory - std::string tryPath; - if (dir && strcmp(dir,"")) - { - tryPath = dir; - tryPath += "/"; - } - - if (subdir && strcmp(subdir,"")) - { - tryPath += subdir; - tryPath += "/"; - } - - tryPath += file; - - // find the file without an executable extension - if(cmSystemTools::FileExists(tryPath.c_str())) - { - *fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); - return true; - } - - // if not found try it with the executable extension - tryPath += cmSystemTools::GetExecutableExtension(); - if(cmSystemTools::FileExists(tryPath.c_str())) - { - *fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); - return true; - } - - // not found at all, return false - return false; -} - -//---------------------------------------------------------------------- // get the next number in a string with numbers separated by , // pos is the start of the search and pos2 is the end of the search // pos becomes pos2 after a call to GetNextNumber. diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 6b81f8a..1bac55c 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -103,11 +103,6 @@ public: cmCTestTestProperties* Properties; }; - // useful function for looking for a test - static bool TryExecutable(const char *dir, const char *file, - std::string *fullPath, - const char *subdir); - // add configuraitons to a search path for an executable static void AddConfigurations(cmCTest *ctest, std::vector<std::string> &attempted, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2cb3bf2..7128ca5 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1018,8 +1018,194 @@ bool cmFileInstaller::InstallDirectory(const char* source, } //---------------------------------------------------------------------------- -bool cmFileCommand::HandleInstallCommand( - std::vector<std::string> const& args) +void cmFileCommand::HandleInstallPermissions(cmFileInstaller& installer, + mode_t& permissions_file, + mode_t& permissions_dir, + int itype, + bool use_given_permissions_file, + bool use_given_permissions_dir, + bool use_source_permissions) const +{ + // Choose a default for shared library permissions. + bool install_so_no_exe = this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE"); + // If file permissions were not specified set default permissions + // for this target type. + if(!use_given_permissions_file && !use_source_permissions) + { + switch(itype) + { + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + if(install_so_no_exe) + { + // Use read/write permissions. + permissions_file = 0; + permissions_file |= mode_owner_read; + permissions_file |= mode_owner_write; + permissions_file |= mode_group_read; + permissions_file |= mode_world_read; + break; + } + case cmTarget::EXECUTABLE: + case cmTarget::INSTALL_PROGRAMS: + // Use read/write/executable permissions. + permissions_file = 0; + permissions_file |= mode_owner_read; + permissions_file |= mode_owner_write; + permissions_file |= mode_owner_execute; + permissions_file |= mode_group_read; + permissions_file |= mode_group_execute; + permissions_file |= mode_world_read; + permissions_file |= mode_world_execute; + break; + default: + // Use read/write permissions. + permissions_file = 0; + permissions_file |= mode_owner_read; + permissions_file |= mode_owner_write; + permissions_file |= mode_group_read; + permissions_file |= mode_world_read; + break; + } + } + + // If directory permissions were not specified set default permissions. + if(!use_given_permissions_dir && !use_source_permissions) + { + // Use read/write/executable permissions. + permissions_dir = 0; + permissions_dir |= mode_owner_read; + permissions_dir |= mode_owner_write; + permissions_dir |= mode_owner_execute; + permissions_dir |= mode_group_read; + permissions_dir |= mode_group_execute; + permissions_dir |= mode_world_read; + permissions_dir |= mode_world_execute; + } + // Set the installer permissions. + installer.FilePermissions = permissions_file; + installer.DirPermissions = permissions_dir; +} + +//---------------------------------------------------------------------------- +void cmFileCommand::GetTargetTypeFromString(const std::string& stype, int& itype) const +{ + if ( stype == "EXECUTABLE" ) + { + itype = cmTarget::EXECUTABLE; + } + else if ( stype == "PROGRAM" ) + { + itype = cmTarget::INSTALL_PROGRAMS; + } + else if ( stype == "STATIC_LIBRARY" ) + { + itype = cmTarget::STATIC_LIBRARY; + } + else if ( stype == "SHARED_LIBRARY" ) + { + itype = cmTarget::SHARED_LIBRARY; + } + else if ( stype == "MODULE" ) + { + itype = cmTarget::MODULE_LIBRARY; + } + else if ( stype == "DIRECTORY" ) + { + itype = cmTarget::INSTALL_DIRECTORY; + } +} + + +//---------------------------------------------------------------------------- +bool cmFileCommand::HandleInstallDestination(cmFileInstaller& installer, std::string& destination) +{ + if ( destination.size() < 2 ) + { + this->SetError("called with inapropriate arguments. " + "No DESTINATION provided or ."); + return false; + } + + const char* destdir = cmSystemTools::GetEnv("DESTDIR"); + if ( destdir && *destdir ) + { + std::string sdestdir = destdir; + cmSystemTools::ConvertToUnixSlashes(sdestdir); + + char ch1 = destination[0]; + char ch2 = destination[1]; + char ch3 = 0; + if ( destination.size() > 2 ) + { + ch3 = destination[2]; + } + int skip = 0; + if ( ch1 != '/' ) + { + int relative = 0; + if ( ( ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z' ) && + ch2 == ':' ) + { + // Assume windows + // let's do some destdir magic: + skip = 2; + if ( ch3 != '/' ) + { + relative = 1; + } + } + else + { + relative = 1; + } + if ( relative ) + { + // This is relative path on unix or windows. Since we are doing + // destdir, this case does not make sense. + this->SetError("called with relative DESTINATION. This " + "does not make sense when using DESTDIR. Specify " + "absolute path or remove DESTDIR environment variable."); + return false; + } + } + else + { + if ( ch2 == '/' ) + { + // looks like a network path. + this->SetError("called with network path DESTINATION. This " + "does not make sense when using DESTDIR. Specify local " + "absolute path or remove DESTDIR environment variable."); + return false; + } + } + destination = sdestdir + (destination.c_str() + skip); + installer.DestDirLength = int(sdestdir.size()); + } + + if ( !cmSystemTools::FileExists(destination.c_str()) ) + { + if ( !cmSystemTools::MakeDirectory(destination.c_str()) ) + { + std::string errstring = "cannot create directory: " + destination + + ". Maybe need administrative privileges."; + this->SetError(errstring.c_str()); + return false; + } + } + if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) + { + std::string errstring = "INSTALL destination: " + destination + + " is not a directory."; + this->SetError(errstring.c_str()); + return false; + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) { if ( args.size() < 6 ) { @@ -1032,307 +1218,376 @@ bool cmFileCommand::HandleInstallCommand( std::string rename = ""; std::string destination = ""; - std::string stype = "FILES"; - const char* destdir = cmSystemTools::GetEnv("DESTDIR"); std::set<cmStdString> components; std::set<cmStdString> configurations; std::vector<std::string> files; int itype = cmTarget::INSTALL_FILES; - std::vector<std::string>::size_type i = 0; - i++; // Get rid of subcommand - std::map<cmStdString, const char*> properties; - - bool doing_files = false; - bool doing_properties = false; - bool doing_permissions_file = false; - bool doing_permissions_dir = false; - bool doing_permissions_match = false; - bool doing_components = false; - bool doing_configurations = false; - bool use_given_permissions_file = false; - bool use_given_permissions_dir = false; - bool use_source_permissions = false; - mode_t permissions_file = 0; - mode_t permissions_dir = 0; bool optional = false; - cmFileInstaller::MatchRule* current_match_rule = 0; - for ( ; i != args.size(); ++i ) + bool result = this->ParseInstallArgs(args, installer, components, + configurations, properties, + itype, rename, destination, files, + optional); + if (result == true) { - const std::string* cstr = &args[i]; - if ( *cstr == "DESTINATION" && i < args.size()-1 ) - { - if(current_match_rule) + result = this->DoInstall(installer, components, configurations, properties, + itype, rename, destination, files, optional); + } + return result; +} + +//---------------------------------------------------------------------------- +bool cmFileCommand::ParseInstallArgs(std::vector<std::string> const& args, + cmFileInstaller& installer, + std::set<cmStdString>& components, + std::set<cmStdString>& configurations, + std::map<cmStdString, const char*>& properties, + int& itype, + std::string& rename, + std::string& destination, + std::vector<std::string>& files, + bool& optional) +{ + std::string stype = "FILES"; + bool doing_files = false; + bool doing_properties = false; + bool doing_permissions_file = false; + bool doing_permissions_dir = false; + bool doing_permissions_match = false; + bool doing_components = false; + bool doing_configurations = false; + bool use_given_permissions_file = false; + bool use_given_permissions_dir = false; + bool use_source_permissions = false; + mode_t permissions_file = 0; + mode_t permissions_dir = 0; + + cmFileInstaller::MatchRule* current_match_rule = 0; + std::vector<std::string>::size_type i = 0; + i++; // Get rid of subcommand + for ( ; i != args.size(); ++i ) + { + const std::string* cstr = &args[i]; + if ( *cstr == "DESTINATION" && i < args.size()-1 ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; - } + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } - i++; - destination = args[i]; - doing_files = false; - doing_properties = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "TYPE" && i < args.size()-1 ) - { - if(current_match_rule) + i++; + destination = args[i]; + doing_files = false; + doing_properties = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; + } + else if ( *cstr == "TYPE" && i < args.size()-1 ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + i++; + stype = args[i]; + if ( args[i+1] == "OPTIONAL" ) + { + i++; + optional = true; + } + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; } + else if ( *cstr == "RENAME" && i < args.size()-1 ) + { + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } - i++; - stype = args[i]; - if ( args[i+1] == "OPTIONAL" ) + i++; + rename = args[i]; + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; + } + else if ( *cstr == "REGEX" && i < args.size()-1 ) { i++; - optional = true; + installer.MatchRules.push_back(cmFileInstaller::MatchRule(args[i])); + current_match_rule = &*(installer.MatchRules.end()-1); + if(!current_match_rule->Regex.is_valid()) + { + cmOStringStream e; + e << "INSTALL could not compile REGEX \"" << args[i] << "\"."; + this->SetError(e.str().c_str()); + return false; + } + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; } - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "RENAME" && i < args.size()-1 ) - { - if(current_match_rule) + else if ( *cstr == "EXCLUDE" ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + // Add this property to the current match rule. + if(!current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" + << *cstr << "\" before a REGEX is given."; + this->SetError(e.str().c_str()); + return false; + } + current_match_rule->Properties.Exclude = true; + doing_permissions_match = true; } + else if ( *cstr == "PROPERTIES" ) + { + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } - i++; - rename = args[i]; - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "REGEX" && i < args.size()-1 ) - { - i++; - installer.MatchRules.push_back(cmFileInstaller::MatchRule(args[i])); - current_match_rule = &*(installer.MatchRules.end()-1); - if(!current_match_rule->Regex.is_valid()) + doing_properties = true; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; + } + else if ( *cstr == "PERMISSIONS" ) { - cmOStringStream e; - e << "INSTALL could not compile REGEX \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); - return false; + if(current_match_rule) + { + doing_permissions_match = true; + doing_permissions_file = false; + } + else + { + doing_permissions_match = false; + doing_permissions_file = true; + use_given_permissions_file = true; + } + doing_properties = false; + doing_files = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; } - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "EXCLUDE" ) - { - // Add this property to the current match rule. - if(!current_match_rule) + else if ( *cstr == "DIR_PERMISSIONS" ) { - cmOStringStream e; - e << "INSTALL does not allow \"" - << *cstr << "\" before a REGEX is given."; - this->SetError(e.str().c_str()); - return false; + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + use_given_permissions_dir = true; + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = true; + doing_components = false; + doing_configurations = false; } - current_match_rule->Properties.Exclude = true; - doing_permissions_match = true; - } - else if ( *cstr == "PROPERTIES" ) - { - if(current_match_rule) + else if ( *cstr == "USE_SOURCE_PERMISSIONS" ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; + use_source_permissions = true; + } + else if ( *cstr == "COMPONENTS" ) + { + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = true; + doing_configurations = false; } + else if ( *cstr == "CONFIGURATIONS" ) + { + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } - doing_properties = true; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "PERMISSIONS" ) - { - if(current_match_rule) + doing_properties = false; + doing_files = false; + doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = true; + } + else if ( *cstr == "FILES" && !doing_files) { - doing_permissions_match = true; + if(current_match_rule) + { + cmOStringStream e; + e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; + this->SetError(e.str().c_str()); + return false; + } + + doing_files = true; + doing_properties = false; doing_permissions_file = false; + doing_permissions_dir = false; + doing_components = false; + doing_configurations = false; } - else + else if ( doing_properties && i < args.size()-1 ) { - doing_permissions_match = false; - doing_permissions_file = true; - use_given_permissions_file = true; + properties[args[i]] = args[i+1].c_str(); + i++; } - doing_properties = false; - doing_files = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "DIR_PERMISSIONS" ) - { - if(current_match_rule) + else if ( doing_files ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + files.push_back(*cstr); } - - use_given_permissions_dir = true; - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = true; - doing_components = false; - doing_configurations = false; - } - else if ( *cstr == "USE_SOURCE_PERMISSIONS" ) - { - if(current_match_rule) + else if ( doing_components ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + components.insert(*cstr); } - - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - use_source_permissions = true; - } - else if ( *cstr == "COMPONENTS" ) - { - if(current_match_rule) + else if ( doing_configurations ) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + configurations.insert(cmSystemTools::UpperCase(*cstr)); } - - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = true; - doing_configurations = false; - } - else if ( *cstr == "CONFIGURATIONS" ) - { - if(current_match_rule) + else if(doing_permissions_file) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + if(!installer.CheckPermissions(args[i], permissions_file)) + { + return false; + } } - - doing_properties = false; - doing_files = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = true; - } - else if ( *cstr == "FILES" && !doing_files) - { - if(current_match_rule) + else if(doing_permissions_dir) { - cmOStringStream e; - e << "INSTALL does not allow \"" << *cstr << "\" after REGEX."; - this->SetError(e.str().c_str()); - return false; + if(!installer.CheckPermissions(args[i], permissions_dir)) + { + return false; + } } - - doing_files = true; - doing_properties = false; - doing_permissions_file = false; - doing_permissions_dir = false; - doing_components = false; - doing_configurations = false; - } - else if ( doing_properties && i < args.size()-1 ) - { - properties[args[i]] = args[i+1].c_str(); - i++; - } - else if ( doing_files ) - { - files.push_back(*cstr); - } - else if ( doing_components ) - { - components.insert(*cstr); - } - else if ( doing_configurations ) - { - configurations.insert(cmSystemTools::UpperCase(*cstr)); - } - else if(doing_permissions_file) - { - if(!installer.CheckPermissions(args[i], permissions_file)) + else if(doing_permissions_match) + { + if(!installer.CheckPermissions( + args[i], current_match_rule->Properties.Permissions)) + { + return false; + } + } + else { + this->SetError("called with inappropriate arguments"); return false; } } - else if(doing_permissions_dir) + + // now check and postprocess what has been parsed + if ( files.size() == 0 ) + { + this->SetError( + "called with inapropriate arguments. No FILES provided."); + return false; + } + + // Check rename form. + if(!rename.empty()) { - if(!installer.CheckPermissions(args[i], permissions_dir)) + if(itype != cmTarget::INSTALL_FILES && + itype != cmTarget::INSTALL_PROGRAMS) { + this->SetError("INSTALL option RENAME may be used only with " + "FILES or PROGRAMS."); return false; } - } - else if(doing_permissions_match) - { - if(!installer.CheckPermissions( - args[i], current_match_rule->Properties.Permissions)) + if(files.size() > 1) { + this->SetError("INSTALL option RENAME may be used only with one file."); return false; } } - else + + if (this->HandleInstallDestination(installer, destination) == false) { - this->SetError("called with inappropriate arguments"); return false; } - } - if ( destination.size() < 2 ) - { - this->SetError("called with inapropriate arguments. " - "No DESTINATION provided or ."); - return false; - } + this->GetTargetTypeFromString(stype, itype); + + this->HandleInstallPermissions(installer, + permissions_file, + permissions_dir, + itype, + use_given_permissions_file, + use_given_permissions_dir, + use_source_permissions); + + return true; +} +//---------------------------------------------------------------------------- +bool cmFileCommand::DoInstall( cmFileInstaller& installer, + const std::set<cmStdString>& components, + const std::set<cmStdString>& configurations, + std::map<cmStdString, const char*>& properties, + const int itype, + const std::string& rename, + const std::string& destination, + const std::vector<std::string>& files, + const bool optional) +{ // Check for component-specific installation. const char* cmake_install_component = this->Makefile->GetDefinition("CMAKE_INSTALL_COMPONENT"); @@ -1349,8 +1604,7 @@ bool cmFileCommand::HandleInstallCommand( // Check for configuration-specific installation. if(!configurations.empty()) { - std::string cmake_install_configuration = - cmSystemTools::UpperCase( + std::string cmake_install_configuration = cmSystemTools::UpperCase( this->Makefile->GetSafeDefinition("CMAKE_INSTALL_CONFIG_NAME")); if(cmake_install_configuration.empty()) { @@ -1366,197 +1620,13 @@ bool cmFileCommand::HandleInstallCommand( } } - if ( destdir && *destdir ) - { - std::string sdestdir = destdir; - cmSystemTools::ConvertToUnixSlashes(sdestdir); - - char ch1 = destination[0]; - char ch2 = destination[1]; - char ch3 = 0; - if ( destination.size() > 2 ) - { - ch3 = destination[2]; - } - int skip = 0; - if ( ch1 != '/' ) - { - int relative = 0; - if ( ( ch1 >= 'a' && ch1 <= 'z' || ch1 >= 'A' && ch1 <= 'Z' ) && - ch2 == ':' ) - { - // Assume windows - // let's do some destdir magic: - skip = 2; - if ( ch3 != '/' ) - { - relative = 1; - } - } - else - { - relative = 1; - } - if ( relative ) - { - // This is relative path on unix or windows. Since we are doing - // destdir, this case does not make sense. - this->SetError("called with relative DESTINATION. This " - "does not make sense when using DESTDIR. Specify " - "absolute path or remove DESTDIR environment variable."); - return false; - } - } - else - { - if ( ch2 == '/' ) - { - // looks like a network path. - this->SetError("called with network path DESTINATION. This " - "does not make sense when using DESTDIR. Specify local " - "absolute path or remove DESTDIR environment variable."); - return false; - } - } - destination = sdestdir + (destination.c_str() + skip); - installer.DestDirLength = int(sdestdir.size()); - } - - if ( files.size() == 0 ) - { - this->SetError( - "called with inapropriate arguments. No FILES provided."); - return false; - } - if ( stype == "EXECUTABLE" ) - { - itype = cmTarget::EXECUTABLE; - } - else if ( stype == "PROGRAM" ) - { - itype = cmTarget::INSTALL_PROGRAMS; - } - else if ( stype == "STATIC_LIBRARY" ) - { - itype = cmTarget::STATIC_LIBRARY; - } - else if ( stype == "SHARED_LIBRARY" ) - { - itype = cmTarget::SHARED_LIBRARY; - } - else if ( stype == "MODULE" ) - { - itype = cmTarget::MODULE_LIBRARY; - } - else if ( stype == "DIRECTORY" ) - { - itype = cmTarget::INSTALL_DIRECTORY; - } - - if ( !cmSystemTools::FileExists(destination.c_str()) ) - { - if ( !cmSystemTools::MakeDirectory(destination.c_str()) ) - { - std::string errstring = "cannot create directory: " + destination + - ". Maybe need administrative privileges."; - this->SetError(errstring.c_str()); - return false; - } - } - if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) - { - std::string errstring = "INSTALL destination: " + destination + - " is not a directory."; - this->SetError(errstring.c_str()); - return false; - } - - // Check rename form. - if(!rename.empty()) - { - if(itype != cmTarget::INSTALL_FILES && - itype != cmTarget::INSTALL_PROGRAMS) - { - this->SetError("INSTALL option RENAME may be used only with " - "FILES or PROGRAMS."); - return false; - } - if(files.size() > 1) - { - this->SetError("INSTALL option RENAME may be used only with one file."); - return false; - } - } - - // Choose a default for shared library permissions. - bool install_so_no_exe = this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE"); - - // If file permissions were not specified set default permissions - // for this target type. - if(!use_given_permissions_file && !use_source_permissions) - { - switch(itype) - { - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - if(install_so_no_exe) - { - // Use read/write permissions. - permissions_file = 0; - permissions_file |= mode_owner_read; - permissions_file |= mode_owner_write; - permissions_file |= mode_group_read; - permissions_file |= mode_world_read; - break; - } - case cmTarget::EXECUTABLE: - case cmTarget::INSTALL_PROGRAMS: - // Use read/write/executable permissions. - permissions_file = 0; - permissions_file |= mode_owner_read; - permissions_file |= mode_owner_write; - permissions_file |= mode_owner_execute; - permissions_file |= mode_group_read; - permissions_file |= mode_group_execute; - permissions_file |= mode_world_read; - permissions_file |= mode_world_execute; - break; - default: - // Use read/write permissions. - permissions_file = 0; - permissions_file |= mode_owner_read; - permissions_file |= mode_owner_write; - permissions_file |= mode_group_read; - permissions_file |= mode_world_read; - break; - } - } - - // If directory permissions were not specified set default permissions. - if(!use_given_permissions_dir && !use_source_permissions) - { - // Use read/write/executable permissions. - permissions_dir = 0; - permissions_dir |= mode_owner_read; - permissions_dir |= mode_owner_write; - permissions_dir |= mode_owner_execute; - permissions_dir |= mode_group_read; - permissions_dir |= mode_group_execute; - permissions_dir |= mode_world_read; - permissions_dir |= mode_world_execute; - } - - // Set the installer permissions. - installer.FilePermissions = permissions_file; - installer.DirPermissions = permissions_dir; - // Check whether files should be copied always or only if they have // changed. bool copy_always = cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS")); // Handle each file listed. - for ( i = 0; i < files.size(); i ++ ) + for (std::vector<std::string>::size_type i = 0; i < files.size(); i ++ ) { // Split the input file into its directory and name components. std::vector<std::string> fromPathComponents; @@ -1704,24 +1774,6 @@ bool cmFileCommand::HandleInstallCommand( { return false; } - - // Perform post-installation processing on the file depending - // on its type. -#if defined(__APPLE_CC__) - // Static libraries need ranlib on this platform. - if(itype == cmTarget::STATIC_LIBRARY) - { - std::string ranlib = "ranlib "; - ranlib += cmSystemTools::ConvertToOutputPath(toFile.c_str()); - if(!cmSystemTools::RunSingleCommand(ranlib.c_str())) - { - std::string err = "ranlib failed: "; - err += ranlib; - this->SetError(err.c_str()); - return false; - } - } -#endif } else if(!optional) { diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index d6327b1..f758151 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -19,6 +19,8 @@ #include "cmCommand.h" +struct cmFileInstaller; + /** \class cmFileCommand * \brief Command for manipulation of files * @@ -146,11 +148,45 @@ protected: bool HandleStringsCommand(std::vector<std::string> const& args); bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse); bool HandleMakeDirectoryCommand(std::vector<std::string> const& args); - bool HandleInstallCommand(std::vector<std::string> const& args); + bool HandleRelativePathCommand(std::vector<std::string> const& args); bool HandleCMakePathCommand(std::vector<std::string> const& args, bool nativePath); void ComputeVersionedName(std::string& name, const char* version); + + // FILE(INSTALL ...) related functions + bool HandleInstallCommand(std::vector<std::string> const& args); + bool ParseInstallArgs(std::vector<std::string> const& args, + cmFileInstaller& installer, + std::set<cmStdString>& components, + std::set<cmStdString>& configurations, + std::map<cmStdString, const char*>& properties, + int& itype, + std::string& destination, + std::string& rename, + std::vector<std::string>& files, + bool& optional + ); + bool DoInstall(cmFileInstaller& installer, + const std::set<cmStdString>& components, + const std::set<cmStdString>& configurations, + std::map<cmStdString, const char*>& properties, + const int itype, + const std::string& rename, + const std::string& destination, + const std::vector<std::string>& files, + const bool optional + ); + void GetTargetTypeFromString(const std::string& stype, int& itype) const; + bool HandleInstallDestination(cmFileInstaller& installer, + std::string& destination); + void HandleInstallPermissions(cmFileInstaller& installer, + mode_t& permissions_file, + mode_t& permissions_dir, + int itype, + bool use_given_permissions_file, + bool use_given_permissions_dir, + bool use_source_permissions) const; }; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index d2ac606..0c3ad86 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -25,6 +25,7 @@ cmFindBase::cmFindBase() this->NoCMakeEnvironmentPath = false; this->NoSystemEnvironmentPath = false; this->NoCMakeSystemPath = false; + this->FindRootPathMode = RootPathModeBoth; // default is to search frameworks first on apple #if defined(__APPLE__) this->SearchFrameworkFirst = true; @@ -250,6 +251,24 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) return true; } this->AlreadyInCache = false; + + + std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_"; + findRootPathVar += this->CMakePathName; + std::string rootPathMode = this->Makefile->GetSafeDefinition(findRootPathVar.c_str()); + if (rootPathMode=="NEVER") + { + this->FindRootPathMode = RootPathModeNoRootPath; + } + else if (rootPathMode=="ONLY") + { + this->FindRootPathMode = RootPathModeOnlyRootPath; + } + else if (rootPathMode=="BOTH") + { + this->FindRootPathMode = RootPathModeBoth; + } + std::vector<std::string> userPaths; std::string doc; bool doingNames = true; // assume it starts with a name @@ -328,6 +347,21 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) doingNames = false; this->NoCMakeSystemPath = true; } + else if (args[j] == "NO_CMAKE_FIND_ROOT_PATH") + { + compatibility = false; + this->FindRootPathMode = RootPathModeNoRootPath; + } + else if (args[j] == "ONLY_CMAKE_FIND_ROOT_PATH") + { + compatibility = false; + this->FindRootPathMode = RootPathModeOnlyRootPath; + } + else if (args[j] == "CMAKE_FIND_ROOT_PATH_BOTH") + { + compatibility = false; + this->FindRootPathMode = RootPathModeBoth; + } else { if(doingNames) @@ -358,7 +392,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) if(this->VariableDocumentation.size() == 0) { - this->VariableDocumentation = "Whare can "; + this->VariableDocumentation = "Where can "; if(this->Names.size() == 0) { this->VariableDocumentation += "the (unknown) library be found"; @@ -392,6 +426,8 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } } this->ExpandPaths(userPaths); + + this->HandleCMakeFindRootPath(); return true; } @@ -413,7 +449,7 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths) !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) { // Add CMAKE_*_PATH environment variables - this->AddEnvironmentVairables(); + this->AddEnvironmentVariables(); } if(!this->NoCMakePath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) @@ -421,13 +457,13 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths) // Add CMake varibles of the same name as the previous environment // varibles CMAKE_*_PATH to be used most of the time with -D // command line options - this->AddCMakeVairables(); + this->AddCMakeVariables(); } if(!this->NoSystemEnvironmentPath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) { // add System environment PATH and (LIB or INCLUDE) - this->AddSystemEnvironmentVairables(); + this->AddSystemEnvironmentVariables(); } if(!this->NoCMakeSystemPath && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) @@ -453,7 +489,46 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths) this->AddPaths(paths); } -void cmFindBase::AddEnvironmentVairables() +void cmFindBase::HandleCMakeFindRootPath() +{ + if (this->FindRootPathMode == RootPathModeNoRootPath) + { + return; + } + + const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); + if ((rootPath == 0) || (strlen(rootPath) == 0)) + { + return; + } + + std::vector<std::string> prefixes; + cmSystemTools::ExpandListArgument(rootPath, prefixes); + + std::vector<std::string> unprefixedPaths=this->SearchPaths; + this->SearchPaths.clear(); + + for (std::vector<std::string>::const_iterator prefixIt = prefixes.begin(); + prefixIt != prefixes.end(); + ++prefixIt ) + { + for (std::vector<std::string>::const_iterator it = unprefixedPaths.begin(); + it != unprefixedPaths.end(); + ++it ) + { + std::string prefixedDir=*prefixIt; + prefixedDir+=*it; + this->SearchPaths.push_back(prefixedDir); + } + } + + if (this->FindRootPathMode == RootPathModeBoth) + { + this->AddPaths(unprefixedPaths); + } +} + +void cmFindBase::AddEnvironmentVariables() { std::string var = "CMAKE_"; var += this->CMakePathName; @@ -547,7 +622,7 @@ void cmFindBase::AddAppBundlePaths() this->AddPaths(paths); } -void cmFindBase::AddCMakeVairables() +void cmFindBase::AddCMakeVariables() { std::string var = "CMAKE_"; var += this->CMakePathName; @@ -576,7 +651,7 @@ void cmFindBase::AddCMakeVairables() this->AddPaths(paths); } -void cmFindBase::AddSystemEnvironmentVairables() +void cmFindBase::AddSystemEnvironmentVariables() { // Add LIB or INCLUDE std::vector<std::string> paths; diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index e9fae38..95fc258 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -39,16 +39,20 @@ public: virtual const char* GetFullDocumentation() {return this->GenericDocumentation.c_str();} + enum RootPathMode { RootPathModeBoth, RootPathModeOnlyRootPath, RootPathModeNoRootPath }; + protected: void PrintFindStuff(); void ExpandPaths(std::vector<std::string> userPaths); + void HandleCMakeFindRootPath(); + // add to the SearchPaths void AddPaths(std::vector<std::string>& paths); void AddFrameWorkPaths(); void AddAppBundlePaths(); - void AddEnvironmentVairables(); - void AddCMakeVairables(); - void AddSystemEnvironmentVairables(); + void AddEnvironmentVariables(); + void AddCMakeVariables(); + void AddSystemEnvironmentVariables(); void AddCMakeSystemVariables(); void ExpandRegistryAndCleanPath(std::vector<std::string>& paths); // see if the VariableName is already set in the cache, @@ -75,6 +79,7 @@ protected: bool NoCMakeEnvironmentPath; bool NoSystemEnvironmentPath; bool NoCMakeSystemPath; + RootPathMode FindRootPathMode; bool SearchFrameworkFirst; bool SearchFrameworkOnly; diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 5cab7d3..8b63fe9 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -20,21 +20,55 @@ // cmIncludeCommand bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args) { - if (args.size()< 1 || args.size() > 2) + if (args.size()< 1 || args.size() > 4) { this->SetError("called with wrong number of arguments. " "Include only takes one file."); return false; } bool optional = false; - - std::string fname = args[0].c_str(); - - if(args.size() == 2) + std::string fname = args[0]; + std::string resultVarName; + + for (unsigned int i=1; i<args.size(); i++) { - optional = args[1] == "OPTIONAL"; + if (args[i] == "OPTIONAL") + { + if (optional) + { + this->SetError("called with invalid arguments: OPTIONAL used twice"); + return false; + } + optional = true; + } + else if(args[i] == "RESULT_VARIABLE") + { + if (resultVarName.size() > 0) + { + this->SetError("called with invalid arguments: " + "only one result variable allowed"); + return false; + } + if(++i < args.size()) + { + resultVarName = args[i]; + } + else + { + this->SetError("called with no value for RESULT_VARIABLE."); + return false; + } + } + else if(i > 1) // compat.: in previous cmake versions the second + // parameter was ignore if it wasn't "OPTIONAL" + { + std::string errorText = "called with invalid argument: "; + errorText += args[i]; + this->SetError(errorText.c_str()); + return false; + } } - + if(!cmSystemTools::FileIsFullPath(fname.c_str())) { // Not a path. Maybe module. @@ -46,9 +80,18 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args) fname = mfile.c_str(); } } + std::string fullFilePath; bool readit = this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), - fname.c_str() ); + fname.c_str(), &fullFilePath ); + + // add the location of the included file if a result variable was given + if (resultVarName.size()) + { + this->Makefile->AddDefinition(resultVarName.c_str(), + readit?fullFilePath.c_str():"NOTFOUND"); + } + if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) { std::string m = "Could not find include file: "; diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 8fc9833..428df0c 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -68,12 +68,14 @@ public: virtual const char* GetFullDocumentation() { return - " INCLUDE(file1 [OPTIONAL])\n" - " INCLUDE(module [OPTIONAL])\n" + " INCLUDE(file1 [OPTIONAL] [RESULT_VARIABLE <VAR>])\n" + " INCLUDE(module [OPTIONAL] [RESULT_VARIABLE <VAR>])\n" "Reads CMake listfile code from the given file. Commands in the file " "are processed immediately as if they were written in place of the " "INCLUDE command. If OPTIONAL is present, then no error " - "is raised if the file does not exist.\n" + "is raised if the file does not exist. If RESULT_VARIABLE is given " + "the variable will be set to the full filename which " + "has been included or NOTFOUND if it failed.\n" "If a module is specified instead of a file, the file with name " "<modulename>.cmake is searched in the CMAKE_MODULE_PATH."; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index fd92eab..bd3f864 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -19,7 +19,6 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmTarget.h" #include "cmake.h" //---------------------------------------------------------------------------- @@ -171,12 +170,21 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) no_rename, literal_args.c_str()); // Fix the install_name settings in installed binaries. - if(type == cmTarget::SHARED_LIBRARY || + if((type == cmTarget::SHARED_LIBRARY || type == cmTarget::MODULE_LIBRARY || - type == cmTarget::EXECUTABLE) + type == cmTarget::EXECUTABLE) && + this->Target->GetMakefile()->IsSet("CMAKE_INSTALL_NAME_TOOL")) { this->AddInstallNamePatchRule(os, destination.c_str()); } + + std::string destinationFilename = destination; + destinationFilename += "/"; + destinationFilename += cmSystemTools::GetFilenameName(fromFile); + + this->AddRanlibRule(os, type, destinationFilename); + + this->AddStripRule(os, destinationFilename); } //---------------------------------------------------------------------------- @@ -417,7 +425,9 @@ void cmInstallTargetGenerator component_test += this->Component; component_test += ")$\""; os << "IF(" << component_test << ")\n"; - os << " EXECUTE_PROCESS(COMMAND install_name_tool"; + os << " EXECUTE_PROCESS(COMMAND \""; + os <<this->Target->GetMakefile()->GetDefinition("CMAKE_INSTALL_NAME_TOOL"); + os << "\""; if(!new_id.empty()) { os << "\n -id \"" << new_id << "\""; @@ -433,3 +443,54 @@ void cmInstallTargetGenerator os << "ENDIF(" << component_test << ")\n"; } } + +void cmInstallTargetGenerator::AddStripRule(std::ostream& os, + const std::string& destinationFilename) +{ + + // Don't handle OSX Bundles. + if(this->Target->GetMakefile()->IsOn("APPLE") && + this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + { + return; + } + + if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP")) + { + return; + } + + os << "IF(CMAKE_INSTALL_DO_STRIP)\n"; + os << " EXECUTE_PROCESS(COMMAND \""; + os << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP"); + os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n"; + os << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n"; +} + +void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, + cmTarget::TargetType type, + const std::string& destinationFilename) +{ + // Static libraries need ranlib on this platform. + if(type != cmTarget::STATIC_LIBRARY) + { + return; + } + + // Perform post-installation processing on the file depending + // on its type. + if(!this->Target->GetMakefile()->IsOn("APPLE")) + { + return; + } + + std::string ranlib = this->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB"); + if (!ranlib.size()) + { + return; + } + + os << "EXECUTE_PROCESS(COMMAND \""; + os << ranlib; + os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n"; +} diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 77f9fec..c7dcec5 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -18,8 +18,7 @@ #define cmInstallTargetGenerator_h #include "cmInstallGenerator.h" - -class cmTarget; +#include "cmTarget.h" /** \class cmInstallTargetGenerator * \brief Generate target installation rules. @@ -45,6 +44,10 @@ protected: std::string GetScriptReference(cmTarget* target, const char* place, bool useSOName); void AddInstallNamePatchRule(std::ostream& os, const char* destination); + void AddStripRule(std::ostream& os, const std::string& destinationFilename); + void AddRanlibRule(std::ostream& os, cmTarget::TargetType type, + const std::string& destinationFilename); + cmTarget* Target; std::string Destination; bool ImportLibrary; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4cc265f..2d345df 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -370,7 +370,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff) // Parse the given CMakeLists.txt file executing all commands // bool cmMakefile::ReadListFile(const char* filename_in, - const char *external_in) + const char *external_in, + std::string* fullPath) { std::string currentParentFile = this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE"); @@ -446,12 +447,19 @@ bool cmMakefile::ReadListFile(const char* filename_in, // push the listfile onto the stack this->ListFileStack.push_back(filenametoread); - + if(fullPath!=0) + { + *fullPath=filenametoread; + } cmListFile cacheFile; if( !cacheFile.ParseFile(filenametoread, requireProjectCommand) ) { // pop the listfile off the stack this->ListFileStack.pop_back(); + if(fullPath!=0) + { + fullPath->clear(); + } this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); return false; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 5d18ead..68780cf 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -72,7 +72,9 @@ public: /** * Read and parse a CMakeLists.txt file. */ - bool ReadListFile(const char* listfile, const char* external= 0); + bool ReadListFile(const char* listfile, + const char* external= 0, + std::string* fullPath= 0); /** * Add a function blocker to this makefile diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index ce991cb..127f8ac 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -18,13 +18,20 @@ #include "cmCacheManager.h" #include "cmTryCompileCommand.h" -// cmExecutableCommand +// cmTryRunCommand bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) { if(argv.size() < 4) { return false; } + + if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) + { + this->SetError("doesn't work when crosscompiling."); + cmSystemTools::SetFatalErrorOccured(); + return false; + } // build an arg list for TryCompile and extract the runArgs std::vector<std::string> tryCompile; @@ -75,10 +82,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) { int retVal = -1; std::string output; + std::string executableSuffix=this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); std::string command1 = binaryDirectory; std::vector<std::string> attemptedPaths; command1 += "/cmTryCompileExec"; - command1 += cmSystemTools::GetExecutableExtension(); + command1 += executableSuffix; std::string fullPath; if(cmSystemTools::FileExists(command1.c_str())) { @@ -97,7 +105,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) command1 += "/"; command1 += config; command1 += "/cmTryCompileExec"; - command1 += cmSystemTools::GetExecutableExtension(); + command1 += executableSuffix; if(cmSystemTools::FileExists(command1.c_str())) { fullPath = cmSystemTools::CollapseFullPath(command1.c_str()); @@ -110,7 +118,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) { command1 = binaryDirectory; command1 += "/Debug/cmTryCompileExec"; - command1 += cmSystemTools::GetExecutableExtension(); + command1 += executableSuffix; if(cmSystemTools::FileExists(command1.c_str())) { fullPath = cmSystemTools::CollapseFullPath(command1.c_str()); @@ -122,7 +130,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv) { command1 = binaryDirectory; command1 += "/Development/cmTryCompileExec"; - command1 += cmSystemTools::GetExecutableExtension(); + command1 += executableSuffix; if(cmSystemTools::FileExists(command1.c_str())) { fullPath = cmSystemTools::CollapseFullPath(command1.c_str()); diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 5160189..8b7a3e2 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -88,7 +88,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args) // Construct the cache entry for the executable's location. std::string utilityExecutable = utilityDirectory+"/"+cmakeCFGout+"/" - +utilityName+cmSystemTools::GetExecutableExtension(); + +utilityName+this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX"); // make sure we remove any /./ in the name cmSystemTools::ReplaceString(utilityExecutable, "/./", "/"); diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 3dd58c8..e1866ef 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -72,7 +72,14 @@ public: "is assumed that the source tree of the utility will have been built " "before it is needed."; } - + + /** This command is kept for compatibility with older CMake versions. */ + virtual bool IsDiscouraged() + { + return true; + } + + cmTypeMacro(cmUtilitySourceCommand, cmCommand); }; |