diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-14 17:27:14 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-17 14:44:29 (GMT) |
commit | 4568d046c46a7357ab48ddfb1117bad39e65572c (patch) | |
tree | 851a7fbee311593712dfff42fdcf9070a2187427 /Source/cmakemain.cxx | |
parent | c59eae7ebc5423c2b06befd762f8639b0f23b7a0 (diff) | |
download | CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.zip CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.gz CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.bz2 |
Properties: Add CMAKE_ROLE global property
This property allows scripts to determine whether they're in project
mode, script mode, find-package mode, CTest, or CPack.
Diffstat (limited to 'Source/cmakemain.cxx')
-rw-r--r-- | Source/cmakemain.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e52f2b3..84d1414 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -217,7 +217,7 @@ int do_cmake(int ac, char const* const* av) doc.addCMakeStandardDocSections(); if (doc.CheckOptions(ac, av)) { // Construct and print requested documentation. - cmake hcm(cmake::RoleInternal); + cmake hcm(cmake::RoleInternal, cmState::Unknown); hcm.SetHomeDirectory(""); hcm.SetHomeOutputDirectory(""); hcm.AddCMakePaths(); @@ -299,7 +299,7 @@ int do_cmake(int ac, char const* const* av) } } if (sysinfo) { - cmake cm(cmake::RoleProject); + cmake cm(cmake::RoleProject, cmState::Project); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); int ret = cm.GetSystemInformation(args); @@ -307,7 +307,19 @@ int do_cmake(int ac, char const* const* av) } cmake::Role const role = workingMode == cmake::SCRIPT_MODE ? cmake::RoleScript : cmake::RoleProject; - cmake cm(role); + cmState::Mode mode = cmState::Unknown; + switch (workingMode) { + case cmake::NORMAL_MODE: + mode = cmState::Project; + break; + case cmake::SCRIPT_MODE: + mode = cmState::Script; + break; + case cmake::FIND_PACKAGE_MODE: + mode = cmState::FindPackage; + break; + } + cmake cm(role, mode); cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); @@ -463,7 +475,7 @@ static int do_build(int ac, char const* const* av) return 1; } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); cm.SetProgressCallback(cmakemainProgressCallback, &cm); return cm.Build(jobs, dir, target, config, nativeOptions, clean); @@ -501,7 +513,7 @@ static int do_open(int ac, char const* const* av) return 1; } - cmake cm(cmake::RoleInternal); + cmake cm(cmake::RoleInternal, cmState::Unknown); cmSystemTools::SetMessageCallback(cmakemainMessageCallback, &cm); cm.SetProgressCallback(cmakemainProgressCallback, &cm); return cm.Open(dir, false) ? 0 : 1; |