From 27617df8b032a3c70cc88b403dcf7d650d474ae4 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 20 Feb 2002 15:26:51 -0500 Subject: [PATCH] close to dot net working --- Source/cmMSDotNETGenerator.cxx | 244 +++++++++++++++++++++------------ Source/cmaketest.cxx | 19 +++ 2 files changed, 177 insertions(+), 86 deletions(-) diff --git a/Source/cmMSDotNETGenerator.cxx b/Source/cmMSDotNETGenerator.cxx index 4a4be7d957..d99881e009 100644 --- a/Source/cmMSDotNETGenerator.cxx +++ b/Source/cmMSDotNETGenerator.cxx @@ -27,9 +27,9 @@ cmMSDotNETGenerator::cmMSDotNETGenerator() { m_Configurations.push_back("Debug"); - m_Configurations.push_back("Release"); - m_Configurations.push_back("MinSizeRel"); - m_Configurations.push_back("RelWithDebInfo"); +// m_Configurations.push_back("Release"); +// m_Configurations.push_back("MinSizeRel"); +// m_Configurations.push_back("RelWithDebInfo"); // default to building a sln project file BuildProjOn(); } @@ -42,34 +42,6 @@ void cmMSDotNETGenerator::GenerateMakefile() } else { - m_LibraryOutputPath = ""; - if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) - { - m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); - } - if(m_LibraryOutputPath.size()) - { - // make sure there is a trailing slash - if(m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/') - { - m_LibraryOutputPath += "/"; - } - m_LibraryOutputPath = cmSystemTools::HandleNetworkPaths(m_LibraryOutputPath.c_str()); - } - m_ExecutableOutputPath = ""; - if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) - { - m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); - } - if(m_ExecutableOutputPath.size()) - { - // make sure there is a trailing slash - if(m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/') - { - m_ExecutableOutputPath += "/"; - } - } - m_ExecutableOutputPath = cmSystemTools::HandleNetworkPaths(m_ExecutableOutputPath.c_str()); this->OutputVCProjFile(); } } @@ -248,12 +220,16 @@ void cmMSDotNETGenerator::WriteSLNFile(std::ostream& fout) } } fout << "Global\n" - << "\tGlobalSection(SolutionConfiguration) = preSolution\n" - << "\t\tConfigName.0 = Debug\n" - << "\t\tConfigName.1 = MinSizeRel\n" - << "\t\tConfigName.2 = Release\n" - << "\t\tConfigName.3 = RelWithDebInfo\n" - << "\tEndGlobalSection\n" + << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; + + int c = 0; + for(std::vector::iterator i = m_Configurations.begin(); + i != m_Configurations.end(); ++i) + { + fout << "\t\tConfigName." << c << " = " << *i << "\n"; + c++; + } + fout << "\tEndGlobalSection\n" << "\tGlobalSection(ProjectDependencies) = postSolution\n"; // loop over again and compute the depends for(k = allListFiles.begin(); k != allListFiles.end(); ++k) @@ -396,17 +372,16 @@ void cmMSDotNETGenerator::WriteProjectDepends(std::ostream& fout, void cmMSDotNETGenerator::WriteProjectConfigurations(std::ostream& fout, const char* name) { std::string guid = this->CreateGUID(name); - fout << "\t\t{" << guid << "}.Debug.ActiveCfg = Debug|Win32\n" - << "\t\t{" << guid << "}.Debug.Build.0 = Debug|Win32\n" - << "\t\t{" << guid << "}.MinSizeRel.ActiveCfg = Debug|Win32\n" - << "\t\t{" << guid << "}.MinSizeRel.Build.0 = Debug|Win32\n" - << "\t\t{" << guid << "}.Release.ActiveCfg = Debug|Win32\n" - << "\t\t{" << guid << "}.Release.Build.0 = Debug|Win32\n" - << "\t\t{" << guid << "}.RelWithDebInfo.ActiveCfg = Debug|Win32\n" - << "\t\t{" << guid << "}.RelWithDebInfo.Build.0 = Debug|Win32\n"; + for(std::vector::iterator i = m_Configurations.begin(); + i != m_Configurations.end(); ++i) + { + fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n" + << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|Win32\n"; + } } + // Write a dsp file into the SLN file, // Note, that dependencies from executables to // the libraries it uses are also done here @@ -497,8 +472,36 @@ void cmMSDotNETGenerator::OutputVCProjFile() m_Makefile->GetStartOutputDirectory()); } } - - // Setup /I and /LIBPATH options for the resulting VCProj file + + m_LibraryOutputPath = ""; + if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH")) + { + m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"); + } + if(m_LibraryOutputPath.size()) + { + // make sure there is a trailing slash + if(m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/') + { + m_LibraryOutputPath += "/"; + } + m_LibraryOutputPath = cmSystemTools::HandleNetworkPaths(m_LibraryOutputPath.c_str()); + } + m_ExecutableOutputPath = ""; + if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) + { + m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + } + if(m_ExecutableOutputPath.size()) + { + // make sure there is a trailing slash + if(m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/') + { + m_ExecutableOutputPath += "/"; + } + } + m_ExecutableOutputPath = cmSystemTools::HandleNetworkPaths(m_ExecutableOutputPath.c_str()); + std::vector& includes = m_Makefile->GetIncludeDirectories(); std::vector::iterator i; for(i = includes.begin(); i != includes.end(); ++i) @@ -645,9 +648,38 @@ void cmMSDotNETGenerator::WriteConfiguration(std::ostream& fout, } fout << "\t\t\n"; @@ -656,32 +688,6 @@ void cmMSDotNETGenerator::WriteConfiguration(std::ostream& fout, << "\t\t\t\tAdditionalOptions=\"" << m_Makefile->GetDefinition("CMAKE_CXX_FLAGS") << "\"\n"; - - if(strcmp(configName, "Debug") == 0) - { - fout << "\t\t\t\tOptimization=\"0\"\n" - << "\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_WINDOWS"; - } - else if(strcmp(configName, "Release") == 0) - { - fout << "\t\t\t\tOptimization=\"2\"\n" - << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" - << "\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS"; - } - else if(strcmp(configName, "MinSizeRel") == 0) - { - fout << "\t\t\t\tOptimization=\"1\"\n" - << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" - << "\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS"; - } - else if(strcmp(configName, "RelWithDebInfo") == 0) - { - fout << "\t\t\t\tOptimization=\"2\"\n" - << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" - << "\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_WINDOWS"; - } - this->OutputDefineFlags(fout); - fout << "\"\n"; fout << "\t\t\t\tAdditionalIncludeDirectories=\""; std::vector& includes = m_Makefile->GetIncludeDirectories(); std::vector::iterator i = includes.begin(); @@ -694,8 +700,37 @@ void cmMSDotNETGenerator::WriteConfiguration(std::ostream& fout, fout << ";"" << *i << """; } fout << "\"\n"; + + if(strcmp(configName, "Debug") == 0) + { + fout << "\t\t\t\tOptimization=\"0\"\n" + << "\t\t\t\tRuntimeLibrary=\"3\"\n" + << "\t\t\t\tPreprocessorDefinitions=\"WIN32,_DEBUG,_WINDOWS"; + } + else if(strcmp(configName, "Release") == 0) + { + fout << "\t\t\t\tOptimization=\"2\"\n" + << "\t\t\t\tRuntimeLibrary=\"0\"\n" + << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" + << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS"; + } + else if(strcmp(configName, "MinSizeRel") == 0) + { + fout << "\t\t\t\tOptimization=\"1\"\n" + << "\t\t\t\tRuntimeLibrary=\"0\"\n" + << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" + << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS"; + } + else if(strcmp(configName, "RelWithDebInfo") == 0) + { + fout << "\t\t\t\tOptimization=\"2\"\n" + << "\t\t\t\tInlineFunctionExpansion=\"1\"\n" + << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS"; + } + this->OutputDefineFlags(fout); + fout << "\"\n"; fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n"; - fout << "\t\t\t\tObjectFile=\"" << configName << "\"\n"; + fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n"; fout << "\t\t\t\tProgramDataBaseFileName=\"" << configName << "\"\n"; fout << "\t\t\t\tWarningLevel=\"3\"\n"; fout << "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n" @@ -720,7 +755,7 @@ void cmMSDotNETGenerator::OutputBuildTool(std::ostream& fout, case cmTarget::STATIC_LIBRARY: fout << "\t\t\t\n"; break; case cmTarget::SHARED_LIBRARY: @@ -733,11 +768,11 @@ void cmMSDotNETGenerator::OutputBuildTool(std::ostream& fout, << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib "; this->OutputLibraries(fout, configName, libName, target); fout << "\"\n"; - fout << "\t\t\t\tOutputFile=\"" << m_LibraryOutputPath << + fout << "\t\t\t\tOutputFile=\"" << m_ExecutableOutputPath << configName << "/" << libName << ".exe\"\n"; fout << "\t\t\t\tLinkIncremental=\"1\"\n"; fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n"; - fout << "AdditionalLibraryDirectories=\""; + fout << "\t\t\t\tAdditionalLibraryDirectories=\""; this->OutputLibraryDirectories(fout, configName, libName, target); fout << "\"\n"; fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath << libName << ".pdb\"\n"; @@ -745,6 +780,22 @@ void cmMSDotNETGenerator::OutputBuildTool(std::ostream& fout, fout << "\t\t\t\tStackReserveSize=\"10000000\"/>\n"; break; case cmTarget::WIN32_EXECUTABLE: + fout << "\t\t\tOutputLibraries(fout, configName, libName, target); + fout << "\"\n"; + fout << "\t\t\t\tOutputFile=\"" << m_ExecutableOutputPath << + configName << "/" << libName << ".exe\"\n"; + fout << "\t\t\t\tLinkIncremental=\"1\"\n"; + fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n"; + fout << "\t\t\t\tAdditionalLibraryDirectories=\""; + this->OutputLibraryDirectories(fout, configName, libName, target); + fout << "\"\n"; + fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath << libName << ".pdb\"\n"; + fout << "\t\t\t\tSubSystem=\"2\"\n"; + fout << "\t\t\t\tStackReserveSize=\"10000000\"/>\n"; break; case cmTarget::UTILITY: break; @@ -756,7 +807,18 @@ void cmMSDotNETGenerator::OutputLibraryDirectories(std::ostream& fout, const char* libName, const cmTarget &target) { - fout << m_LibraryOutputPath << "$(INTDIR)," << m_LibraryOutputPath; + bool hasone = false; + if(m_LibraryOutputPath.size()) + { + hasone = true; + fout << m_LibraryOutputPath << "$(INTDIR)," << m_LibraryOutputPath; + } + if(m_ExecutableOutputPath.size()) + { + hasone = true; + fout << m_ExecutableOutputPath << "$(INTDIR)," << m_ExecutableOutputPath; + } + std::set pathEmitted; std::vector::iterator i; std::vector& libdirs = m_Makefile->GetLinkDirectories(); @@ -769,10 +831,14 @@ void cmMSDotNETGenerator::OutputLibraryDirectories(std::ostream& fout, } if(pathEmitted.insert(lpath).second) { - fout << "," << lpath; + if(hasone) + { + fout << ","; + } + fout << lpath; + hasone = true; } } - } void cmMSDotNETGenerator::OutputLibraries(std::ostream& fout, @@ -817,7 +883,7 @@ void cmMSDotNETGenerator::OutputDefineFlags(std::ostream& fout) define = defs.substr(pos+2); done = true; } - fout << define << ";"; + fout << define << ","; if(!done) { pos = defs.find("-D", nextpos); @@ -902,10 +968,11 @@ void cmMSDotNETGenerator::WriteVCProjFile(std::ostream& fout, if (source != libName || target.GetType() == cmTarget::UTILITY) { fout << "\t\t\t\n"; + fout << "\t\t\t\tRelativePath=\"" << cmSystemTools::EscapeSpaces(d.c_str()) << "\">\n"; if (!commands.empty()) { cmSourceGroup::CommandFiles totalCommand; @@ -961,6 +1028,11 @@ void cmMSDotNETGenerator::WriteCustomRule(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\t\tOutputs=\""; + if(outputs.size() == 0) + { + fout << source << "_force"; + } + bool first = true; // Write a rule for every output generated by this command. for(std::set::const_iterator output = outputs.begin(); diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx index 707f1833c2..eeefdc3a2e 100644 --- a/Source/cmaketest.cxx +++ b/Source/cmaketest.cxx @@ -124,6 +124,7 @@ int main (int argc, char *argv[]) cmSystemTools::LowerCase(lowerCaseCommand); // if msdev is the make program then do the following + // MSDEV 6.0 if(lowerCaseCommand.find("msdev") != std::string::npos) { // if there are spaces in the makeCommand, assume a full path @@ -145,6 +146,24 @@ int main (int argc, char *argv[]) makeCommand += projectName; makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD"; } + // MSDEV 7.0 .NET + else if (lowerCaseCommand.find("devenv") != std::string::npos) + { + if(makeCommand.find(' ') != std::string::npos) + { + char *buffer = new char[makeCommand.size()+1]; + if(GetShortPathName(makeCommand.c_str(), buffer, + makeCommand.size()+1) != 0) + { + makeCommand = buffer; + } + delete [] buffer;\ + } + makeCommand += " "; + makeCommand += projectName; + makeCommand += ".sln /rebuild Debug /project ALL_BUILD"; + } + // command line make program else { // assume a make sytle program