Add directory property to list buildsystem targets
Add a BUILDSYSTEM_TARGETS property to allow project code to traverse the list of its own targets in a given directory.
This commit is contained in:
parent
7a4b8d0dc2
commit
cbca65826c
|
@ -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/BUILDSYSTEM_TARGETS
|
||||||
/prop_dir/CACHE_VARIABLES
|
/prop_dir/CACHE_VARIABLES
|
||||||
/prop_dir/CLEAN_NO_CUSTOM
|
/prop_dir/CLEAN_NO_CUSTOM
|
||||||
/prop_dir/CMAKE_CONFIGURE_DEPENDS
|
/prop_dir/CMAKE_CONFIGURE_DEPENDS
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
BUILDSYSTEM_TARGETS
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
This read-only directory property contains a
|
||||||
|
:ref:`;-list <CMake Language Lists>` of buildsystem targets added in the
|
||||||
|
directory by calls to the :command:`add_library`, :command:`add_executable`,
|
||||||
|
and :command:`add_custom_target` commands. The list does not include any
|
||||||
|
:ref:`Imported Targets` or :ref:`Alias Targets`, but does include
|
||||||
|
:ref:`Interface Libraries`. Each entry in the list is the logical name
|
||||||
|
of a target, suitable to pass to the :command:`get_property` command
|
||||||
|
``TARGET`` option.
|
|
@ -1,5 +1,9 @@
|
||||||
directory-list-targets-and-subdirs
|
directory-list-targets-and-subdirs
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
* A :prop_dir:`BUILDSYSTEM_TARGETS` directory property was added to
|
||||||
|
get the list of logical buildsystem target names added by the
|
||||||
|
project in a directory.
|
||||||
|
|
||||||
* A :prop_dir:`SUBDIRECTORIES` directory property was added to
|
* A :prop_dir:`SUBDIRECTORIES` directory property was added to
|
||||||
get the list of subdirectories added by a project in a directory.
|
get the list of subdirectories added by a project in a directory.
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS";
|
||||||
static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES";
|
static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES";
|
||||||
|
|
||||||
struct cmState::SnapshotDataType
|
struct cmState::SnapshotDataType
|
||||||
|
@ -1683,6 +1684,10 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
|
||||||
output = cmJoin(child_dirs, ";");
|
output = cmJoin(child_dirs, ";");
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
|
if (prop == kBUILDSYSTEM_TARGETS) {
|
||||||
|
output = cmJoin(this->DirectoryState->NormalTargetNames, ";");
|
||||||
|
return output.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
if (prop == "LISTFILE_STACK") {
|
if (prop == "LISTFILE_STACK") {
|
||||||
std::vector<std::string> listFiles;
|
std::vector<std::string> listFiles;
|
||||||
|
|
|
@ -7,4 +7,8 @@ get_property: --><--
|
||||||
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
||||||
get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties<--
|
||||||
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<--
|
get_directory_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<--
|
||||||
get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<--$
|
get_property: -->[^<;]*Tests/RunCMake/get_property/directory_properties/sub1;[^<;]*Tests/RunCMake/get_property/directory_properties/sub2<--
|
||||||
|
get_directory_property: -->CustomTop;InterfaceTop<--
|
||||||
|
get_property: -->CustomTop;InterfaceTop<--
|
||||||
|
get_directory_property: -->CustomSub;InterfaceSub<--
|
||||||
|
get_property: -->CustomSub;InterfaceSub<--$
|
||||||
|
|
|
@ -14,6 +14,12 @@ check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" empty)
|
||||||
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" custom)
|
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" custom)
|
||||||
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" noexist)
|
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" noexist)
|
||||||
|
|
||||||
|
add_custom_target(CustomTop)
|
||||||
|
add_library(InterfaceTop INTERFACE)
|
||||||
|
add_library(my::InterfaceTop ALIAS InterfaceTop)
|
||||||
|
|
||||||
add_subdirectory(directory_properties)
|
add_subdirectory(directory_properties)
|
||||||
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SUBDIRECTORIES)
|
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}/directory_properties" BUILDSYSTEM_TARGETS)
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
add_subdirectory(sub1)
|
add_subdirectory(sub1)
|
||||||
subdirs(sub2)
|
subdirs(sub2)
|
||||||
|
|
||||||
|
add_custom_target(CustomSub)
|
||||||
|
add_library(InterfaceSub INTERFACE)
|
||||||
|
add_library(my::InterfaceSub ALIAS InterfaceSub)
|
||||||
|
|
Loading…
Reference in New Issue