summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt4
-rw-r--r--Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt74
-rw-r--r--Tests/Module/GenerateExportHeader/CMakeLists.txt168
-rw-r--r--Tests/Module/GenerateExportHeader/exportheader_test.cpp82
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt12
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp91
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h54
-rw-r--r--Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt33
-rw-r--r--Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt6
-rw-r--r--Tests/Module/GenerateExportHeader/libshared/libshared.cpp91
-rw-r--r--Tests/Module/GenerateExportHeader/libshared/libshared.h54
-rw-r--r--Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt44
-rw-r--r--Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt8
-rw-r--r--Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp87
-rw-r--r--Tests/Module/GenerateExportHeader/libstatic/libstatic.h54
-rw-r--r--Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt18
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt11
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/main.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/override_symbol/someclass.h8
20 files changed, 915 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 46b3c15..9f4e8a3 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -228,6 +228,10 @@ IF(BUILD_TESTING)
ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
+ ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
+
+ ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag)
+
ADD_TEST(LinkFlags-prepare
${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
--build-and-test
diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt
new file mode 100644
index 0000000..77f5006
--- /dev/null
+++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt
@@ -0,0 +1,74 @@
+cmake_minimum_required(VERSION 2.8)
+project(CheckCXXCompilerFlag)
+
+message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
+set(CMAKE_VERBOSE_MAKEFILE 1)
+
+macro(TEST_FAIL value msg)
+ if (${value})
+ message (SEND_ERROR "Test fail:" ${msg} ${Out} )
+ endif ()
+endmacro()
+
+macro(TEST_PASS value msg)
+ if (NOT ${value})
+ message (SEND_ERROR "Test fail:" ${msg} ${Out} )
+ endif ()
+endmacro()
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
+ string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
+ # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the
+ # patch level, handle this here:
+ if(NOT _gcc_version)
+ string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}")
+ endif()
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
+ exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info)
+ string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}")
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
+ exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info)
+ string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}")
+endif()
+
+message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n"
+ " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n"
+ " GCC: ${_gcc_version}\n"
+ " Clang: ${_clang_version}\n"
+ " Intel: ${_intel_version}\n"
+)
+
+include(CheckCXXCompilerFlag)
+
+check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY)
+
+message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}")
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ if(NOT WIN32)
+# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.")
+ endif()
+else()
+ message("Unhandled Platform")
+endif()
+
+#
+# This is a no-op executable... If this test is going to fail, it fails during
+# the configure step while cmake is configuring this CMakeLists.txt file...
+#
+
+file(WRITE
+ "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+ "int main() { return 0; }
+"
+)
+
+add_executable(
+ CheckCXXCompilerFlag
+ "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+)
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
new file mode 100644
index 0000000..fee836e
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -0,0 +1,168 @@
+cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
+
+project(GenerateExportHeader)
+
+# Prevent timeout on Watcom by not running the tests.
+if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom)
+ file(WRITE
+ "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+ "int main() { return 0; }
+ "
+ )
+
+ add_executable(
+ GenerateExportHeader
+ "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
+ )
+ return()
+endif()
+
+include(CheckCXXCompilerFlag)
+
+set( CMAKE_INCLUDE_CURRENT_DIR ON )
+
+macro(TEST_FAIL value msg)
+ if (${value})
+ message (SEND_ERROR "Test fail:" ${msg} ${Out} )
+ endif ()
+endmacro()
+
+macro(TEST_PASS value msg)
+ if (NOT ${value})
+ message (SEND_ERROR "Test fail:" ${msg} ${Out} )
+ endif ()
+endmacro()
+
+check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG)
+
+if(HAS_WERROR_FLAG)
+ set(ERROR_FLAG "-Werror")
+else()
+ # MSVC
+ # And intel on windows?
+ # http://software.intel.com/en-us/articles/how-to-handle-warnings-message-in-compiler/?wapkw=%28compiler+warning+message%29
+ check_cxx_compiler_flag("/WX" HAS_WX_FLAG)
+ if(HAS_WX_FLAG)
+ set(ERROR_FLAG "/WX")
+ else()
+ # Sun CC
+ # http://www.acsu.buffalo.edu/~charngda/sunstudio.html
+ check_cxx_compiler_flag("-errwarn=%all" HAS_ERRWARN_ALL)
+ if (HAS_ERRWARN_ALL)
+ set(ERROR_FLAG "-errwarn=%all")
+ else()
+ endif()
+ endif()
+endif()
+
+
+# We seem to get race conditions is writing this stuff to the same file at least on MinGW
+# So to write to separate source and build directories, we use a count to differentiate.
+set (COUNT 0)
+macro(_do_build Include Library LibrarySource Source)
+
+ math(EXPR COUNT "${COUNT} + 1" )
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n"
+ "int main() { ${Source}; }\n"
+ )
+
+ file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../${LibrarySource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}")
+
+ if ("${Library}" STREQUAL "static_variant")
+ set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n")
+ endif()
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt"
+ "cmake_minimum_required(VERSION 2.8)\n"
+
+ "project(compiletest)\n"
+
+ "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n"
+
+ "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n"
+
+ "include(GenerateExportHeader)\n"
+
+ "add_compiler_export_flags()\n"
+
+ "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n"
+ " add_definitions(${ERROR_FLAG})\n"
+ "endif()\n"
+
+ "if(MSVC)\n"
+ " add_definitions(-DCOMPILER_IS_MSVC)\n"
+ "endif()\n"
+
+ "add_subdirectory(\"${LibrarySource}\")\n"
+
+ "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n"
+
+ "${CONDITIONAL_STATIC_DEFINE}"
+
+ "add_executable(compiletest src.cpp)\n"
+ "target_link_libraries(compiletest ${Library})\n"
+ )
+
+ try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT}
+ ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}
+ compiletest
+ OUTPUT_VARIABLE Out
+ )
+endmacro()
+
+macro(build_fail Include Library LibrarySource Source Message)
+ _do_build(${Include} ${Library} ${LibrarySource} "${Source}")
+ test_fail(Result ${Message})
+endmacro()
+
+macro(build_pass Include Library LibrarySource Source Message)
+ _do_build(${Include} ${Library} ${LibrarySource} "${Source}")
+ test_pass(Result ${Message})
+endmacro()
+
+include(GenerateExportHeader)
+
+add_compiler_export_flags()
+
+if (MSVC)
+ add_definitions(-DCOMPILER_IS_MSVC)
+endif()
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+
+message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED})
+message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY})
+message("#### WIN32: " ${WIN32})
+message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG})
+
+set(link_libraries)
+macro(macro_add_test_library name)
+ add_subdirectory(${name})
+ include_directories(${name}
+ ${${name}_BINARY_DIR} # For the export header.
+ )
+ list(APPEND link_libraries ${name})
+ add_subdirectory(${name}test)
+endmacro()
+
+macro_add_test_library(libshared)
+macro_add_test_library(libstatic)
+add_subdirectory(lib_shared_and_static)
+add_subdirectory(lib_shared_and_statictest)
+
+add_subdirectory(override_symbol)
+
+if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
+ # We deliberately call deprecated methods, and test for that elsewhere.
+ # No need to clutter the test output with warnings.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
+endif()
+
+if(MSVC AND COMPILER_HAS_DEPRECATED)
+ add_definitions(/wd4996)
+endif()
+
+add_executable(GenerateExportHeader exportheader_test.cpp)
+
+target_link_libraries(GenerateExportHeader ${link_libraries})
diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
new file mode 100644
index 0000000..55c3c1a
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
@@ -0,0 +1,82 @@
+
+#include "libshared.h"
+
+#include "libstatic.h"
+
+// #define BUILD_FAIL
+
+#ifndef BUILD_FAIL
+#define DOES_NOT_BUILD(function)
+#else
+#define DOES_NOT_BUILD(function) function
+#endif
+
+int main()
+{
+ {
+ Libshared l;
+ l.libshared();
+ l.libshared_exported();
+ l.libshared_deprecated();
+ l.libshared_not_exported();
+
+ DOES_NOT_BUILD(l.libshared_excluded();)
+ }
+
+ {
+ LibsharedNotExported l;
+ DOES_NOT_BUILD(l.libshared();)
+ l.libshared_exported();
+ l.libshared_deprecated();
+ DOES_NOT_BUILD(l.libshared_not_exported();)
+ DOES_NOT_BUILD(l.libshared_excluded();)
+ }
+
+ {
+ LibsharedExcluded l;
+ DOES_NOT_BUILD(l.libshared();)
+ l.libshared_exported();
+ l.libshared_deprecated();
+ DOES_NOT_BUILD(l.libshared_not_exported();)
+ DOES_NOT_BUILD(l.libshared_excluded();)
+ }
+
+ libshared_exported();
+ libshared_deprecated();
+ DOES_NOT_BUILD(libshared_not_exported();)
+ DOES_NOT_BUILD(libshared_excluded();)
+
+ {
+ Libstatic l;
+ l.libstatic();
+ l.libstatic_exported();
+ l.libstatic_deprecated();
+ l.libstatic_not_exported();
+ l.libstatic_excluded();
+ }
+
+ {
+ LibstaticNotExported l;
+ l.libstatic();
+ l.libstatic_exported();
+ l.libstatic_deprecated();
+ l.libstatic_not_exported();
+ l.libstatic_excluded();
+ }
+
+ {
+ LibstaticExcluded l;
+ l.libstatic();
+ l.libstatic_exported();
+ l.libstatic_deprecated();
+ l.libstatic_not_exported();
+ l.libstatic_excluded();
+ }
+
+ libstatic_exported();
+ libstatic_deprecated();
+ libstatic_not_exported();
+ libstatic_excluded();
+
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt
new file mode 100644
index 0000000..d19b6dc
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(shared_and_static)
+
+set(lib_SRCS
+ libshared_and_static.cpp
+)
+
+add_library(shared_variant SHARED ${lib_SRCS})
+add_library(static_variant ${lib_SRCS})
+
+generate_export_header(shared_variant BASE_NAME libshared_and_static)
+
+set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
new file mode 100644
index 0000000..1e07273
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
@@ -0,0 +1,91 @@
+
+#include "libshared_and_static.h"
+
+int LibsharedAndStatic::libshared_and_static() const
+{
+ return 0;
+}
+
+int LibsharedAndStatic::libshared_and_static_exported() const
+{
+ return 0;
+}
+
+int LibsharedAndStatic::libshared_and_static_deprecated() const
+{
+ return 0;
+}
+
+int LibsharedAndStatic::libshared_and_static_not_exported() const {
+ return 0;
+}
+
+int LibsharedAndStatic::libshared_and_static_excluded() const {
+ return 0;
+}
+
+int LibsharedAndStaticNotExported::libshared_and_static() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticNotExported::libshared_and_static_exported() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const {
+ return 0;
+}
+
+int LibsharedAndStaticNotExported::libshared_and_static_excluded() const {
+ return 0;
+}
+
+int LibsharedAndStaticExcluded::libshared_and_static() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticExcluded::libshared_and_static_exported() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const
+{
+ return 0;
+}
+
+int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const {
+ return 0;
+}
+
+int LibsharedAndStaticExcluded::libshared_and_static_excluded() const {
+ return 0;
+}
+
+int libshared_and_static() {
+ return 0;
+}
+
+int libshared_and_static_exported() {
+ return 0;
+}
+
+int libshared_and_static_deprecated() {
+ return 0;
+}
+
+int libshared_and_static_not_exported() {
+ return 0;
+}
+
+int libshared_and_static_excluded() {
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
new file mode 100644
index 0000000..049bfe9
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h
@@ -0,0 +1,54 @@
+
+#ifndef SHARED_AND_STATIC_H
+#define SHARED_AND_STATIC_H
+
+#include "libshared_and_static_export.h"
+
+class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
+public:
+ int libshared_and_static() const;
+
+ int libshared_and_static_exported() const;
+
+ int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+
+ int libshared_and_static_not_exported() const;
+
+ int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+};
+
+class LibsharedAndStaticNotExported {
+public:
+ int libshared_and_static() const;
+
+ int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+
+ int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+
+ int libshared_and_static_not_exported() const;
+
+ int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+};
+
+class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
+public:
+ int libshared_and_static() const;
+
+ int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
+
+ int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
+
+ int libshared_and_static_not_exported() const;
+
+ int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
+};
+
+LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
+
+LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
+
+int libshared_and_static_not_exported();
+
+int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt
new file mode 100644
index 0000000..207534d
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt
@@ -0,0 +1,33 @@
+
+macro(shared_variant_build_pass Source Message)
+ build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message})
+endmacro()
+
+macro(shared_variant_build_fail Source Message)
+ build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message})
+endmacro()
+
+macro(static_variant_build_pass Source Message)
+ build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message})
+endmacro()
+
+macro(static_variant_build_fail Source Message)
+ build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message})
+endmacro()
+
+static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant")
+shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant")
+# if (COMPILER_HAS_DEPRECATED)
+# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant")
+# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant")
+# else()
+# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant")
+# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant")
+# endif()
+static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant")
+
+if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY)
+ shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant")
+else()
+ shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant")
+endif()
diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt
new file mode 100644
index 0000000..8e4ee2b
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+project(libshared)
+
+add_library(libshared SHARED libshared.cpp)
+
+generate_export_header(libshared)
diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp
new file mode 100644
index 0000000..d4041b3
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp
@@ -0,0 +1,91 @@
+
+#include "libshared.h"
+
+int Libshared::libshared() const
+{
+ return 0;
+}
+
+int Libshared::libshared_exported() const
+{
+ return 0;
+}
+
+int Libshared::libshared_deprecated() const
+{
+ return 0;
+}
+
+int Libshared::libshared_not_exported() const {
+ return 0;
+}
+
+int Libshared::libshared_excluded() const {
+ return 0;
+}
+
+int LibsharedNotExported::libshared() const
+{
+ return 0;
+}
+
+int LibsharedNotExported::libshared_exported() const
+{
+ return 0;
+}
+
+int LibsharedNotExported::libshared_deprecated() const
+{
+ return 0;
+}
+
+int LibsharedNotExported::libshared_not_exported() const {
+ return 0;
+}
+
+int LibsharedNotExported::libshared_excluded() const {
+ return 0;
+}
+
+int LibsharedExcluded::libshared() const
+{
+ return 0;
+}
+
+int LibsharedExcluded::libshared_exported() const
+{
+ return 0;
+}
+
+int LibsharedExcluded::libshared_deprecated() const
+{
+ return 0;
+}
+
+int LibsharedExcluded::libshared_not_exported() const {
+ return 0;
+}
+
+int LibsharedExcluded::libshared_excluded() const {
+ return 0;
+}
+
+int libshared() {
+ return 0;
+}
+
+int libshared_exported() {
+ return 0;
+}
+
+int libshared_deprecated() {
+ return 0;
+}
+
+int libshared_not_exported() {
+ return 0;
+}
+
+int libshared_excluded() {
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h
new file mode 100644
index 0000000..3d9bbff
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h
@@ -0,0 +1,54 @@
+
+#ifndef LIBSHARED_H
+#define LIBSHARED_H
+
+#include "libshared_export.h"
+
+class LIBSHARED_EXPORT Libshared {
+public:
+ int libshared() const;
+
+ int libshared_exported() const;
+
+ int LIBSHARED_DEPRECATED libshared_deprecated() const;
+
+ int libshared_not_exported() const;
+
+ int LIBSHARED_NO_EXPORT libshared_excluded() const;
+};
+
+class LibsharedNotExported {
+public:
+ int libshared() const;
+
+ int LIBSHARED_EXPORT libshared_exported() const;
+
+ int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const;
+
+ int libshared_not_exported() const;
+
+ int LIBSHARED_NO_EXPORT libshared_excluded() const;
+};
+
+class LIBSHARED_NO_EXPORT LibsharedExcluded {
+public:
+ int libshared() const;
+
+ int LIBSHARED_EXPORT libshared_exported() const;
+
+ int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const;
+
+ int libshared_not_exported() const;
+
+ int LIBSHARED_NO_EXPORT libshared_excluded() const;
+};
+
+LIBSHARED_EXPORT int libshared_exported();
+
+LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated();
+
+int libshared_not_exported();
+
+int LIBSHARED_NO_EXPORT libshared_excluded();
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt
new file mode 100644
index 0000000..a5804fc
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt
@@ -0,0 +1,44 @@
+
+macro(shared_build_pass Source Message)
+ build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message})
+endmacro()
+
+macro(shared_build_fail Source Message)
+ build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message})
+endmacro()
+
+shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported")
+
+# if (COMPILER_HAS_DEPRECATED)
+# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.")
+# else()
+# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.")
+# endif()
+if (COMPILER_HAS_HIDDEN_VISIBILITY)
+ shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.")
+else()
+ # There is no MSVC equivalent to hiding symbols.
+ shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.")
+endif()
+
+if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY)
+ shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.")
+ shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.")
+ shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.")
+ shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.")
+ shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.")
+ shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.")
+
+ shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.")
+ shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.")
+else()
+ shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.")
+ shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.")
+ shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.")
+ shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.")
+ shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.")
+ shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.")
+
+ shared_build_pass("return libshared_excluded();" "Built use of excluded function.")
+ shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.")
+endif()
diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt
new file mode 100644
index 0000000..8db1827
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+project(libstatic)
+
+# Show that the export header has no effect on a static library.
+
+add_library(libstatic STATIC libstatic.cpp)
+
+generate_export_header(libstatic)
diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp
new file mode 100644
index 0000000..0710c3e
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp
@@ -0,0 +1,87 @@
+
+#include "libstatic.h"
+
+int Libstatic::libstatic() const
+{
+ return 0;
+}
+
+int Libstatic::libstatic_exported() const
+{
+ return 0;
+}
+
+int Libstatic::libstatic_deprecated() const
+{
+ return 0;
+}
+
+int Libstatic::libstatic_not_exported() const {
+ return 0;
+}
+
+int Libstatic::libstatic_excluded() const {
+ return 0;
+}
+
+int LibstaticNotExported::libstatic() const
+{
+ return 0;
+}
+
+int LibstaticNotExported::libstatic_exported() const
+{
+ return 0;
+}
+
+int LibstaticNotExported::libstatic_deprecated() const
+{
+ return 0;
+}
+
+int LibstaticNotExported::libstatic_not_exported() const {
+ return 0;
+}
+
+int LibstaticNotExported::libstatic_excluded() const {
+ return 0;
+}
+
+int LibstaticExcluded::libstatic() const
+{
+ return 0;
+}
+
+int LibstaticExcluded::libstatic_exported() const
+{
+ return 0;
+}
+
+int LibstaticExcluded::libstatic_deprecated() const
+{
+ return 0;
+}
+
+int LibstaticExcluded::libstatic_not_exported() const {
+ return 0;
+}
+
+int LibstaticExcluded::libstatic_excluded() const {
+ return 0;
+}
+
+int libstatic_exported() {
+ return 0;
+}
+
+int libstatic_deprecated() {
+ return 0;
+}
+
+int libstatic_not_exported() {
+ return 0;
+}
+
+int libstatic_excluded() {
+ return 0;
+}
diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h
new file mode 100644
index 0000000..cc7a35b
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h
@@ -0,0 +1,54 @@
+
+#ifndef LIBSTATIC_H
+#define LIBSTATIC_H
+
+#include "libstatic_export.h"
+
+class LIBSTATIC_EXPORT Libstatic {
+public:
+ int libstatic() const;
+
+ int libstatic_exported() const;
+
+ int LIBSTATIC_DEPRECATED libstatic_deprecated() const;
+
+ int libstatic_not_exported() const;
+
+ int LIBSTATIC_NO_EXPORT libstatic_excluded() const;
+};
+
+class LibstaticNotExported {
+public:
+ int libstatic() const;
+
+ int LIBSTATIC_EXPORT libstatic_exported() const;
+
+ int LIBSTATIC_DEPRECATED libstatic_deprecated() const;
+
+ int libstatic_not_exported() const;
+
+ int LIBSTATIC_NO_EXPORT libstatic_excluded() const;
+};
+
+class LIBSTATIC_NO_EXPORT LibstaticExcluded {
+public:
+ int libstatic() const;
+
+ int LIBSTATIC_EXPORT libstatic_exported() const;
+
+ int LIBSTATIC_DEPRECATED libstatic_deprecated() const;
+
+ int libstatic_not_exported() const;
+
+ int LIBSTATIC_NO_EXPORT libstatic_excluded() const;
+};
+
+LIBSTATIC_EXPORT int libstatic_exported();
+
+LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated();
+
+int libstatic_not_exported();
+
+int LIBSTATIC_NO_EXPORT libstatic_excluded();
+
+#endif
diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt
new file mode 100644
index 0000000..eb6bb87
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt
@@ -0,0 +1,18 @@
+
+macro(static_build_pass Source Message)
+ build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message})
+endmacro()
+
+macro(static_build_fail Source Message)
+ build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message})
+endmacro()
+
+static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.")
+
+# if (COMPILER_HAS_DEPRECATED)
+# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.")
+# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.")
+# else()
+# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.")
+# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.")
+# endif()
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt
new file mode 100644
index 0000000..aeeef20
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt
@@ -0,0 +1,11 @@
+project(override_symbol)
+
+add_library(somelib SHARED someclass.cpp)
+
+set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL)
+
+generate_export_header(somelib)
+
+add_executable(consumer main.cpp)
+
+target_link_libraries(consumer somelib)
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp
new file mode 100644
index 0000000..445a652
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp
@@ -0,0 +1,9 @@
+
+#include "someclass.h"
+
+int main(int, char**)
+{
+ SomeClass sc;
+ sc.someMethod();
+ return 0;
+} \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp
new file mode 100644
index 0000000..7326b78
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp
@@ -0,0 +1,7 @@
+
+#include "someclass.h"
+
+void SomeClass::someMethod() const
+{
+
+} \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h
new file mode 100644
index 0000000..ae5e844
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h
@@ -0,0 +1,8 @@
+
+#include "somelib_export.h"
+
+class SOMELIB_EXPORT SomeClass
+{
+public:
+ void someMethod() const;
+};