On Mon, Jul 20, 2015 at 9:33 AM, Brad King <brad.k...@kitware.com> wrote:
> That looks good to me. Please extend the patch to also do BINARY_DIR > for completeness and also to update the documentation to cover the new > properties. The Tests/RunCMake/get_property test should be updated > to cover both too. I've put both in and added the man pages - progress so far attached. Are there any other docs that list target properties, or are the rst files the canonical sources for property docs? For testing these properties, what would you suggest? They're intended to report local configure-time absolute paths, which can't be hard coded... is it enough to check them to make sure they're not empty or is there something more robust that could be devised?" Thanks, CY
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 1d27a64..ac893c2 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -114,6 +114,7 @@ Properties on Targets /prop_tgt/AUTOUIC_OPTIONS /prop_tgt/AUTORCC /prop_tgt/AUTORCC_OPTIONS + /prop_tgt/BINARY_DIR /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION /prop_tgt/BUNDLE @@ -244,6 +245,7 @@ Properties on Targets /prop_tgt/RUNTIME_OUTPUT_NAME_CONFIG /prop_tgt/RUNTIME_OUTPUT_NAME /prop_tgt/SKIP_BUILD_RPATH + /prop_tgt/SOURCE_DIR /prop_tgt/SOURCES /prop_tgt/SOVERSION /prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG diff --git a/Help/prop_tgt/BINARY_DIR.rst b/Help/prop_tgt/BINARY_DIR.rst new file mode 100644 index 0000000..a6c1c12 --- /dev/null +++ b/Help/prop_tgt/BINARY_DIR.rst @@ -0,0 +1,4 @@ +BINARY_DIR +---------- + +Reports the value of CMAKE_CURRENT_BINARY_DIR in the directory in which the target was defined. diff --git a/Help/prop_tgt/SOURCE_DIR.rst b/Help/prop_tgt/SOURCE_DIR.rst new file mode 100644 index 0000000..de93f29 --- /dev/null +++ b/Help/prop_tgt/SOURCE_DIR.rst @@ -0,0 +1,4 @@ +SOURCE_DIR +---------- + +Reports the value of CMAKE_CURRENT_SOURCE_DIR in the directory in which the target was defined. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0303f1e..ff4f161 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2959,6 +2959,8 @@ const char *cmTarget::GetProperty(const std::string& prop, MAKE_STATIC_PROP(COMPILE_DEFINITIONS); MAKE_STATIC_PROP(IMPORTED); MAKE_STATIC_PROP(NAME); + MAKE_STATIC_PROP(BINARY_DIR); + MAKE_STATIC_PROP(SOURCE_DIR); MAKE_STATIC_PROP(SOURCES); #undef MAKE_STATIC_PROP if(specialProps.empty()) @@ -2971,6 +2973,8 @@ const char *cmTarget::GetProperty(const std::string& prop, specialProps.insert(propCOMPILE_DEFINITIONS); specialProps.insert(propIMPORTED); specialProps.insert(propNAME); + specialProps.insert(propBINARY_DIR); + specialProps.insert(propSOURCE_DIR); specialProps.insert(propSOURCES); } if(specialProps.count(prop)) @@ -3053,6 +3057,14 @@ const char *cmTarget::GetProperty(const std::string& prop, { return this->GetName().c_str(); } + else if (prop == propBINARY_DIR) + { + return this->GetMakefile()->GetCurrentBinaryDirectory(); + } + else if (prop == propSOURCE_DIR) + { + return this->GetMakefile()->GetCurrentSourceDirectory(); + } else if(prop == propSOURCES) { if (this->Internal->SourceEntries.empty())
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers