mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 04:31:04 -06:00
@@ -236,6 +236,7 @@ Properties on Targets
|
||||
/prop_tgt/MACOSX_BUNDLE
|
||||
/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST
|
||||
/prop_tgt/MACOSX_RPATH
|
||||
/prop_tgt/MANUALLY_ADDED_DEPENDENCIES
|
||||
/prop_tgt/MAP_IMPORTED_CONFIG_CONFIG
|
||||
/prop_tgt/NAME
|
||||
/prop_tgt/NO_SONAME
|
||||
|
||||
8
Help/prop_tgt/MANUALLY_ADDED_DEPENDENCIES.rst
Normal file
8
Help/prop_tgt/MANUALLY_ADDED_DEPENDENCIES.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
MANUALLY_ADDED_DEPENDENCIES
|
||||
---------------------------
|
||||
|
||||
Get manually added dependencies to other top-level targets.
|
||||
|
||||
This read-only property can be used to query all dependencies that
|
||||
were added for this target with the :command:`add_dependencies`
|
||||
command.
|
||||
6
Help/release/dev/manually-added-dependencies.rst
Normal file
6
Help/release/dev/manually-added-dependencies.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
manually-added-dependencies
|
||||
---------------------------
|
||||
|
||||
* The target property :prop_tgt:`MANUALLY_ADDED_DEPENDENCIES` has
|
||||
been added. It is read-only and could be used to retrieve
|
||||
dependencies that have been added with :command:`add_dependencies`.
|
||||
@@ -852,6 +852,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
|
||||
this->Makefile->GetBacktrace())) {
|
||||
return;
|
||||
}
|
||||
if (prop == "MANUALLY_ADDED_DEPENDENCIES") {
|
||||
std::ostringstream e;
|
||||
e << "MANUALLY_ADDED_DEPENDENCIES property is read-only\n";
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
return;
|
||||
}
|
||||
if (prop == "NAME") {
|
||||
std::ostringstream e;
|
||||
e << "NAME property is read-only\n";
|
||||
@@ -1168,6 +1174,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const
|
||||
MAKE_STATIC_PROP(COMPILE_OPTIONS);
|
||||
MAKE_STATIC_PROP(COMPILE_DEFINITIONS);
|
||||
MAKE_STATIC_PROP(IMPORTED);
|
||||
MAKE_STATIC_PROP(MANUALLY_ADDED_DEPENDENCIES);
|
||||
MAKE_STATIC_PROP(NAME);
|
||||
MAKE_STATIC_PROP(BINARY_DIR);
|
||||
MAKE_STATIC_PROP(SOURCE_DIR);
|
||||
@@ -1181,6 +1188,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const
|
||||
specialProps.insert(propCOMPILE_OPTIONS);
|
||||
specialProps.insert(propCOMPILE_DEFINITIONS);
|
||||
specialProps.insert(propIMPORTED);
|
||||
specialProps.insert(propMANUALLY_ADDED_DEPENDENCIES);
|
||||
specialProps.insert(propNAME);
|
||||
specialProps.insert(propBINARY_DIR);
|
||||
specialProps.insert(propSOURCE_DIR);
|
||||
@@ -1236,6 +1244,15 @@ const char* cmTarget::GetProperty(const std::string& prop) const
|
||||
output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
|
||||
return output.c_str();
|
||||
}
|
||||
if (prop == propMANUALLY_ADDED_DEPENDENCIES) {
|
||||
if (this->Utilities.empty()) {
|
||||
return CM_NULLPTR;
|
||||
}
|
||||
|
||||
static std::string output;
|
||||
output = cmJoin(this->Utilities, ";");
|
||||
return output.c_str();
|
||||
}
|
||||
if (prop == propIMPORTED) {
|
||||
return this->IsImported() ? "TRUE" : "FALSE";
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1 @@
|
||||
MANUALLY_ADDED_DEPENDENCIES property is read-only
|
||||
6
Tests/RunCMake/add_dependencies/ReadOnlyProperty.cmake
Normal file
6
Tests/RunCMake/add_dependencies/ReadOnlyProperty.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(ReadOnlyProperty C)
|
||||
|
||||
add_library(a a.c)
|
||||
|
||||
set_property(TARGET a PROPERTY MANUALLY_ADDED_DEPENDENCIES DEPENDENCIES foo)
|
||||
16
Tests/RunCMake/add_dependencies/RetrieveDependencies.cmake
Normal file
16
Tests/RunCMake/add_dependencies/RetrieveDependencies.cmake
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(RetrieveDependencies C)
|
||||
|
||||
add_library(a a.c)
|
||||
|
||||
add_library(b c.c)
|
||||
target_link_libraries(a b)
|
||||
|
||||
add_library(c c.c)
|
||||
add_dependencies(a c)
|
||||
|
||||
get_property(DEPS_A TARGET a PROPERTY MANUALLY_ADDED_DEPENDENCIES)
|
||||
|
||||
if(NOT DEPS_A STREQUAL "c")
|
||||
message(FATAL_ERROR "Expected target c being a dependency of a but got: '${DEPS_A}'")
|
||||
endif()
|
||||
@@ -1,3 +1,5 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(NoTarget)
|
||||
run_cmake(ReadOnlyProperty)
|
||||
run_cmake(RetrieveDependencies)
|
||||
|
||||
3
Tests/RunCMake/add_dependencies/a.c
Normal file
3
Tests/RunCMake/add_dependencies/a.c
Normal file
@@ -0,0 +1,3 @@
|
||||
void a()
|
||||
{
|
||||
}
|
||||
3
Tests/RunCMake/add_dependencies/b.c
Normal file
3
Tests/RunCMake/add_dependencies/b.c
Normal file
@@ -0,0 +1,3 @@
|
||||
void b()
|
||||
{
|
||||
}
|
||||
3
Tests/RunCMake/add_dependencies/c.c
Normal file
3
Tests/RunCMake/add_dependencies/c.c
Normal file
@@ -0,0 +1,3 @@
|
||||
void c()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user