Add directory properties to get source and binary directories

Add SOURCE_DIR and BINARY_DIR directory properties that return the
absolute paths to the corresponding directories.  These correspond
to the target properties of the same names that we already have.
This commit is contained in:
Brad King 2016-09-19 13:47:51 -04:00
parent cbca65826c
commit d0be1e15c3
7 changed files with 43 additions and 1 deletions

View File

@ -54,6 +54,7 @@ Properties on Directories
:maxdepth: 1 :maxdepth: 1
/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES
/prop_dir/BINARY_DIR
/prop_dir/BUILDSYSTEM_TARGETS /prop_dir/BUILDSYSTEM_TARGETS
/prop_dir/CACHE_VARIABLES /prop_dir/CACHE_VARIABLES
/prop_dir/CLEAN_NO_CUSTOM /prop_dir/CLEAN_NO_CUSTOM
@ -74,6 +75,7 @@ Properties on Directories
/prop_dir/RULE_LAUNCH_COMPILE /prop_dir/RULE_LAUNCH_COMPILE
/prop_dir/RULE_LAUNCH_CUSTOM /prop_dir/RULE_LAUNCH_CUSTOM
/prop_dir/RULE_LAUNCH_LINK /prop_dir/RULE_LAUNCH_LINK
/prop_dir/SOURCE_DIR
/prop_dir/SUBDIRECTORIES /prop_dir/SUBDIRECTORIES
/prop_dir/TEST_INCLUDE_FILE /prop_dir/TEST_INCLUDE_FILE
/prop_dir/VARIABLES /prop_dir/VARIABLES

View File

@ -0,0 +1,5 @@
BINARY_DIR
----------
This read-only directory property reports absolute path to the binary
directory corresponding to the source on which it is read.

View File

@ -0,0 +1,5 @@
SOURCE_DIR
----------
This read-only directory property reports absolute path to the source
directory on which it is read.

View File

@ -1,6 +1,13 @@
directory-list-targets-and-subdirs directory-list-targets-and-subdirs
---------------------------------- ----------------------------------
* A :prop_dir:`SOURCE_DIR` directory property was added to get the
absolute path to the source directory associated with a directory.
* A :prop_dir:`BINARY_DIR` directory property was added to get the
absolute path to the binary directory corresponding to the source
directory on which the property is read.
* A :prop_dir:`BUILDSYSTEM_TARGETS` directory property was added to * A :prop_dir:`BUILDSYSTEM_TARGETS` directory property was added to
get the list of logical buildsystem target names added by the get the list of logical buildsystem target names added by the
project in a directory. project in a directory.

View File

@ -29,7 +29,9 @@
#include <string.h> #include <string.h>
#include <utility> #include <utility>
static std::string const kBINARY_DIR = "BINARY_DIR";
static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS"; static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS";
static std::string const kSOURCE_DIR = "SOURCE_DIR";
static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES"; static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES";
struct cmState::SnapshotDataType struct cmState::SnapshotDataType
@ -1673,6 +1675,14 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
} }
return ""; return "";
} }
if (prop == kBINARY_DIR) {
output = this->GetCurrentBinary();
return output.c_str();
}
if (prop == kSOURCE_DIR) {
output = this->GetCurrentSource();
return output.c_str();
}
if (prop == kSUBDIRECTORIES) { if (prop == kSUBDIRECTORIES) {
std::vector<std::string> child_dirs; std::vector<std::string> child_dirs;
std::vector<cmState::Snapshot> const& children = std::vector<cmState::Snapshot> const& children =

View File

@ -11,4 +11,12 @@ get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<
get_directory_property: -->CustomTop;InterfaceTop<-- get_directory_property: -->CustomTop;InterfaceTop<--
get_property: -->CustomTop;InterfaceTop<-- get_property: -->CustomTop;InterfaceTop<--
get_directory_property: -->CustomSub;InterfaceSub<-- get_directory_property: -->CustomSub;InterfaceSub<--
get_property: -->CustomSub;InterfaceSub<--$ get_property: -->CustomSub;InterfaceSub<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build<--
get_directory_property: -->[^<;]*/RunCMake/get_property<--
get_property: -->[^<;]*/Tests/RunCMake/get_property<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--$

View File

@ -23,3 +23,8 @@ check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SUBDIRECTORIES)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SUBDIRECTORIES) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SUBDIRECTORIES)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BUILDSYSTEM_TARGETS) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BUILDSYSTEM_TARGETS)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BUILDSYSTEM_TARGETS) check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BUILDSYSTEM_TARGETS)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SOURCE_DIR)