summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CMakeGenericSystem.cmake23
-rw-r--r--Source/cmLocalGenerator.cxx22
2 files changed, 39 insertions, 6 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 167f148..004a98a 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -23,16 +23,27 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX)
SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL
"If set, runtime paths are not added when using shared libraries.")
-SET (CMAKE_INSTALL_PREFIX /usr/local CACHE PATH
- "Install path prefix, prepended onto install directories.")
+
+# Choose a default install prefix for this platform.
+IF(UNIX)
+ SET(CMAKE_INSTALL_PREFIX "/usr/local"
+ CACHE PATH "Install path prefix, prepended onto install directories.")
+ELSE(UNIX)
+ IF("$ENV{SystemDrive}" MATCHES "^$")
+ SET(CMAKE_GENERIC_SYSTEM_DRIVE "C:")
+ ELSE("$ENV{SystemDrive}" MATCHES "^$")
+ SET(CMAKE_GENERIC_SYSTEM_DRIVE "$ENV{SystemDrive}")
+ ENDIF("$ENV{SystemDrive}" MATCHES "^$")
+ SET(CMAKE_INSTALL_PREFIX
+ "${CMAKE_GENERIC_SYSTEM_DRIVE}/Program Files/${PROJECT_NAME}"
+ CACHE PATH "Install path prefix, prepended onto install directories.")
+ SET(CMAKE_GENERIC_SYSTEM_DRIVE)
+ MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
+ENDIF(UNIX)
MARK_AS_ADVANCED(
CMAKE_SKIP_RPATH
)
-IF(NOT UNIX)
- MARK_AS_ADVANCED(CMAKE_INSTALL_PREFIX)
-ENDIF(NOT UNIX)
-
# always include the gcc compiler information
INCLUDE(Platform/gcc)
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 2faf647..0943c0c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -75,10 +75,32 @@ void cmLocalGenerator::GenerateInstallRules()
const cmTargets &tgts = m_Makefile->GetTargets();
const char* prefix
= m_Makefile->GetDefinition("CMAKE_INSTALL_PREFIX");
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ std::string prefix_win32;
+ if(!prefix)
+ {
+ if(!cmSystemTools::GetEnv("SystemDrive", prefix_win32))
+ {
+ prefix_win32 = "C:";
+ }
+ const char* project_name = m_Makefile->GetDefinition("PROJECT_NAME");
+ if(project_name && project_name[0])
+ {
+ prefix_win32 += "/Program Files/";
+ prefix_win32 += project_name;
+ }
+ else
+ {
+ prefix_win32 += "/InstalledCMakeProject";
+ }
+ prefix = prefix_win32.c_str();
+ }
+#else
if (!prefix)
{
prefix = "/usr/local";
}
+#endif
std::string file = m_Makefile->GetStartOutputDirectory();
std::string homedir = m_Makefile->GetHomeOutputDirectory();