This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 37d5107091a9713090f73406b87053a05817c882 (commit) via ed92af3a7a746dfeb395b9fd783791fcae2b062f (commit) via 35447174ccece96d1b4e6304b94a31e03064500b (commit) via 15928265868c8bb7afba6d4ce9f2f27b56d685d5 (commit) from 28d08a9e6b7eb2f45773dc5754828eb8de35aa0a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=37d5107091a9713090f73406b87053a05817c882 commit 37d5107091a9713090f73406b87053a05817c882 Merge: 28d08a9 ed92af3 Author: Brad King <brad.k...@kitware.com> AuthorDate: Thu Sep 8 11:54:10 2016 -0400 Commit: CMake Topic Stage <kwro...@kitware.com> CommitDate: Thu Sep 8 11:54:10 2016 -0400 Merge topic 'geh-failure-tests' into next ed92af3a Refactor GenerateExportHeader test code 35447174 Add data tests to GenerateExportHeader test 15928265 Add failure test for GenerateExportHeader https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ed92af3a7a746dfeb395b9fd783791fcae2b062f commit ed92af3a7a746dfeb395b9fd783791fcae2b062f Author: Matthew Woehlke <matthew.woeh...@kitware.com> AuthorDate: Fri Sep 2 16:53:34 2016 -0400 Commit: Matthew Woehlke <matthew.woeh...@kitware.com> CommitDate: Wed Sep 7 10:47:22 2016 -0400 Refactor GenerateExportHeader test code Refactor the library code used in the GenerateExportHeader test to use an improved naming convention that more directly identifies what it being tested, making use of namespaces to avoid possible symbol collisions. This also eliminates duplicate cases such as `libshared()` and `libshared_not_exported()` which had the same decoration, and adds consistent pairings of <name>_EXPORT and <name>_DEPRECATED_EXPORT which were missing previously. The data tests from the previous commit are also added to `libstatic` and `libshared_and_static` for consistency. Note that there are no exported members of exported classes, as these are not allowed on Windows. diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp index f3f2da9..4ba6abd 100644 --- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp @@ -56,19 +56,29 @@ void compare(const char* refName, const char* testName) int main() { { - Libshared l; - l.libshared(); - l.libshared_exported(); - l.libshared_deprecated(); - l.libshared_not_exported(); + libshared::Class l; + //l.method(); LINK ERROR + l.method_exported(); + //l.method_deprecated(); LINK ERROR + l.method_deprecated_exported(); + //l.method_excluded(); LINK ERROR + + //use_int(l.data); LINK ERROR + use_int(l.data_exported); + //use_int(l.data_excluded); LINK ERROR + } + + { + libshared::ExportedClass l; + l.method(); + l.method_deprecated(); #ifdef _WIN32 - l.libshared_excluded(); + l.method_excluded(); #else - //l.libshared_excluded(); LINK ERROR (NOT WIN32) + //l.method_excluded(); LINK ERROR (NOT WIN32) #endif - use_int(l.data_exported); - use_int(l.data_not_exported); + use_int(l.data); #ifdef _WIN32 use_int(l.data_excluded); #else @@ -77,71 +87,76 @@ int main() } { - LibsharedNotExported l; - //l.libshared(); LINK ERROR - l.libshared_exported(); - l.libshared_deprecated(); - //l.libshared_not_exported(); LINK ERROR - //l.libshared_excluded(); LINK ERROR - - use_int(l.data_exported); - //use_int(l.data_not_exported); LINK ERROR - //use_int(l.data_excluded); LINK ERROR - } - - { - LibsharedExcluded l; - //l.libshared(); LINK ERROR - l.libshared_exported(); - l.libshared_deprecated(); - //l.libshared_not_exported(); LINK ERROR - //l.libshared_excluded(); LINK ERROR - + libshared::ExcludedClass l; + //l.method(); LINK ERROR + l.method_exported(); + //l.method_deprecated(); LINK ERROR + l.method_deprecated_exported(); + //l.method_excluded(); LINK ERROR + + //use_int(l.data); LINK ERROR use_int(l.data_exported); - //use_int(l.data_not_exported); LINK ERROR //use_int(l.data_excluded); LINK ERROR } - libshared_exported(); - libshared_deprecated(); - //libshared_not_exported(); LINK ERROR - //libshared_excluded(); LINK ERROR + //libshared::function(); LINK ERROR + libshared::function_exported(); + //libshared::function_deprecated(); LINK ERROR + libshared::function_deprecated_exported(); + //libshared::function_excluded(); LINK ERROR - use_int(data_exported); - //use_int(data_not_exported); LINK ERROR - //use_int(data_excluded); LINK ERROR + //use_int(libshared::data); LINK ERROR + use_int(libshared::data_exported); + //use_int(libshared::data_excluded); LINK ERROR { - Libstatic l; - l.libstatic(); - l.libstatic_exported(); - l.libstatic_deprecated(); - l.libstatic_not_exported(); - l.libstatic_excluded(); + libstatic::Class l; + l.method(); + l.method_exported(); + l.method_deprecated(); + l.method_deprecated_exported(); + l.method_excluded(); + + use_int(l.data); + use_int(l.data_exported); + use_int(l.data_excluded); } { - LibstaticNotExported l; - l.libstatic(); - l.libstatic_exported(); - l.libstatic_deprecated(); - l.libstatic_not_exported(); - l.libstatic_excluded(); + libstatic::ExportedClass l; + l.method(); + l.method_exported(); + l.method_deprecated(); + l.method_deprecated_exported(); + l.method_excluded(); + + use_int(l.data); + use_int(l.data_exported); + use_int(l.data_excluded); } { - LibstaticExcluded l; - l.libstatic(); - l.libstatic_exported(); - l.libstatic_deprecated(); - l.libstatic_not_exported(); - l.libstatic_excluded(); + libstatic::ExcludedClass l; + l.method(); + l.method_exported(); + l.method_deprecated(); + l.method_deprecated_exported(); + l.method_excluded(); + + use_int(l.data); + use_int(l.data_exported); + use_int(l.data_excluded); } - libstatic_exported(); - libstatic_deprecated(); - libstatic_not_exported(); - libstatic_excluded(); + libstatic::function(); + libstatic::function_exported(); + libstatic::function_deprecated(); + libstatic::function_deprecated_exported(); + libstatic::function_excluded(); + + use_int(libstatic::data); + use_int(libstatic::data_exported); + use_int(libstatic::data_excluded); #if defined(SRC_DIR) && defined(BIN_DIR) compare(SRC_DIR "/libshared_export.h", diff --git a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp index 846c207..9ac8381 100644 --- a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp +++ b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -1,106 +1,121 @@ - #include "libshared_and_static.h" #ifndef MY_CUSTOM_CONTENT_ADDED #error "MY_CUSTOM_CONTENT_ADDED not defined!" #endif -int LibsharedAndStatic::libshared_and_static() const +int libshared_and_static::Class::method() const { return 0; } -int LibsharedAndStatic::libshared_and_static_exported() const +int libshared_and_static::Class::method_exported() const { return 0; } -int LibsharedAndStatic::libshared_and_static_deprecated() const +int libshared_and_static::Class::method_deprecated() const { return 0; } -int LibsharedAndStatic::libshared_and_static_not_exported() const +int libshared_and_static::Class::method_deprecated_exported() const { return 0; } -int LibsharedAndStatic::libshared_and_static_excluded() const +int libshared_and_static::Class::method_excluded() const { return 0; } -int LibsharedAndStaticNotExported::libshared_and_static() const -{ - return 0; -} +int const libshared_and_static::Class::data = 1; -int LibsharedAndStaticNotExported::libshared_and_static_exported() const +int const libshared_and_static::Class::data_exported = 1; + +int const libshared_and_static::Class::data_excluded = 1; + +int libshared_and_static::ExportedClass::method() const { return 0; } -int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const +int libshared_and_static::ExportedClass::method_deprecated() const { return 0; } -int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const +int libshared_and_static::ExportedClass::method_excluded() const { return 0; } -int LibsharedAndStaticNotExported::libshared_and_static_excluded() const +int const libshared_and_static::ExportedClass::data = 1; + +int const libshared_and_static::ExportedClass::data_excluded = 1; + +int libshared_and_static::ExcludedClass::method() const { return 0; } -int LibsharedAndStaticExcluded::libshared_and_static() const +int libshared_and_static::ExcludedClass::method_exported() const { return 0; } -int LibsharedAndStaticExcluded::libshared_and_static_exported() const +int libshared_and_static::ExcludedClass::method_deprecated() const { return 0; } -int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const +int libshared_and_static::ExcludedClass::method_deprecated_exported() const { return 0; } -int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const +int libshared_and_static::ExcludedClass::method_excluded() const { return 0; } -int LibsharedAndStaticExcluded::libshared_and_static_excluded() const +int const libshared_and_static::ExcludedClass::data = 1; + +int const libshared_and_static::ExcludedClass::data_exported = 1; + +int const libshared_and_static::ExcludedClass::data_excluded = 1; + +int libshared_and_static::function() { return 0; } -int libshared_and_static() +int libshared_and_static::function_exported() { return 0; } -int libshared_and_static_exported() +int libshared_and_static::function_deprecated() { return 0; } -int libshared_and_static_deprecated() +int libshared_and_static::function_deprecated_exported() { return 0; } -int libshared_and_static_not_exported() +int libshared_and_static::function_excluded() { return 0; } -int libshared_and_static_excluded() +int const libshared_and_static::data = 1; + +int const libshared_and_static::data_exported = 1; + +int const libshared_and_static::data_excluded = 1; + +void use_int(int) { - return 0; } diff --git a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h index ea672fe..14b0109 100644 --- a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h +++ b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -1,66 +1,81 @@ - -#ifndef SHARED_AND_STATIC_H -#define SHARED_AND_STATIC_H +#ifndef LIBSHARED_AND_STATIC_H +#define LIBSHARED_AND_STATIC_H #include "libshared_and_static_export.h" -class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic +namespace libshared_and_static +{ + +class Class { public: - int libshared_and_static() const; + int method() const; + + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT method_exported() const; - int libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const; - int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED - libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT method_deprecated_exported() const; - int libshared_and_static_not_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const; - int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT - libshared_and_static_excluded() const; + static int const data; + + static int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported; + + static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded; }; -class LibsharedAndStaticNotExported +class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT ExportedClass { public: - int libshared_and_static() const; + int method() const; - int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT - libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const; - int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED - libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const; - int libshared_and_static_not_exported() const; + static int const data; - int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT - libshared_and_static_excluded() const; + static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded; }; -class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded +class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT ExcludedClass { public: - int libshared_and_static() const; + int method() const; + + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT method_exported() const; - int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT - libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED method_deprecated() const; - int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED - libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT method_deprecated_exported() const; - int libshared_and_static_not_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT method_excluded() const; - int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT - libshared_and_static_excluded() const; + static int const data; + + static int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported; + + static int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded; }; -MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); +int function(); + +int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT function_exported(); + +int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED function_deprecated(); + +int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT function_deprecated_exported(); + +int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT function_excluded(); + +extern int const data; -MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int -libshared_and_static_deprecated(); +extern int const MYPREFIX_LIBSHARED_AND_STATIC_EXPORT data_exported; -int libshared_and_static_not_exported(); +extern int const MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT data_excluded; -int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); +} // namespace libshared_and_static #endif diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp index 7e46ab5..328ef6f 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp @@ -1,129 +1,116 @@ - #include "libshared.h" -int Libshared::libshared() const +int libshared::Class::method() const { return 0; } -int Libshared::libshared_exported() const +int libshared::Class::method_exported() const { return 0; } -int Libshared::libshared_deprecated() const +int libshared::Class::method_deprecated() const { return 0; } -int Libshared::libshared_not_exported() const +int libshared::Class::method_deprecated_exported() const { return 0; } -int Libshared::libshared_excluded() const +int libshared::Class::method_excluded() const { return 0; } -int const Libshared::data_exported = 1; - -int const Libshared::data_not_exported = 1; - -int const Libshared::data_excluded = 1; +int const libshared::Class::data = 1; -int LibsharedNotExported::libshared() const -{ - return 0; -} +int const libshared::Class::data_exported = 1; -int LibsharedNotExported::libshared_exported() const -{ - return 0; -} +int const libshared::Class::data_excluded = 1; -int LibsharedNotExported::libshared_deprecated() const +int libshared::ExportedClass::method() const { return 0; } -int LibsharedNotExported::libshared_not_exported() const +int libshared::ExportedClass::method_deprecated() const { return 0; } -int LibsharedNotExported::libshared_excluded() const +int libshared::ExportedClass::method_excluded() const { return 0; } -int const LibsharedNotExported::data_exported = 1; - -int const LibsharedNotExported::data_not_exported = 1; +int const libshared::ExportedClass::data = 1; -int const LibsharedNotExported::data_excluded = 1; +int const libshared::ExportedClass::data_excluded = 1; -int LibsharedExcluded::libshared() const +int libshared::ExcludedClass::method() const { return 0; } -int LibsharedExcluded::libshared_exported() const +int libshared::ExcludedClass::method_exported() const { return 0; } -int LibsharedExcluded::libshared_deprecated() const +int libshared::ExcludedClass::method_deprecated() const { return 0; } -int LibsharedExcluded::libshared_not_exported() const +int libshared::ExcludedClass::method_deprecated_exported() const { return 0; } -int LibsharedExcluded::libshared_excluded() const +int libshared::ExcludedClass::method_excluded() const { return 0; } -int const LibsharedExcluded::data_exported = 1; +int const libshared::ExcludedClass::data = 1; -int const LibsharedExcluded::data_not_exported = 1; +int const libshared::ExcludedClass::data_exported = 1; -int const LibsharedExcluded::data_excluded = 1; +int const libshared::ExcludedClass::data_excluded = 1; -int libshared() +int libshared::function() { return 0; } -int libshared_exported() +int libshared::function_exported() { return 0; } -int libshared_deprecated() +int libshared::function_deprecated() { return 0; } -int libshared_not_exported() +int libshared::function_deprecated_exported() { return 0; } -int libshared_excluded() +int libshared::function_excluded() { return 0; } -int const data_exported = 1; +int const libshared::data = 1; -int const data_not_exported = 1; +int const libshared::data_exported = 1; -int const data_excluded = 1; +int const libshared::data_excluded = 1; void use_int(int) { diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h index 62879c2..d24905f 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h @@ -1,83 +1,83 @@ - #ifndef LIBSHARED_H #define LIBSHARED_H #include "libshared_export.h" -class LIBSHARED_EXPORT Libshared +namespace libshared +{ + +class Class { public: - int libshared() const; + int method() const; - int libshared_exported() const; + int LIBSHARED_EXPORT method_exported() const; - int LIBSHARED_DEPRECATED libshared_deprecated() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - int libshared_not_exported() const; + int LIBSHARED_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; + int LIBSHARED_NO_EXPORT method_excluded() const; - static int const LIBSHARED_EXPORT data_exported; + static int const data; - static int const data_not_exported; + static int const LIBSHARED_EXPORT data_exported; static int const LIBSHARED_NO_EXPORT data_excluded; }; -class LibsharedNotExported +class LIBSHARED_EXPORT ExportedClass { public: - int libshared() const; - - int LIBSHARED_EXPORT libshared_exported() const; + int method() const; - int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - int libshared_not_exported() const; + int LIBSHARED_NO_EXPORT method_excluded() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; - - static int const LIBSHARED_EXPORT data_exported; - - static int const data_not_exported; + static int const data; static int const LIBSHARED_NO_EXPORT data_excluded; }; -class LIBSHARED_NO_EXPORT LibsharedExcluded +class LIBSHARED_NO_EXPORT ExcludedClass { public: - int libshared() const; + int method() const; - int LIBSHARED_EXPORT libshared_exported() const; + int LIBSHARED_EXPORT method_exported() const; - int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + int LIBSHARED_DEPRECATED method_deprecated() const; - int libshared_not_exported() const; + int LIBSHARED_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSHARED_NO_EXPORT libshared_excluded() const; + int LIBSHARED_NO_EXPORT method_excluded() const; - static int const LIBSHARED_EXPORT data_exported; + static int const data; - static int const data_not_exported; + static int const LIBSHARED_EXPORT data_exported; static int const LIBSHARED_NO_EXPORT data_excluded; }; -LIBSHARED_EXPORT int libshared_exported(); +int function(); -LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); +int LIBSHARED_EXPORT function_exported(); -int libshared_not_exported(); +int LIBSHARED_DEPRECATED function_deprecated(); -int LIBSHARED_NO_EXPORT libshared_excluded(); +int LIBSHARED_DEPRECATED_EXPORT function_deprecated_exported(); -extern int const LIBSHARED_EXPORT data_exported; +int LIBSHARED_NO_EXPORT function_excluded(); -extern int const data_not_exported; +extern int const data; + +extern int const LIBSHARED_EXPORT data_exported; extern int const LIBSHARED_NO_EXPORT data_excluded; +} // namespace libshared + LIBSHARED_EXPORT void use_int(int); #endif diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.cpp index 89381af..e1d1255 100644 --- a/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.cpp +++ b/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.cpp @@ -1,97 +1,125 @@ - #include "libstatic.h" -int Libstatic::libstatic() const +int libstatic::Class::method() const { return 0; } -int Libstatic::libstatic_exported() const +int libstatic::Class::method_exported() const { return 0; } -int Libstatic::libstatic_deprecated() const +int libstatic::Class::method_deprecated() const { return 0; } -int Libstatic::libstatic_not_exported() const +int libstatic::Class::method_deprecated_exported() const { return 0; } -int Libstatic::libstatic_excluded() const +int libstatic::Class::method_excluded() const { return 0; } -int LibstaticNotExported::libstatic() const +int const libstatic::Class::data = 1; + +int const libstatic::Class::data_exported = 1; + +int const libstatic::Class::data_excluded = 1; + +int libstatic::ExportedClass::method() const { return 0; } -int LibstaticNotExported::libstatic_exported() const +int libstatic::ExportedClass::method_exported() const { return 0; } -int LibstaticNotExported::libstatic_deprecated() const +int libstatic::ExportedClass::method_deprecated() const { return 0; } -int LibstaticNotExported::libstatic_not_exported() const +int libstatic::ExportedClass::method_deprecated_exported() const { return 0; } -int LibstaticNotExported::libstatic_excluded() const +int libstatic::ExportedClass::method_excluded() const { return 0; } -int LibstaticExcluded::libstatic() const +int const libstatic::ExportedClass::data = 1; + +int const libstatic::ExportedClass::data_exported = 1; + +int const libstatic::ExportedClass::data_excluded = 1; + +int libstatic::ExcludedClass::method() const { return 0; } -int LibstaticExcluded::libstatic_exported() const +int libstatic::ExcludedClass::method_exported() const { return 0; } -int LibstaticExcluded::libstatic_deprecated() const +int libstatic::ExcludedClass::method_deprecated() const { return 0; } -int LibstaticExcluded::libstatic_not_exported() const +int libstatic::ExcludedClass::method_deprecated_exported() const { return 0; } -int LibstaticExcluded::libstatic_excluded() const +int libstatic::ExcludedClass::method_excluded() const { return 0; } -int libstatic_exported() +int const libstatic::ExcludedClass::data = 1; + +int const libstatic::ExcludedClass::data_exported = 1; + +int const libstatic::ExcludedClass::data_excluded = 1; + +int libstatic::function() +{ + return 0; +} + +int libstatic::function_exported() { return 0; } -int libstatic_deprecated() +int libstatic::function_deprecated() { return 0; } -int libstatic_not_exported() +int libstatic::function_deprecated_exported() { return 0; } -int libstatic_excluded() +int libstatic::function_excluded() { return 0; } + +int const libstatic::data = 1; + +int const libstatic::data_exported = 1; + +int const libstatic::data_excluded = 1; diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.h b/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.h index 6072d9b..a40e732 100644 --- a/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.h +++ b/Tests/RunCMake/GenerateExportHeader/libstatic/libstatic.h @@ -1,57 +1,87 @@ - #ifndef LIBSTATIC_H #define LIBSTATIC_H #include "libstatic_export.h" -class LIBSTATIC_EXPORT Libstatic +namespace libstatic +{ + +class Class { public: - int libstatic() const; + int method() const; + + int LIBSTATIC_EXPORT method_exported() const; + + int LIBSTATIC_DEPRECATED method_deprecated() const; - int libstatic_exported() const; + int LIBSTATIC_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + int LIBSTATIC_NO_EXPORT method_excluded() const; - int libstatic_not_exported() const; + static int const data; - int LIBSTATIC_NO_EXPORT libstatic_excluded() const; + static int const LIBSTATIC_EXPORT data_exported; + + static int const LIBSTATIC_NO_EXPORT data_excluded; }; -class LibstaticNotExported +class LIBSTATIC_EXPORT ExportedClass { public: - int libstatic() const; + int method() const; + + int LIBSTATIC_EXPORT method_exported() const; + + int LIBSTATIC_DEPRECATED method_deprecated() const; + + int LIBSTATIC_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSTATIC_EXPORT libstatic_exported() const; + int LIBSTATIC_NO_EXPORT method_excluded() const; - int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + static int const data; - int libstatic_not_exported() const; + static int const LIBSTATIC_EXPORT data_exported; - int LIBSTATIC_NO_EXPORT libstatic_excluded() const; + static int const LIBSTATIC_NO_EXPORT data_excluded; }; -class LIBSTATIC_NO_EXPORT LibstaticExcluded +class LIBSTATIC_NO_EXPORT ExcludedClass { public: - int libstatic() const; + int method() const; - int LIBSTATIC_EXPORT libstatic_exported() const; + int LIBSTATIC_EXPORT method_exported() const; - int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + int LIBSTATIC_DEPRECATED method_deprecated() const; - int libstatic_not_exported() const; + int LIBSTATIC_DEPRECATED_EXPORT method_deprecated_exported() const; - int LIBSTATIC_NO_EXPORT libstatic_excluded() const; + int LIBSTATIC_NO_EXPORT method_excluded() const; + + static int const data; + + static int const LIBSTATIC_EXPORT data_exported; + + static int const LIBSTATIC_NO_EXPORT data_excluded; }; -LIBSTATIC_EXPORT int libstatic_exported(); +int function(); + +int LIBSTATIC_EXPORT function_exported(); + +int LIBSTATIC_DEPRECATED function_deprecated(); + +int LIBSTATIC_DEPRECATED_EXPORT function_deprecated_exported(); + +int LIBSTATIC_NO_EXPORT function_excluded(); + +extern int const data; -LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated(); +extern int const LIBSTATIC_EXPORT data_exported; -int libstatic_not_exported(); +extern int const LIBSTATIC_NO_EXPORT data_excluded; -int LIBSTATIC_NO_EXPORT libstatic_excluded(); +} // namespace libstatic #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=35447174ccece96d1b4e6304b94a31e03064500b commit 35447174ccece96d1b4e6304b94a31e03064500b Author: Matthew Woehlke <matthew.woeh...@kitware.com> AuthorDate: Fri Sep 2 11:23:16 2016 -0400 Commit: Matthew Woehlke <matthew.woeh...@kitware.com> CommitDate: Wed Sep 7 10:47:21 2016 -0400 Add data tests to GenerateExportHeader test Add static data members and global variables to the GenerateExportHeader shared library, testing that export decoration for these works in addition to decoration of classes and free functions. diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp index 4c1f2a9..f3f2da9 100644 --- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp @@ -66,6 +66,14 @@ int main() #else //l.libshared_excluded(); LINK ERROR (NOT WIN32) #endif + + use_int(l.data_exported); + use_int(l.data_not_exported); +#ifdef _WIN32 + use_int(l.data_excluded); +#else + //use_int(l.data_excluded); LINK ERROR (NOT WIN32) +#endif } { @@ -75,6 +83,10 @@ int main() l.libshared_deprecated(); //l.libshared_not_exported(); LINK ERROR //l.libshared_excluded(); LINK ERROR + + use_int(l.data_exported); + //use_int(l.data_not_exported); LINK ERROR + //use_int(l.data_excluded); LINK ERROR } { @@ -84,6 +96,10 @@ int main() l.libshared_deprecated(); //l.libshared_not_exported(); LINK ERROR //l.libshared_excluded(); LINK ERROR + + use_int(l.data_exported); + //use_int(l.data_not_exported); LINK ERROR + //use_int(l.data_excluded); LINK ERROR } libshared_exported(); @@ -91,6 +107,10 @@ int main() //libshared_not_exported(); LINK ERROR //libshared_excluded(); LINK ERROR + use_int(data_exported); + //use_int(data_not_exported); LINK ERROR + //use_int(data_excluded); LINK ERROR + { Libstatic l; l.libstatic(); diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp index ad6d356..7e46ab5 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.cpp @@ -26,6 +26,12 @@ int Libshared::libshared_excluded() const return 0; } +int const Libshared::data_exported = 1; + +int const Libshared::data_not_exported = 1; + +int const Libshared::data_excluded = 1; + int LibsharedNotExported::libshared() const { return 0; @@ -51,6 +57,12 @@ int LibsharedNotExported::libshared_excluded() const return 0; } +int const LibsharedNotExported::data_exported = 1; + +int const LibsharedNotExported::data_not_exported = 1; + +int const LibsharedNotExported::data_excluded = 1; + int LibsharedExcluded::libshared() const { return 0; @@ -76,6 +88,12 @@ int LibsharedExcluded::libshared_excluded() const return 0; } +int const LibsharedExcluded::data_exported = 1; + +int const LibsharedExcluded::data_not_exported = 1; + +int const LibsharedExcluded::data_excluded = 1; + int libshared() { return 0; @@ -100,3 +118,13 @@ int libshared_excluded() { return 0; } + +int const data_exported = 1; + +int const data_not_exported = 1; + +int const data_excluded = 1; + +void use_int(int) +{ +} diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h index bd9f2e3..62879c2 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h +++ b/Tests/RunCMake/GenerateExportHeader/libshared/libshared.h @@ -16,6 +16,12 @@ public: int libshared_not_exported() const; int LIBSHARED_NO_EXPORT libshared_excluded() const; + + static int const LIBSHARED_EXPORT data_exported; + + static int const data_not_exported; + + static int const LIBSHARED_NO_EXPORT data_excluded; }; class LibsharedNotExported @@ -30,6 +36,12 @@ public: int libshared_not_exported() const; int LIBSHARED_NO_EXPORT libshared_excluded() const; + + static int const LIBSHARED_EXPORT data_exported; + + static int const data_not_exported; + + static int const LIBSHARED_NO_EXPORT data_excluded; }; class LIBSHARED_NO_EXPORT LibsharedExcluded @@ -44,6 +56,12 @@ public: int libshared_not_exported() const; int LIBSHARED_NO_EXPORT libshared_excluded() const; + + static int const LIBSHARED_EXPORT data_exported; + + static int const data_not_exported; + + static int const LIBSHARED_NO_EXPORT data_excluded; }; LIBSHARED_EXPORT int libshared_exported(); @@ -54,4 +72,12 @@ int libshared_not_exported(); int LIBSHARED_NO_EXPORT libshared_excluded(); +extern int const LIBSHARED_EXPORT data_exported; + +extern int const data_not_exported; + +extern int const LIBSHARED_NO_EXPORT data_excluded; + +LIBSHARED_EXPORT void use_int(int); + #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15928265868c8bb7afba6d4ce9f2f27b56d685d5 commit 15928265868c8bb7afba6d4ce9f2f27b56d685d5 Author: Matthew Woehlke <matthew.woeh...@kitware.com> AuthorDate: Fri Sep 2 11:04:55 2016 -0400 Commit: Matthew Woehlke <matthew.woeh...@kitware.com> CommitDate: Wed Sep 7 10:47:21 2016 -0400 Add failure test for GenerateExportHeader Modify notation of statements in the GenerateExportHeader test expected to result in link errors. Modify script used to build the test to also generate a suite of modified sources, each having exactly one of the failing lines enabled, and to generate EXCLUDE_FROM_ALL executables for the same. Modify RunCMake script used to drive the test to read the list of such executables and try to build each of them, verifying that they do in fact fail to build. This will verify that the _NO_EXPORT macros are working as expected, and will also catch errors like the one that 0cbaaf2dc3e2 fixed. diff --git a/Tests/RunCMake/GenerateExportHeader/GEH-failures.cmake b/Tests/RunCMake/GenerateExportHeader/GEH-failures.cmake new file mode 100644 index 0000000..88853b3 --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/GEH-failures.cmake @@ -0,0 +1,60 @@ +set(failure_test_executables + ${CMAKE_CURRENT_BINARY_DIR}/failure_test_targets) +file(WRITE ${failure_test_executables} "") + +# Read the input source file +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/exportheader_test.cpp content_post) +set(content_pre "") + +# Generate source files for failure test executables +set(counter 0) +while(1) + # Find first occurrence of link error marker in remaining content + string(REGEX MATCH "//([^;\n]+;) LINK ERROR( [(][^)]+[)])?\n(.*)" + match "${content_post}") + if(match STREQUAL "") + # No more matches + break() + endif() + + # Shift content buffers and extract failing statement + string(LENGTH "${content_post}" content_post_length) + string(LENGTH "${match}" matched_length) + math(EXPR shift_length "${content_post_length} - ${matched_length}") + + string(SUBSTRING "${content_post}" 0 ${shift_length} shift) + set(content_pre "${content_pre}${shift}") + set(content_post "${CMAKE_MATCH_3}") + set(content_active "//${CMAKE_MATCH_1} LINK ERROR${CMAKE_MATCH_2}") + set(statement "${CMAKE_MATCH_1}") + + # Check if potential error is conditional, and evaluate condition if so + string(REGEX REPLACE " [(]([^)]+)[)]" "\\1" condition "${CMAKE_MATCH_2}") + if(NOT condition STREQUAL "") + string(REGEX REPLACE " +" ";" condition "${condition}") + if(${condition}) + else() + message(STATUS "Not testing '${statement}'; " + "condition (${condition}) is FALSE") + set(content_pre "${content_pre}// link error removed\n") + continue() + endif() + endif() + + if(NOT skip) + message(STATUS "Creating failure test for '${statement}'") + math(EXPR counter "${counter} + 1") + + # Write new source file + set(out ${CMAKE_CURRENT_BINARY_DIR}/exportheader_failtest-${counter}.cpp) + file(WRITE ${out} "${content_pre}${statement}\n${content_post}") + + # Add executable for failure test + add_executable(GEH-fail-${counter} EXCLUDE_FROM_ALL ${out}) + target_link_libraries(GEH-fail-${counter} ${link_libraries}) + file(APPEND ${failure_test_executables} "GEH-fail-${counter}\n") + endif() + + # Add placeholder where failing statement was removed + set(content_pre "${content_pre}${content_active}\n") +endwhile() diff --git a/Tests/RunCMake/GenerateExportHeader/GEH-link-error-result.txt b/Tests/RunCMake/GenerateExportHeader/GEH-link-error-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/GEH-link-error-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GenerateExportHeader/GEH-link-error-stderr.txt b/Tests/RunCMake/GenerateExportHeader/GEH-link-error-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/GenerateExportHeader/GEH-link-error-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index ee0871b..cddba29 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -123,3 +123,5 @@ target_compile_definitions(GenerateExportHeader "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}\"" "BIN_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" ) + +include(${CMAKE_CURRENT_LIST_DIR}/GEH-failures.cmake) diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake index e534c1f..9423ef5 100644 --- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake @@ -12,6 +12,16 @@ function(run_GEH) run_cmake(GEH) run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug) run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader) + + file(STRINGS "${RunCMake_TEST_BINARY_DIR}/failure_test_targets" + failure_test_targets) + + foreach(failure_test_target ${failure_test_targets}) + run_cmake_command(GEH-link-error ${CMAKE_COMMAND} + --build . + --config Debug + --target ${failure_test_target}) + endforeach() endfunction() run_GEH() diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp index 26bea7e..4c1f2a9 100644 --- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp @@ -3,14 +3,6 @@ #include "libstatic.h" -// #define BUILD_FAIL - -#ifndef BUILD_FAIL -#define DOES_NOT_BUILD(function) -#else -#define DOES_NOT_BUILD(function) function -#endif - #include <fstream> #include <iostream> #include <stdlib.h> @@ -69,32 +61,35 @@ int main() l.libshared_exported(); l.libshared_deprecated(); l.libshared_not_exported(); - - DOES_NOT_BUILD(l.libshared_excluded();) +#ifdef _WIN32 + l.libshared_excluded(); +#else + //l.libshared_excluded(); LINK ERROR (NOT WIN32) +#endif } { LibsharedNotExported l; - DOES_NOT_BUILD(l.libshared();) + //l.libshared(); LINK ERROR l.libshared_exported(); l.libshared_deprecated(); - DOES_NOT_BUILD(l.libshared_not_exported();) - DOES_NOT_BUILD(l.libshared_excluded();) + //l.libshared_not_exported(); LINK ERROR + //l.libshared_excluded(); LINK ERROR } { LibsharedExcluded l; - DOES_NOT_BUILD(l.libshared();) + //l.libshared(); LINK ERROR l.libshared_exported(); l.libshared_deprecated(); - DOES_NOT_BUILD(l.libshared_not_exported();) - DOES_NOT_BUILD(l.libshared_excluded();) + //l.libshared_not_exported(); LINK ERROR + //l.libshared_excluded(); LINK ERROR } libshared_exported(); libshared_deprecated(); - DOES_NOT_BUILD(libshared_not_exported();) - DOES_NOT_BUILD(libshared_excluded();) + //libshared_not_exported(); LINK ERROR + //libshared_excluded(); LINK ERROR { Libstatic l; @@ -128,10 +123,12 @@ int main() libstatic_not_exported(); libstatic_excluded(); +#if defined(SRC_DIR) && defined(BIN_DIR) compare(SRC_DIR "/libshared_export.h", BIN_DIR "/libshared/libshared_export.h"); compare(SRC_DIR "/libstatic_export.h", BIN_DIR "/libstatic/libstatic_export.h"); +#endif return 0; } ----------------------------------------------------------------------- Summary of changes: .../GenerateExportHeader/GEH-failures.cmake | 60 +++++++++ .../GEH-link-error-result.txt} | 0 ...-build-stderr.txt => GEH-link-error-stderr.txt} | 0 Tests/RunCMake/GenerateExportHeader/GEH.cmake | 2 + .../GenerateExportHeader/RunCMakeTest.cmake | 10 ++ .../GenerateExportHeader/exportheader_test.cpp | 138 ++++++++++++-------- .../lib_shared_and_static/libshared_and_static.cpp | 65 +++++---- .../lib_shared_and_static/libshared_and_static.h | 83 +++++++----- .../GenerateExportHeader/libshared/libshared.cpp | 65 +++++---- .../GenerateExportHeader/libshared/libshared.h | 72 ++++++---- .../GenerateExportHeader/libstatic/libstatic.cpp | 68 +++++++--- .../GenerateExportHeader/libstatic/libstatic.h | 76 +++++++---- 12 files changed, 436 insertions(+), 203 deletions(-) create mode 100644 Tests/RunCMake/GenerateExportHeader/GEH-failures.cmake copy Tests/RunCMake/{CMP0060/CMP0060-OLD-Build-result.txt => GenerateExportHeader/GEH-link-error-result.txt} (100%) copy Tests/RunCMake/GenerateExportHeader/{GEH-build-stderr.txt => GEH-link-error-stderr.txt} (100%) hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits