summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2011-09-07 19:38:00 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2011-09-07 19:38:00 (GMT)
commit54730d7604a69975e66047c3b5f406df89a4ade5 (patch)
tree28b2bf8f96120f5e5ec4a0bea2de8f60995ff770
parent2ea27a54d97c72870ed69c9bde17826faf87f6d3 (diff)
parentdbd776dde7710a0bf1af1ca9c3554d9025502a31 (diff)
downloadCMake-54730d7604a69975e66047c3b5f406df89a4ade5.zip
CMake-54730d7604a69975e66047c3b5f406df89a4ade5.tar.gz
CMake-54730d7604a69975e66047c3b5f406df89a4ade5.tar.bz2
Merge topic 'generate_export_header'
dbd776d Don't put what some compilers consider junk at the end of the line. 93d8d19 Add some more unit tests.
-rw-r--r--Modules/exportheader.cmake.in2
-rw-r--r--Tests/Module/GenerateExportHeader/CMakeLists.txt2
-rw-r--r--Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt26
-rw-r--r--Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in15
-rw-r--r--Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp9
-rw-r--r--Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h10
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt15
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/main.cpp8
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp7
-rw-r--r--Tests/Module/GenerateExportHeader/prefix/useprefixclass.h13
11 files changed, 115 insertions, 1 deletions
diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in
index 131d3a7..80a879d 100644
--- a/Modules/exportheader.cmake.in
+++ b/Modules/exportheader.cmake.in
@@ -32,4 +32,4 @@
# define @NO_DEPRECATED_MACRO_NAME@
#endif
-#endif // @INCLUDE_GUARD_NAME@
+#endif
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index fee836e..3edb548 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -152,6 +152,8 @@ add_subdirectory(lib_shared_and_static)
add_subdirectory(lib_shared_and_statictest)
add_subdirectory(override_symbol)
+add_subdirectory(nodeprecated)
+add_subdirectory(prefix)
if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))
# We deliberately call deprecated methods, and test for that elsewhere.
diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt
new file mode 100644
index 0000000..aeeb13a
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(nodeprecated)
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined)
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined)
+
+configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined/CMakeLists.txt)
+set(DEFINE_NO_DEPRECATED DEFINE_NO_DEPRECATED)
+configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined/CMakeLists.txt)
+
+try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined_build
+ ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined
+ nodeprecated_test
+ OUTPUT_VARIABLE Out
+)
+
+test_pass(Result "Failed to build without no-deprecated define")
+
+try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build
+ ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined
+ nodeprecated_test
+ OUTPUT_VARIABLE Out
+)
+
+test_fail(Result "Built even with no-deprecated define") \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in
new file mode 100644
index 0000000..d8dc482
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(nodeprecated_test)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+include(GenerateExportHeader)
+
+add_library(nodeprecatedlib SHARED someclass.cpp)
+
+generate_export_header(nodeprecatedlib @DEFINE_NO_DEPRECATED@)
+
+add_executable(nodeprecatedconsumer main.cpp)
+
+target_link_libraries(nodeprecatedconsumer nodeprecatedlib)
diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp
new file mode 100644
index 0000000..445a652
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/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/nodeprecated/src/someclass.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp
new file mode 100644
index 0000000..a3f4111
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp
@@ -0,0 +1,9 @@
+
+#include "someclass.h"
+
+#ifndef NODEPRECATEDLIB_NO_DEPRECATED
+void SomeClass::someMethod() const
+{
+
+}
+#endif
diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h
new file mode 100644
index 0000000..312a177
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h
@@ -0,0 +1,10 @@
+
+#include "nodeprecatedlib_export.h"
+
+class NODEPRECATEDLIB_EXPORT SomeClass
+{
+public:
+#ifndef NODEPRECATEDLIB_NO_DEPRECATED
+ void someMethod() const;
+#endif
+};
diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt
new file mode 100644
index 0000000..bd64df2
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt
@@ -0,0 +1,15 @@
+project(use_prefix)
+
+set(use_prefix_lib_SRCS
+ useprefixclass.cpp
+)
+
+add_library(use_prefix_lib SHARED useprefixclass.cpp)
+
+generate_export_header(use_prefix_lib
+ PREFIX_NAME MYPREFIX_
+)
+
+add_executable(use_prefix main.cpp)
+
+target_link_libraries(use_prefix use_prefix_lib) \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp
new file mode 100644
index 0000000..d04ae3c
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/prefix/main.cpp
@@ -0,0 +1,8 @@
+
+#include "useprefixclass.h"
+
+int main(int argc, char **argv)
+{
+ UsePrefixClass upc;
+ return upc.someMethod();
+} \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp
new file mode 100644
index 0000000..8337ab8
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp
@@ -0,0 +1,7 @@
+
+#include "useprefixclass.h"
+
+int UsePrefixClass::someMethod() const
+{
+ return 0;
+} \ No newline at end of file
diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h
new file mode 100644
index 0000000..f5e31b5
--- /dev/null
+++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h
@@ -0,0 +1,13 @@
+
+#ifndef USEPREFIXCLASS_H
+#define USEPREFIXCLASS_H
+
+#include "use_prefix_lib_export.h"
+
+class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass
+{
+public:
+ int someMethod() const;
+};
+
+#endif