From 802a28fc5e19136b947b2f7d136de31c1d10b578 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Dec 2013 16:09:46 +0100 Subject: Add cmHasLiteralSuffix API. --- Source/cmFindPackageCommand.cxx | 4 ++-- Source/cmStandardIncludes.h | 25 +++++++++++++++++++++++++ Source/cmSystemTools.cxx | 13 +++---------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 55c20d6..12bb807 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1151,8 +1151,8 @@ void cmFindPackageCommand::AddPrefixesSystemEnvironment() std::string const& d = *i; // If the path is a PREFIX/bin case then add its parent instead. - if((d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0) || - (d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)) + if((cmHasLiteralSuffix(d, "/bin")) || + (cmHasLiteralSuffix(d, "/sbin"))) { this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath); } diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index eb6e52f..ebfa8f9 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -391,6 +391,22 @@ inline bool cmHasLiteralPrefixImpl(const char* str1, return strncmp(str1, str2, N) == 0; } +inline bool cmHasLiteralSuffixImpl(const std::string &str1, + const char *str2, + size_t N) +{ + size_t len = str1.size(); + return len >= N && strcmp(str1.c_str() + len - N, str2) == 0; +} + +inline bool cmHasLiteralSuffixImpl(const char* str1, + const char* str2, + size_t N) +{ + size_t len = strlen(str1); + return len >= N && strcmp(str1 + len - N, str2) == 0; +} + #if defined(_MSC_VER) && _MSC_VER < 1300 \ || defined(__GNUC__) && __GNUC__ < 3 \ || defined(__BORLANDC__) @@ -402,6 +418,9 @@ inline bool cmHasLiteralPrefixImpl(const char* str1, #define cmHasLiteralPrefix(STR1, STR2) \ cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) +#define cmHasLiteralSuffix(STR1, STR2) \ + cmHasLiteralSuffixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) + #else template @@ -417,6 +436,12 @@ bool cmHasLiteralPrefix(T str1, const char (&str2)[N]) return cmHasLiteralPrefixImpl(str1, str2, N - 1); } +template +bool cmHasLiteralSuffix(T str1, const char (&str2)[N]) +{ + return cmHasLiteralSuffixImpl(str1, str2, N - 1); +} + #endif struct cmStrCmp { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b8163c8..1de2358 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -359,18 +359,11 @@ bool cmSystemTools::IsOn(const char* val) bool cmSystemTools::IsNOTFOUND(const char* val) { - size_t len = strlen(val); - const char* notfound = "-NOTFOUND"; - const size_t lenNotFound = 9; - if(len < lenNotFound-1) + if(strcmp(val, "NOTFOUND") == 0) { - return false; - } - if(len == lenNotFound-1) - { - return ( strcmp(val, "NOTFOUND") == 0); + return true; } - return ((strncmp((val + (len - lenNotFound)), notfound, lenNotFound) == 0)); + return cmHasLiteralSuffix(val, "-NOTFOUND"); } -- cgit v0.12 From 711fb38f726fe3ef1209c81ae7b3220c5ca1512b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 5 Jan 2014 05:13:39 +0100 Subject: Genex: List transitive properties and methods as a table, not two lists. Introduce a new set of macros to select the column. --- Source/cmGeneratorExpressionDAGChecker.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 98ffd36..812e985 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -16,19 +16,21 @@ #include "cmGeneratorExpressionEvaluator.h" +#define CM_SELECT_FIRST(F, A1, A2) F(A1) +#define CM_SELECT_SECOND(F, A1, A2) F(A2) + +#define CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, SELECT) \ + SELECT(F, EvaluatingIncludeDirectories, INCLUDE_DIRECTORIES) \ + SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \ + SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS) \ + SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ + SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) + #define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ - F(EvaluatingIncludeDirectories) \ - F(EvaluatingSystemIncludeDirectories) \ - F(EvaluatingCompileDefinitions) \ - F(EvaluatingCompileOptions) \ - F(EvaluatingAutoUicOptions) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ - F(INCLUDE_DIRECTORIES) \ - F(SYSTEM_INCLUDE_DIRECTORIES) \ - F(COMPILE_DEFINITIONS) \ - F(COMPILE_OPTIONS) \ - F(AUTOUIC_OPTIONS) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_SECOND) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker -- cgit v0.12 From 646c6ec2f975238c11e2be02912fae0872843772 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 5 Jan 2014 12:40:38 +0100 Subject: Genex: Use a preprocessor loop to implement transitive DAG check. The other infrastructure for transitive property handling is already using a preprocessor loop. Implement special backward-compatibility handling of COMPILE_DEFINITIONS_ using a template switch for the extra check. --- Source/cmGeneratorExpressionDAGChecker.cxx | 57 +++++++++++++----------------- Source/cmGeneratorExpressionDAGChecker.h | 4 +++ 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index c2c4e20..3e97163 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -179,44 +179,37 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() const +enum TransitiveProperty { +#define DEFINE_ENUM_ENTRY(NAME) NAME, + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY) +#undef DEFINE_ENUM_ENTRY + TransitivePropertyTerminal +}; + +template +bool additionalTest(const char* const) { - const char *prop = this->Property.c_str(); - return (strcmp(prop, "INCLUDE_DIRECTORIES") == 0 - || strcmp(prop, "INTERFACE_INCLUDE_DIRECTORIES") == 0 ); + return false; } -//---------------------------------------------------------------------------- -bool -cmGeneratorExpressionDAGChecker::EvaluatingSystemIncludeDirectories() const +template<> +bool additionalTest(const char* const prop) { - const char *prop = this->Property.c_str(); - return (strcmp(prop, "SYSTEM_INCLUDE_DIRECTORIES") == 0 - || strcmp(prop, "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") == 0); + return cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_"); } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 - || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 - || cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_")); +#define DEFINE_TRANSITIVE_PROPERTY_METHOD(METHOD, PROPERTY) \ +bool cmGeneratorExpressionDAGChecker::METHOD() const \ +{ \ + const char* const prop = this->Property.c_str(); \ + if (strcmp(prop, #PROPERTY) == 0 \ + || strcmp(prop, "INTERFACE_" #PROPERTY) == 0) \ + { \ + return true; \ + } \ + return additionalTest(prop); \ } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "COMPILE_OPTIONS") == 0 - || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 ); -} +CM_FOR_EACH_TRANSITIVE_PROPERTY(DEFINE_TRANSITIVE_PROPERTY_METHOD) -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingAutoUicOptions() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "AUTOUIC_OPTIONS") == 0 - || strcmp(prop, "INTERFACE_AUTOUIC_OPTIONS") == 0 ); -} +#undef DEFINE_TRANSITIVE_PROPERTY_METHOD diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 812e985..1636492 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -16,6 +16,7 @@ #include "cmGeneratorExpressionEvaluator.h" +#define CM_SELECT_BOTH(F, A1, A2) F(A1, A2) #define CM_SELECT_FIRST(F, A1, A2) F(A1) #define CM_SELECT_SECOND(F, A1, A2) F(A2) @@ -26,6 +27,9 @@ SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) +#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \ + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH) + #define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST) -- cgit v0.12 From 6eb32181052e2262fd2b8ed1d6fa19e279d7ae5e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 5 Jan 2014 05:25:09 +0100 Subject: Genex: Fix case of methods in the dag checker. --- Source/cmGeneratorExpressionDAGChecker.cxx | 8 ++++---- Source/cmGeneratorExpressionDAGChecker.h | 6 +++--- Source/cmGeneratorExpressionEvaluator.cxx | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 3e97163..e7e1d34 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -31,7 +31,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( top = p; p = p->Parent; } - this->CheckResult = this->checkGraph(); + this->CheckResult = this->CheckGraph(); #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) \ top->METHOD () || @@ -61,13 +61,13 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( //---------------------------------------------------------------------------- cmGeneratorExpressionDAGChecker::Result -cmGeneratorExpressionDAGChecker::check() const +cmGeneratorExpressionDAGChecker::Check() const { return this->CheckResult; } //---------------------------------------------------------------------------- -void cmGeneratorExpressionDAGChecker::reportError( +void cmGeneratorExpressionDAGChecker::ReportError( cmGeneratorExpressionContext *context, const std::string &expr) { @@ -125,7 +125,7 @@ void cmGeneratorExpressionDAGChecker::reportError( //---------------------------------------------------------------------------- cmGeneratorExpressionDAGChecker::Result -cmGeneratorExpressionDAGChecker::checkGraph() const +cmGeneratorExpressionDAGChecker::CheckGraph() const { const cmGeneratorExpressionDAGChecker *parent = this->Parent; while (parent) diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 1636492..b6effa1 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -52,9 +52,9 @@ struct cmGeneratorExpressionDAGChecker ALREADY_SEEN }; - Result check() const; + Result Check() const; - void reportError(cmGeneratorExpressionContext *context, + void ReportError(cmGeneratorExpressionContext *context, const std::string &expr); bool EvaluatingLinkLibraries(const char *tgt = 0); @@ -71,7 +71,7 @@ struct cmGeneratorExpressionDAGChecker { this->TransitivePropertiesOnly = true; } private: - Result checkGraph() const; + Result CheckGraph() const; private: const cmGeneratorExpressionDAGChecker * const Parent; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index f0e40ea..fec43b9 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -957,10 +957,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode content, dagCheckerParent); - switch (dagChecker.check()) + switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: - dagChecker.reportError(context, content->GetOriginalExpression()); + dagChecker.ReportError(context, content->GetOriginalExpression()); return std::string(); case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: // No error. We just skip cyclic references. -- cgit v0.12 From 9c9f69fb9c0c1ab1f62de646cffe48485bd893af Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 4 Jan 2014 19:38:23 +0100 Subject: Genex: Make EQUAL support upper case binary literals As C++11, python, D and java do. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf Add test for uppercase hex literals. --- Source/cmGeneratorExpressionEvaluator.cxx | 12 ++++++------ Tests/GeneratorExpression/CMakeLists.txt | 16 +++++++++------- Tests/GeneratorExpression/check-part3.cmake | 6 ++++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index fec43b9..259ba94 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -215,18 +215,18 @@ static const struct EqualNode : public cmGeneratorExpressionNode bool flipSign = false; const char *lhs = parameters[0].c_str(); - if (cmHasLiteralPrefix(lhs, "0b")) + if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) { base = 2; lhs += 2; } - if (cmHasLiteralPrefix(lhs, "-0b")) + if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) { base = 2; lhs += 3; flipSign = true; } - if (cmHasLiteralPrefix(lhs, "+0b")) + if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) { base = 2; lhs += 3; @@ -249,18 +249,18 @@ static const struct EqualNode : public cmGeneratorExpressionNode flipSign = false; const char *rhs = parameters[1].c_str(); - if (cmHasLiteralPrefix(rhs, "0b")) + if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) { base = 2; rhs += 2; } - if (cmHasLiteralPrefix(rhs, "-0b")) + if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) { base = 2; rhs += 3; flipSign = true; } - if (cmHasLiteralPrefix(rhs, "+0b")) + if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) { base = 2; rhs += 3; diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 4fb7ecd..9512efc 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -199,7 +199,7 @@ add_custom_target(check-part3 ALL -Dequal1=$ -Dequal2=$ -Dequal3=$ - -Dequal4=$ + -Dequal4=$ -Dequal5=$ -Dequal6=$ -Dequal7=$ @@ -208,15 +208,17 @@ add_custom_target(check-part3 ALL -Dequal10=$ -Dequal11=$ -Dequal12=$ - -Dequal13=$ + -Dequal13=$ -Dequal14=$ - -Dequal15=$ + -Dequal15=$ -Dequal16=$ -Dequal17=$ - -Dequal18=$ - -Dequal19=$ - -Dequal20=$ - -Dequal21=$ + -Dequal18=$ + -Dequal19=$ + -Dequal20=$ + -Dequal21=$ + -Dequal22=$ + -Dequal23=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 2c6bf49..70ccfe1 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -55,6 +55,8 @@ check(equal15 "1") check(equal16 "1") check(equal17 "0") check(equal18 "1") -check(equal19 "1") -check(equal20 "0") +check(equal19 "0") +check(equal20 "1") check(equal21 "1") +check(equal22 "0") +check(equal23 "1") -- cgit v0.12 From b7deca4a54991c4c596cbd7ee209988785bfcd44 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jan 2014 16:15:23 +0100 Subject: Test: Remove obsolete commented code. This should not have survived in commit a247911a (Tests: Don't read the LOCATION property from build targets., 2013-11-18). --- Tests/LinkDirectory/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/LinkDirectory/CMakeLists.txt b/Tests/LinkDirectory/CMakeLists.txt index b8d5a04..c60de84 100644 --- a/Tests/LinkDirectory/CMakeLists.txt +++ b/Tests/LinkDirectory/CMakeLists.txt @@ -11,13 +11,11 @@ endif() add_library(mylibA STATIC mylibA.c) set_property(TARGET mylibA PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/External/lib") -# get_property(mylibA TARGET mylibA PROPERTY LOCATION) # Build a library into our build tree relative to the subproject build tree. add_library(mylibB STATIC mylibB.c) set_property(TARGET mylibB PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${LinkDirectory_BINARY_DIR}/lib") -# get_property(mylibB TARGET mylibB PROPERTY LOCATION) # Create a custom target to drive the subproject build. include(ExternalProject) -- cgit v0.12 From 6cfe6b881daab46abf97b8e8ccca3f906f8256fe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jan 2014 16:17:54 +0100 Subject: Help: Fix typo: 'target' -> 'target property' --- Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst index 2bc1881..3e6c4d1 100644 --- a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst +++ b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst @@ -9,6 +9,6 @@ files. As this ``_automoc`` target is created at generate-time, it is not possible to define dependencies of it, such as to create inputs for the ``moc`` executable. -The ``AUTOGEN_TARGET_DEPENDS`` target can be set instead to a list of dependencies -for the ``_automoc`` target. The buildsystem will be generated to depend on its -contents. +The ``AUTOGEN_TARGET_DEPENDS`` target property can be set instead to a list of +dependencies for the ``_automoc`` target. The buildsystem will be generated to +depend on its contents. -- cgit v0.12 From 28c865bb220882deab60091063ca7a1f8ab386f4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jan 2014 16:24:28 +0100 Subject: Tests: simplify Qt4 target usage This content was copied from another test where both the Core and Gui targets are used. --- Tests/RunCMake/CompatibleInterface/AutoUic.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Tests/RunCMake/CompatibleInterface/AutoUic.cmake b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake index 86bd5a0..03635e2 100644 --- a/Tests/RunCMake/CompatibleInterface/AutoUic.cmake +++ b/Tests/RunCMake/CompatibleInterface/AutoUic.cmake @@ -1,9 +1,6 @@ find_package(Qt4 REQUIRED) -set(QT_CORE_TARGET Qt4::QtCore) -set(QT_GUI_TARGET Qt4::QtGui) - set(CMAKE_AUTOUIC ON) set(CMAKE_DEBUG_TARGET_PROPERTIES AUTOUIC_OPTIONS) @@ -19,4 +16,4 @@ set_property(TARGET OtherI18n APPEND PROPERTY ) add_library(LibWidget empty.cpp) -target_link_libraries(LibWidget KI18n OtherI18n ${QT_GUI_TARGET}) +target_link_libraries(LibWidget KI18n OtherI18n Qt4::QtGui) -- cgit v0.12 From 0b5bf8ad0b55431969aadb94d6563f1b9c6cf2e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jan 2014 16:35:31 +0100 Subject: Help: Mention CMAKE_DISABLE_FIND_PACKAGE_ in package docs. --- Help/manual/cmake-packages.7.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index 376ec78..3eda829 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -72,6 +72,10 @@ or as a separate ``OPTIONAL_COMPONENTS`` list: Handling of ``COMPONENTS`` and ``OPTIONAL_COMPONENTS`` is defined by the package. +By setting the :variable:`CMAKE_DISABLE_FIND_PACKAGE_` variable to +``TRUE``, the ``PackageName`` package will not be searched, and will always +be ``NOTFOUND``. + Config-file Packages -------------------- -- cgit v0.12 From 80e9fe9cee63f2a8ade3b381e31477ab6055ef8b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 5 Jan 2014 04:41:08 +0100 Subject: Help: Note that language-specific 'built-ins' are set by the project command. --- Help/manual/cmake-toolchains.7.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 97cd650..fb529ad 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -20,7 +20,11 @@ with information about compiler and utility paths. Languages ========= -Languages are enabled by the :command:`project` command. If no project command +Languages are enabled by the :command:`project` command. Language-specific +built-in variables, such as +:variable:`CMAKE_CXX_COMPILER _COMPILER>`, +:variable:`CMAKE_CXX_COMPILER_ID _COMPILER_ID>` etc are set by +invoking the :command:`project` command. If no project command is in the top-level CMakeLists file, one will be implicitly generated. By default the enabled languages are C and CXX: -- cgit v0.12 From ee21f1c60500a5e1d088bef9116712acaaa06892 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 6 Jan 2014 18:23:58 +0100 Subject: CompatibleInterface: Test debugging of not-set property. --- Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt | 6 ++++++ Tests/RunCMake/CompatibleInterface/DebugProperties.cmake | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt index e3efe28..17b8a5c 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt @@ -67,6 +67,12 @@ CMake Debug Log: \* Target "CompatibleInterface" has property content "prop3" + CMake Debug Log: + String compatibility of property "STRING_PROP4" for target + "CompatibleInterface" \(result: "\(unset\)"\): + + \* Target "CompatibleInterface" property not set. ++ +CMake Debug Log: Numeric minimum compatibility of property "NUMBER_MIN_PROP1" for target "CompatibleInterface" \(result: "50"\): diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake index 42a3af2..0196611 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake @@ -22,6 +22,7 @@ set_property(TARGET iface1 APPEND PROPERTY STRING_PROP1 STRING_PROP2 STRING_PROP3 + STRING_PROP4 # Not set. ) set_property(TARGET iface1 APPEND PROPERTY COMPATIBLE_INTERFACE_NUMBER_MIN @@ -36,7 +37,7 @@ set_property(TARGET iface1 APPEND PROPERTY set(CMAKE_DEBUG_TARGET_PROPERTIES BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 BOOL_PROP5 BOOL_PROP6 BOOL_PROP7 - STRING_PROP1 STRING_PROP2 STRING_PROP3 + STRING_PROP1 STRING_PROP2 STRING_PROP3 STRING_PROP4 NUMBER_MIN_PROP1 NUMBER_MIN_PROP2 NUMBER_MAX_PROP1 NUMBER_MAX_PROP2 ) -- cgit v0.12 From 5169130539110ff479875e76784109f174c28c69 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 4 Jan 2014 12:34:02 +0100 Subject: Help: Document the target properties exported to IMPORTED targets. --- Help/manual/cmake-buildsystem.7.rst | 2 ++ Help/manual/cmake-packages.7.rst | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index be60ebb..03f9115 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -218,6 +218,8 @@ each keyword: PRIVATE serialization ) +.. _`Compatible Interface Properties`: + Compatible Interface Properties ------------------------------- diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index 3eda829..b572bf7 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -280,6 +280,12 @@ shared library: add_library(ClimbingStats SHARED climbingstats.cpp) generate_export_header(ClimbingStats) + set_property(TARGET ClimbingStats PROPERTY VERSION ${Upstream_VERSION}) + set_property(TARGET ClimbingStats PROPERTY SOVERSION 3) + set_property(TARGET ClimbingStats PROPERTY INTERFACE_ClimbingStats_MAJOR_VERSION 3) + set_property(TARGET ClimbingStats APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING ClimbingStats_MAJOR_VERSION + ) install(TARGETS ClimbingStats EXPORT ClimbingStatsTargets LIBRARY DESTINATION lib @@ -346,6 +352,22 @@ targets, suitable for use by downsteams and arranges to install it to and a ``cmake/ClimbingStatsConfig.cmake`` are installed to the same location, completing the package. +The generated :prop_tgt:`IMPORTED` targets have appropriate properties set +to define their usage requirements, such as +:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`, +:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` and other relevant built-in +``INTERFACE_`` properties. The ``INTERFACE`` variant of user-defined +properties listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and +other :ref:`Compatible Interface Properties` are also propagated to the +generated :prop_tgt:`IMPORTED` targets. In the above case, +``ClimbingStats_MAJOR_VERSION`` is defined as a string which must be +compatible among the dependencies of any depender. By setting this custom +defined user property in this version and in the next version of +``ClimbingStats``, :manual:`cmake(1)` will issue a diagnostic if there is an +attempt to use version 3 together with version 4. Packages can choose to +employ such a pattern if different major versions of the package are designed +to be incompatible. + A ``NAMESPACE`` with double-colons is specified when exporting the targets for installation. This convention of double-colons gives CMake a hint that the name is an :prop_tgt:`IMPORTED` target when it is used by downstreams -- cgit v0.12 From 3917d86b261f0b88eb5cf0e8d2700c70cebdbe4b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 31 Dec 2013 15:57:25 +0100 Subject: Genex: Add a nullary form for CONFIG This is consistent with other similar expressions such as PLATFORM_ID, and makes the CONFIGURATION expression obsolete. Fix an off-by-one error in GeneratorExpressionContent::EvaluateParameters exposed by a unit test. Remove the test for 'bad' nullary use of $. Add a unit test to verify that $ and $ have the same value. --- Help/manual/cmake-generator-expressions.7.rst | 2 ++ Source/cmGeneratorExpressionEvaluator.cxx | 8 ++++++-- Tests/GeneratorExpression/CMakeLists.txt | 1 + Tests/GeneratorExpression/check-part1.cmake | 1 + Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt | 11 +---------- Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake | 1 - 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 12cfaf8..ac8c3f8 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -104,6 +104,8 @@ expands to ``OLD_COMPILER`` if the than 4.2.0. ``$`` + Configuration name. Deprecated. Use ``CONFIG`` instead. +``$`` Configuration name ``$`` The CMake-id of the platform diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 259ba94..5edea86 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -676,13 +676,17 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode { ConfigurationTestNode() {} - virtual int NumExpectedParameters() const { return 1; } + virtual int NumExpectedParameters() const { return OneOrZeroParameters; } std::string Evaluate(const std::vector ¶meters, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *) const { + if (parameters.empty()) + { + return configurationNode.Evaluate(parameters, context, content, 0); + } cmsys::RegularExpression configValidator; configValidator.compile("^[A-Za-z0-9_]*$"); if (!configValidator.find(parameters.begin()->c_str())) @@ -1801,7 +1805,7 @@ std::string GeneratorExpressionContent::EvaluateParameters( + "> expression requires at least one parameter."); } if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters - && parameters.size() > 2) + && parameters.size() > 1) { reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires one or zero parameters."); diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 9512efc..3b85dc3 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -13,6 +13,7 @@ add_custom_target(check-part1 ALL -Dtest_1=$<1:content> -Dtest_1_with_comma=$<1:-Wl,--no-undefined> -Dconfig=$ + -Dshort_config=$ -Dtest_and_0=$ -Dtest_and_0_0=$ -Dtest_and_0_1=$ diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 9bef159..3207582 100644 --- a/Tests/GeneratorExpression/check-part1.cmake +++ b/Tests/GeneratorExpression/check-part1.cmake @@ -2,6 +2,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake) message(STATUS "config=[${config}]") +check(config "${short_config}") check(test_0 "") check(test_0_with_comma "") check(test_1 "content") diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 1cfbf40..964ea4d 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -1,15 +1,6 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): Error evaluating generator expression: - \$ - - \$ expression requires exactly one parameter. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): - Error evaluating generator expression: - \$ Expression syntax not recognized. @@ -21,7 +12,7 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\): \$ - \$ expression requires exactly one parameter. + \$ expression requires one or zero parameters. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake index c27ea5f..5c22aaa 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake @@ -1,5 +1,4 @@ add_custom_target(check ALL COMMAND check - $ $ $ $ -- cgit v0.12