From 86195caf6ad23d6528748ad3879394b8709513c5 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 5 Jul 2004 12:16:33 -0400 Subject: [PATCH] ENH: add support for VCExpress 2005 --- Modules/CMakeVS8FindMake.cmake | 10 ++++ Modules/Platform/Windows-cl.cmake | 68 +++++++++++++++-------- Source/CMakeLists.txt | 3 + Source/MFCDialog/CMakeSetupDialog.cpp | 22 ++++++-- Source/cmGlobalGenerator.cxx | 13 +++++ Source/cmGlobalVisualStudio8Generator.cxx | 54 ++++++++++++++++++ Source/cmGlobalVisualStudio8Generator.h | 48 ++++++++++++++++ Source/cmLocalVisualStudio7Generator.cxx | 15 +++-- Source/cmLocalVisualStudio7Generator.h | 5 +- Source/cmake.cxx | 3 + 10 files changed, 207 insertions(+), 34 deletions(-) create mode 100644 Modules/CMakeVS8FindMake.cmake create mode 100644 Source/cmGlobalVisualStudio8Generator.cxx create mode 100644 Source/cmGlobalVisualStudio8Generator.h diff --git a/Modules/CMakeVS8FindMake.cmake b/Modules/CMakeVS8FindMake.cmake new file mode 100644 index 000000000..ec3a3ca43 --- /dev/null +++ b/Modules/CMakeVS8FindMake.cmake @@ -0,0 +1,10 @@ +FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES VCExpress + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VS;EnvironmentDirectory] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path] + "c:/Program Files/Microsoft Visual Studio 8/Common7/IDE" + "c:/Program Files/Microsoft Visual Studio8/Common7/IDE" + "/Program Files/Microsoft Visual Studio 8/Common7/IDE/" + ) +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index d047abaae..c8ee0faf0 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -40,28 +40,10 @@ SET(CMAKE_CXX_LINK_EXECUTABLE SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows) SET(CMAKE_CREATE_CONSOLE_EXE /subsystem:console) -# default to Debug builds -SET(CMAKE_BUILD_TYPE_INIT Debug) -SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR") -SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") -SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") -SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") -SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000") -SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") -SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") -SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") -SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") - - -SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING - "Libraries linked by defalut with all applications.") -MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES) - IF(CMAKE_GENERATOR MATCHES "Visual Studio 6") SET (CMAKE_NO_BUILD_TYPE 1) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6") -IF(CMAKE_GENERATOR MATCHES "Visual Studio 7") +IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") SET (CMAKE_NO_BUILD_TYPE 1) SET (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING "Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.") @@ -70,10 +52,13 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 7") SET (CMAKE_CXX_STACK_SIZE "10000000" CACHE STRING "Size of stack for programs.") MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES CMAKE_CXX_STACK_SIZE CMAKE_CXX_WARNING_LEVEL) -ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7") - -# does the compiler support pdbtype +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES "Visual Studio 8") +# does the compiler support pdbtype and is it the newer compiler SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) +SET(CMAKE_COMPILER_2005 0) +IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") + SET(CMAKE_COMPILER_2005 1) +ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") IF(CMAKE_GENERATOR MATCHES "NMake Makefiles") EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS /nologo -EP \"${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c\" @@ -84,10 +69,49 @@ IF(CMAKE_GENERATOR MATCHES "NMake Makefiles") IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" ) SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" ) + IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" ) + SET(CMAKE_COMPILER_2005 1) + ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" ) ENDIF(NOT CMAKE_COMPILER_RETURN) ENDIF(CMAKE_GENERATOR MATCHES "NMake Makefiles") +# default to Debug builds +IF(CMAKE_COMPILER_2005) + SET(CMAKE_BUILD_TYPE_INIT Debug) + SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /EHsc /GR") + SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /RTC1") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") + SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000") + SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") + SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") +ELSE(CMAKE_COMPILER_2005) + SET(CMAKE_BUILD_TYPE_INIT Debug) + SET (CMAKE_CXX_FLAGS_INIT "/W3 /Zm1000 /GX /GR") + SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") + SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") + SET (CMAKE_C_FLAGS_INIT "/W3 /Zm1000") + SET (CMAKE_C_FLAGS_DEBUG_INIT "/MDd /Zi /Od /GZ") + SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /D NDEBUG") + SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /D NDEBUG") + SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") +ENDIF(CMAKE_COMPILER_2005) + + +MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES) + + + # executable linker flags SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") SET (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /machine:I386 /INCREMENTAL:YES") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 96422c628..4f59aed95 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -79,8 +79,11 @@ IF (WIN32) ) IF(NOT MINGW) SET(SRCS ${SRCS} + cmGlobalVisualStudio71Generator.h + cmGlobalVisualStudio8Generator.h cmGlobalVisualStudio7Generator.h cmLocalVisualStudio7Generator.h + cmGlobalVisualStudio8Generator.cxx cmGlobalVisualStudio71Generator.cxx cmGlobalVisualStudio7Generator.cxx cmLocalVisualStudio7Generator.cxx) diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index e3c00e8d2..c8b8612ce 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -322,26 +322,36 @@ BOOL CMakeSetupDialog::OnInitDialog() { // check for vs7 in registry then decide what default to use std::string mp; - mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]"; + mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path"; cmSystemTools::ExpandRegistryValues(mp); - if (mp != "/registry") + if(mp != "/registry") { - m_GeneratorChoiceString = "Visual Studio 7 .NET 2003"; + m_GeneratorChoiceString = "Visual Studio 8 2005"; } else { - mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]"; + mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]"; cmSystemTools::ExpandRegistryValues(mp); if (mp != "/registry") { - m_GeneratorChoiceString = "Visual Studio 7"; + m_GeneratorChoiceString = "Visual Studio 7 .NET 2003"; } else { - m_GeneratorChoiceString = "Visual Studio 6"; + mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]"; + cmSystemTools::ExpandRegistryValues(mp); + if (mp != "/registry") + { + m_GeneratorChoiceString = "Visual Studio 7"; + } + else + { + m_GeneratorChoiceString = "Visual Studio 6"; + } } } } + // try to load the cmake cache from disk this->LoadCacheFromDiskToGUI(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 14c78e816..907e11103 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -74,9 +74,22 @@ void cmGlobalGenerator::EnableLanguage(const char* lang, return; } std::string makeProgram = mf->GetDefinition("CMAKE_MAKE_PROGRAM"); + // if there are spaces in the make program use short path + // but do not short path the actual program name, as + // this can cause trouble with VSExpress if(makeProgram.find(' ') != makeProgram.npos) { + std::string dir; + std::string file; + cmSystemTools::SplitProgramPath(makeProgram.c_str(), + dir, file); + std::string saveFile = file; cmSystemTools::GetShortPath(makeProgram.c_str(), makeProgram); + cmSystemTools::SplitProgramPath(makeProgram.c_str(), + dir, file); + makeProgram = dir; + makeProgram += "/"; + makeProgram += saveFile; this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", makeProgram.c_str(), "make program", cmCacheManager::FILEPATH); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx new file mode 100644 index 000000000..4f20eb077 --- /dev/null +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -0,0 +1,54 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "windows.h" // this must be first to define GetCurrentDirectory +#include "cmGlobalVisualStudio8Generator.h" +#include "cmLocalVisualStudio7Generator.h" +#include "cmMakefile.h" +#include "cmake.h" + + + +cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() +{ + m_FindMakeProgramFile = "CMakeVS8FindMake.cmake"; +} + + + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; + lg->SetVersion8(); + lg->SetGlobalGenerator(this); + return lg; +} + + +// ouput standard header for dsw file +void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) +{ + fout << "Microsoft Visual Studio Solution File, Format Version 9.00\n"; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.name = this->GetName(); + entry.brief = "Generates Visual Studio .NET 2005 project files."; + entry.full = ""; +} diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h new file mode 100644 index 000000000..07a359aa5 --- /dev/null +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -0,0 +1,48 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmGlobalVisualStudio8Generator_h +#define cmGlobalVisualStudio8Generator_h + +#include "cmGlobalVisualStudio71Generator.h" + + +/** \class cmGlobalVisualStudio8Generator + * \brief Write a Unix makefiles. + * + * cmGlobalVisualStudio8Generator manages UNIX build process for a tree + */ +class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator +{ +public: + cmGlobalVisualStudio8Generator(); + static cmGlobalGenerator* New() { return new cmGlobalVisualStudio8Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio8Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 8 2005";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! Create a local generator appropriate to this Global Generator + virtual cmLocalGenerator *CreateLocalGenerator(); + +protected: + virtual void WriteSLNHeader(std::ostream& fout); +}; +#endif diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3ab48d38b..f62e22899 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -24,7 +24,7 @@ cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() { - m_Version71 = false; + m_Version = 7; } cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() @@ -1172,13 +1172,20 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, fout << "\n" << "