diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-10-13 19:48:46 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-10-13 22:16:20 (GMT) |
commit | 20b95ef8c83fbcb7705e72c85c9de18ff420562f (patch) | |
tree | 7241038f255ebe43bd6fefd8e2efd7533ae3167d /Source/cmState.cxx | |
parent | 841164cb36650574a1a7363c78e4cdf28d5d37fd (diff) | |
download | CMake-20b95ef8c83fbcb7705e72c85c9de18ff420562f.zip CMake-20b95ef8c83fbcb7705e72c85c9de18ff420562f.tar.gz CMake-20b95ef8c83fbcb7705e72c85c9de18ff420562f.tar.bz2 |
cmState: Initialize default definitions immediately.
Don't leave this as cmMakefile responsibility.
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index e3f62b5..364b75e 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -12,6 +12,7 @@ #include "cmState.h" #include "cmake.h" +#include "cmVersion.h" #include "cmCacheManager.h" #include "cmCommand.h" #include "cmAlgorithms.h" @@ -847,6 +848,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, cmState::Snapshot snapshot = cmState::Snapshot(this, pos); originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); + snapshot.SetDefaultDefinitions(); snapshot.InitializeFromParent(); snapshot.SetDirectoryDefinitions(); return snapshot; @@ -1333,6 +1335,54 @@ void InitializeContentFromParent(T& parentContent, contentEndPosition = thisContent.size(); } +void cmState::Snapshot::SetDefaultDefinitions() +{ + /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. + With CMake must separate between target and host platform. In most cases + the tests for WIN32, UNIX and APPLE will be for the target system, so an + additional set of variables for the host system is required -> + CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. + WIN32, UNIX and APPLE are now set in the platform files in + Modules/Platforms/. + To keep cmake scripts (-P) and custom language and compiler modules + working, these variables are still also set here in this place, but they + will be reset in CMakeSystemSpecificInformation.cmake before the platform + files are executed. */ + #if defined(_WIN32) + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + #else + this->SetDefinition("UNIX", "1"); + this->SetDefinition("CMAKE_HOST_UNIX", "1"); + #endif + #if defined(__CYGWIN__) + if(cmSystemTools::IsOn(cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32"))) + { + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + } + #endif + #if defined(__APPLE__) + this->SetDefinition("APPLE", "1"); + this->SetDefinition("CMAKE_HOST_APPLE", "1"); + #endif + + char temp[1024]; + sprintf(temp, "%d", cmVersion::GetMinorVersion()); + this->SetDefinition("CMAKE_MINOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetMajorVersion()); + this->SetDefinition("CMAKE_MAJOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetPatchVersion()); + this->SetDefinition("CMAKE_PATCH_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetTweakVersion()); + this->SetDefinition("CMAKE_TWEAK_VERSION", temp); + this->SetDefinition("CMAKE_VERSION", + cmVersion::GetCMakeVersion()); + + this->SetDefinition("CMAKE_FILES_DIRECTORY", + cmake::GetCMakeFilesDirectory()); +} + void cmState::Snapshot::SetDirectoryDefinitions() { this->SetDefinition("CMAKE_SOURCE_DIR", |