diff options
author | Stephen Kelly <steveire@gmail.com> | 2011-08-25 17:01:04 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2011-09-02 08:18:24 (GMT) |
commit | 93d8d1992ed94225bb0a5706f0a294524913dccc (patch) | |
tree | cb1850d6a828c6d8bebe02b8b53755f7e5db088b /Tests/Module | |
parent | 83ce7c4d3cbc8b4277e815f861456ea6f7ec18e3 (diff) | |
download | CMake-93d8d1992ed94225bb0a5706f0a294524913dccc.zip CMake-93d8d1992ed94225bb0a5706f0a294524913dccc.tar.gz CMake-93d8d1992ed94225bb0a5706f0a294524913dccc.tar.bz2 |
Add some more unit tests.
Diffstat (limited to 'Tests/Module')
10 files changed, 114 insertions, 0 deletions
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 |