diff options
-rw-r--r-- | Source/MFCDialog/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 85 | ||||
-rw-r--r-- | Source/cmInstallTargetsCommand.cxx | 15 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmTarget.h | 7 |
6 files changed, 126 insertions, 36 deletions
diff --git a/Source/MFCDialog/CMakeLists.txt b/Source/MFCDialog/CMakeLists.txt index 70fcc44..c23a3bb 100644 --- a/Source/MFCDialog/CMakeLists.txt +++ b/Source/MFCDialog/CMakeLists.txt @@ -1,12 +1,12 @@ SET( SRCS -CMakeSetup.cpp -MakeHelp.cpp -CMakeSetup.rc -CMakeSetupDialog.cpp -PathDialog.cpp -PropertyList.cpp -StdAfx.cpp -CMakeCommandLineInfo.cpp + CMakeSetup.cpp + MakeHelp.cpp + CMakeSetup.rc + CMakeSetupDialog.cpp + PathDialog.cpp + PropertyList.cpp + StdAfx.cpp + CMakeCommandLineInfo.cpp ) # add stuff to use MFC in this executable @@ -16,3 +16,4 @@ SET(CMAKE_MFC_FLAG 6) ADD_EXECUTABLE(CMakeSetup WIN32 ${SRCS}) TARGET_LINK_LIBRARIES(CMakeSetup CMakeLib) ADD_DEPENDENCIES(CMakeSetup cmake) +INSTALL_TARGETS(/bin CMakeSetup) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b6ddfcf..68170e0 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -237,6 +237,14 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) std::string destination = ""; std::string stype = "FILES"; + const char* build_type = m_Makefile->GetDefinition("BUILD_TYPE"); + std::string extra_dir = ""; + if ( build_type ) + { + extra_dir = build_type; + } + + std::vector<std::string> files; int itype = cmTarget::INSTALL_FILES; @@ -245,6 +253,7 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) std::string expr; bool in_files = false; + bool optional = false; for ( ; i != args.size(); ++i ) { const std::string* cstr = &args[i]; @@ -258,6 +267,11 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) { i++; stype = args[i]; + if ( args[i+1] == "OPTIONAL" ) + { + i++; + optional = true; + } in_files = false; } else if ( *cstr == "FILES" && !in_files) @@ -289,6 +303,10 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) { itype = cmTarget::EXECUTABLE; } + else if ( stype == "PROGRAM" ) + { + itype = cmTarget::INSTALL_PROGRAMS; + } else if ( stype == "STATIC_LIBRARY" ) { itype = cmTarget::STATIC_LIBRARY; @@ -302,12 +320,6 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) itype = cmTarget::MODULE_LIBRARY; } - for ( i = 0; i < files.size(); i ++ ) - { - std::cout << " " << files[i]; - } - std::cout << std::endl; - if ( !cmSystemTools::FileExists(destination.c_str()) ) { if ( !cmSystemTools::MakeDirectory(destination.c_str()) ) @@ -329,33 +341,62 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args) for ( i = 0; i < files.size(); i ++ ) { std::string destfile = destination + "/" + cmSystemTools::GetFilenameName(files[i]); - - if ( !cmSystemTools::CopyFileAlways(files[i].c_str(), destination.c_str()) ) - { - std::string errstring = "cannot copy file: " + files[i] + - " to directory : " + destination + "."; - this->SetError(errstring.c_str()); - return false; - } + std::string ctarget = files[i].c_str(); switch( itype ) { case cmTarget::MODULE_LIBRARY: + case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::EXECUTABLE: + if ( extra_dir.size() > 0 ) + { + cmOStringStream str; + str << cmSystemTools::GetFilenamePath(ctarget) << "/" << extra_dir << "/" + << cmSystemTools::GetFilenameName(ctarget); + ctarget = str.str(); + } + break; + } + + if ( cmSystemTools::FileExists(ctarget.c_str()) ) + { + if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(), destination.c_str()) ) + { + std::string errstring = "cannot copy file: " + ctarget + + " to directory : " + destination + "."; + this->SetError(errstring.c_str()); + return false; + } + switch( itype ) + { + case cmTarget::MODULE_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::EXECUTABLE: + case cmTarget::INSTALL_PROGRAMS: - if ( !cmSystemTools::SetPermissions(destfile.c_str(), + if ( !cmSystemTools::SetPermissions(destfile.c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) - S_IREAD | S_IWRITE | S_IEXEC + S_IREAD | S_IWRITE | S_IEXEC #elif defined( __BORLANDC__ ) - S_IRUSR | S_IWUSR | S_IXUSR + S_IRUSR | S_IWUSR | S_IXUSR #else - S_IRUSR | S_IWUSR | S_IXUSR | - S_IRGRP | S_IXGRP | - S_IROTH | S_IXOTH + S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IXGRP | + S_IROTH | S_IXOTH #endif - ) ) + ) ) + { + perror("problem doing chmod."); + } + } + } + else + { + if ( !optional ) { - perror("problem doing chmod."); + std::string errstring = "cannot find file: " + ctarget + " to install."; + this->SetError(errstring.c_str()); + return false; } } } diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 1553754..421fcea 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -28,11 +28,24 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args) cmTargets &tgts = m_Makefile->GetTargets(); std::vector<std::string>::const_iterator s = args.begin(); ++s; + std::string runtime_dir = "/bin"; for (;s != args.end(); ++s) { - if (tgts.find(*s) != tgts.end()) + if (*s == "RUNTIME_DIRECTORY") + { + ++s; + if ( s == args.end() ) + { + this->SetError("called with RUNTIME_DIRECTORY but no actual directory"); + return false; + } + + runtime_dir = *s; + } + else if (tgts.find(*s) != tgts.end()) { tgts[*s].SetInstallPath(args[0].c_str()); + tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str()); } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0a19def..5ad32cb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -127,13 +127,38 @@ void cmLocalGenerator::GenerateInstallRules() switch (type) { case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: fname = libOutPath; fname += this->GetFullTargetName(l->first.c_str(), l->second); files = fname.c_str(); this->AddInstallRule(fout, dest, type, files); break; + case cmTarget::SHARED_LIBRARY: + { + // Special code to handle DLL + fname = libOutPath; + fname += this->GetFullTargetName(l->first.c_str(), l->second); + std::string ext = cmSystemTools::GetFilenameExtension(fname); + ext = cmSystemTools::LowerCase(ext); + if ( ext == ".dll" ) + { + std::string libname = libOutPath; + libname += cmSystemTools::GetFilenameWithoutExtension(fname); + libname += ".lib"; + std::cout << "This is dll: " << libname << std::endl; + files = libname.c_str(); + this->AddInstallRule(fout, dest, cmTarget::STATIC_LIBRARY, files, true); + std::string dlldest = prefix + l->second.GetRuntimeInstallPath(); + files = fname.c_str(); + this->AddInstallRule(fout, dlldest.c_str(), type, files); + } + else + { + files = fname.c_str(); + this->AddInstallRule(fout, dest, type, files); + } + } + break; case cmTarget::WIN32_EXECUTABLE: case cmTarget::EXECUTABLE: fname = exeOutPath; @@ -213,14 +238,15 @@ void cmLocalGenerator::GenerateInstallRules() } } -void cmLocalGenerator::AddInstallRule(std::ostream& fout, const char* dest, int type, const char* files) +void cmLocalGenerator::AddInstallRule(std::ostream& fout, const char* dest, + int type, const char* files, bool optional) { std::string sfiles = files; std::string destination = dest; std::string stype; switch ( type ) { - case cmTarget::INSTALL_PROGRAMS: + case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break; case cmTarget::EXECUTABLE: case cmTarget::WIN32_EXECUTABLE: stype = "EXECUTABLE"; break; case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break; @@ -232,7 +258,8 @@ void cmLocalGenerator::AddInstallRule(std::ostream& fout, const char* dest, int fout << "MESSAGE(STATUS \"Install " << stype << ": " << sfiles.c_str() << "\")\n" << "FILE(INSTALL DESTINATION \"" << destination.c_str() - << "\" TYPE " << stype.c_str() << " FILES \"" << sfiles.c_str() << "\")\n"; + << "\" TYPE " << stype.c_str() << (optional?" OPTIONAL":"") + << " FILES \"" << sfiles.c_str() << "\")\n"; } const char* cmLocalGenerator::GetSafeDefinition(const char* def) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index e773568..c7e1e20 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -79,7 +79,8 @@ public: std::string ConvertToRelativeOutputPath(const char* p); protected: - virtual void AddInstallRule(std::ostream& fout, const char* dest, int type, const char* files); + virtual void AddInstallRule(std::ostream& fout, const char* dest, int type, + const char* files, bool optional = false); bool m_FromTheTop; cmMakefile *m_Makefile; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 303406e..d31ca3a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -119,6 +119,12 @@ public: std::string GetInstallPath() const {return m_InstallPath;} void SetInstallPath(const char *name) {m_InstallPath = name;} + /** + * Set the path where this target (if it has a runtime part) should be + * installed. This is relative to INSTALL_PREFIX + */ + std::string GetRuntimeInstallPath() const {return m_RuntimeInstallPath;} + void SetRuntimeInstallPath(const char *name) {m_RuntimeInstallPath = name;} /** * Generate the SourceFilesList from the SourceLists. This should only be @@ -213,6 +219,7 @@ private: std::vector<std::string> m_LinkDirectories; bool m_InAll; std::string m_InstallPath; + std::string m_RuntimeInstallPath; std::set<cmStdString> m_Utilities; bool m_RecordDependencies; std::map<cmStdString,cmStdString> m_Properties; |