From 1d3ad6faa22a040bc6bb15727b9783ae2f547a02 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 27 Apr 2014 12:25:03 -0700 Subject: [PATCH] Added Testing capability --- CMakeLists.txt | 7 ++++++- lib/polarssl.cmake | 6 +++++- tests/CMakeLists.txt | 5 +++++ tests/ChunkBuffer/CMakeLists.txt | 10 ++++++++++ tests/ChunkBuffer/creatable.cpp | 4 ++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/ChunkBuffer/CMakeLists.txt create mode 100644 tests/ChunkBuffer/creatable.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a860920c..45fc8c37a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.2) # Without this, the MSVC variable isn't defined for MSVC builds ( http://www.cmake.org/pipermail/cmake/2011-November/047130.html ) enable_language(CXX C) @@ -69,3 +69,8 @@ set_exe_flags() add_subdirectory (src) +if(${SELF_TEST}) + enable_testing() + add_subdirectory (tests) +endif() + diff --git a/lib/polarssl.cmake b/lib/polarssl.cmake index d57cc9220..2a58e54c5 100644 --- a/lib/polarssl.cmake +++ b/lib/polarssl.cmake @@ -1,5 +1,9 @@ if(NOT TARGET polarssl) message("including polarssl") - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl EXCLUDE_FROM_ALL ) + if (SELF_TEST) + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl) + else() + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/polarssl/ ${CMAKE_CURRENT_BINARY_DIR}/lib/polarssl EXCLUDE_FROM_ALL) + endif() endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..c2f9ceb5a --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +add_subdirectory(ChunkBuffer) diff --git a/tests/ChunkBuffer/CMakeLists.txt b/tests/ChunkBuffer/CMakeLists.txt new file mode 100644 index 000000000..33722f785 --- /dev/null +++ b/tests/ChunkBuffer/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkBuffer.cpp) + + +add_executable(creatable-exe creatable.cpp) +target_link_libraries(creatable-exe ChunkBuffer) +add_test(NAME creatable-test COMMAND creatable-exe) diff --git a/tests/ChunkBuffer/creatable.cpp b/tests/ChunkBuffer/creatable.cpp new file mode 100644 index 000000000..573f09de9 --- /dev/null +++ b/tests/ChunkBuffer/creatable.cpp @@ -0,0 +1,4 @@ +int main(int argc, char** argv) +{ +return 0; +}