diff --git a/CMakeLists.txt b/CMakeLists.txt index a7411bc..b4c75c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.1) -project(UnitTest++) +cmake_minimum_required(VERSION 3.0) +project(UnitTest++ VERSION 2.1.0) option(UTPP_USE_PLUS_SIGN "Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths" @@ -11,8 +11,16 @@ option(UTPP_AMPLIFY_WARNINGS "Set this to OFF if you wish to use CMake default warning levels; should generally only use to work around support issues for your specific compiler" ON) -if(MSVC14 OR MSVC12) - # has the support we need +set(LIB_SUFFIX "" CACHE STRING "Identifier to add to end of lib directory name e.g. 64 for lib64") + +if (MSVC) + # CHECK_CXX_COMPILER_FLAG could be used + # but MSVC version is preferred for feature requirements + if (MSVC14 OR MSVC12) + # has the support we need + else() + message(STATUS "The MSVC compiler version does not support UnitTest++ C++11 features.") + endif() else() include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) @@ -22,7 +30,7 @@ else() elseif(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") endif() endif() @@ -56,6 +64,8 @@ source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_}) # create the lib add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_}) +add_library(UnitTest++::UnitTest++ ALIAS UnitTest++) + if(${UTPP_USE_PLUS_SIGN}) set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++) @@ -66,13 +76,16 @@ endif() file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h) source_group( "" FILES ${TEST_SRCS}) add_executable(TestUnitTest++ ${TEST_SRCS}) -include_directories(.) + if(${UTPP_USE_PLUS_SIGN}) set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++) endif() -target_link_libraries(TestUnitTest++ UnitTest++) +target_link_libraries(TestUnitTest++ + PUBLIC + UnitTest++::UnitTest++ + ) # run unit tests as post build step add_custom_command(TARGET TestUnitTest++ @@ -92,11 +105,41 @@ else() set (UTPP_INSTALL_DESTINATION "include/UnitTestPP") endif() -set(config_install_dir_ lib/cmake/${PROJECT_NAME}) -set(targets_export_name_ "${PROJECT_NAME}Targets") +target_include_directories( UnitTest++ + PUBLIC + $ + $ + ) +set_target_properties(UnitTest++ PROPERTIES DEBUG_POSTFIX "-d") +set_target_properties(TestUnitTest++ PROPERTIES DEBUG_POSTFIX "-d") -install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib) +set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}) +set(targets_export_name_ "${PROJECT_NAME}Targets") +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + cmake/UnitTest++ConfigVersion.cmake + VERSION ${UnitTest++_VERSION} + COMPATIBILITY SameMajorVersion + ) + +install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX}) install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION}) install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_}) -install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}") -install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}") +install(FILES + cmake/UnitTest++Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake + DESTINATION "${config_install_dir_}") +install(EXPORT "${targets_export_name_}" NAMESPACE "UnitTest++::" DESTINATION "${config_install_dir_}") + +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) +set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) +set(includedir ${CMAKE_INSTALL_PREFIX}/include/UnitTest++) +configure_file("UnitTest++.pc.in" "UnitTest++.pc" @ONLY) +if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig) +else() + set(pkgconfdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig) +endif() +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/UnitTest++.pc" + DESTINATION "${pkgconfdir}") diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/INSTALL b/INSTALL index 6e90e07..6c99c94 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,9 @@ + +Preamble: If you are installing UnitTest++ from source, or from a +release prior to 1.6.1, you will need to have autotools installed and +run `autoreconf -i; autoconf` prior to following the standard +instructions below. + Installation Instructions ************************* diff --git a/README.md b/README.md index 8a49c3d..6ece10e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> ### Maintenance of UnitTest++, recently sporadic, is officially on hiatus until 26 November 2020. Subscribe to https://github.com/unittest-cpp/unittest-cpp/issues/180 for updates. + + [![Build Status](https://travis-ci.org/unittest-cpp/unittest-cpp.svg?branch=master)](https://travis-ci.org/unittest-cpp/unittest-cpp) [![Build status](https://ci.appveyor.com/api/projects/status/ffs2k8dddts5cyok/branch/master?svg=true)](https://ci.appveyor.com/project/pjohnmeyer/unittest-cpp/branch/master) @@ -30,17 +33,17 @@ Via svn: svn checkout https://github.com/unittest-cpp/unittest-cpp/trunk unittest-cpp -### Latest release (v1.6.1) ### +### Latest release (v2.0.0) ### Via git: git clone https://github.com/unittest-cpp/unittest-cpp cd unittest-cpp - git checkout v1.6.1 + git checkout v2.0.0 Via svn: - svn checkout https://github.com/unittest-cpp/unittest-cpp/tags/v1.6.1 unittest-cpp + svn checkout https://github.com/unittest-cpp/unittest-cpp/tags/v2.0.0 unittest-cpp License --------- @@ -77,6 +80,12 @@ Contributors Historic release notes ---------------------- +### Version 2.0.0 (2017-01-13) ### +- Change Check method supporting CHECK macro to accept argument by reference +- Introduce long macro forms (e.g. UNITTEST_CHECK); make short forms optional +- Improved Visual Studio 2015 support +- [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A2.0.0+) + ### Version 1.6.0 (2016-02-29) ### - Add REQUIRE macro to end tests early when selected checks fail - [Full List](https://github.com/unittest-cpp/unittest-cpp/issues?q=milestone%3A1.6.0+) diff --git a/UnitTest++/Config.h b/UnitTest++/Config.h index 4bebf1a..14429ee 100644 --- a/UnitTest++/Config.h +++ b/UnitTest++/Config.h @@ -22,7 +22,7 @@ #if defined(unix) || defined(__unix__) || defined(__unix) || defined(linux) || \ defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) \ - || defined (__HAIKU__) + || defined (__HAIKU__) || defined(_AIX) #define UNITTEST_POSIX #endif diff --git a/UnitTest++/TestMacros.h b/UnitTest++/TestMacros.h index d6bc204..0c8e903 100644 --- a/UnitTest++/TestMacros.h +++ b/UnitTest++/TestMacros.h @@ -25,16 +25,16 @@ } \ namespace Suite ## Name -#define UNITTEST_IMPL_TEST(Name, List) \ +#define UNITTEST_IMPL_TEST(Name, List) \ class Test ## Name : public UnitTest::Test \ { \ public: \ Test ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ private: \ virtual void RunImpl() const; \ - } test ## Name ## Instance; \ + } static test ## Name ## Instance; \ \ - UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \ + static UnitTest::ListAdder adder ## Name (List, &test ## Name ## Instance); \ \ void Test ## Name::RunImpl() const @@ -49,10 +49,12 @@ explicit Fixture ## Name ## Helper(UnitTest::TestDetails const& details) : m_details(details) {} \ void RunImpl(); \ UnitTest::TestDetails const& m_details; \ + virtual ~Fixture ## Name ## Helper(); \ private: \ Fixture ## Name ## Helper(Fixture ## Name ## Helper const&); \ Fixture ## Name ## Helper& operator =(Fixture ## Name ## Helper const&); \ }; \ + Fixture ## Name ## Helper::~Fixture ## Name ## Helper(){} \ \ class Test ## Fixture ## Name : public UnitTest::Test \ { \ @@ -60,9 +62,9 @@ Test ## Fixture ## Name() : Test(#Name, UnitTestSuite::GetSuiteName(), __FILE__, __LINE__) {} \ private: \ virtual void RunImpl() const; \ - } test ## Fixture ## Name ## Instance; \ + } static test ## Fixture ## Name ## Instance; \ \ - UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ + static UnitTest::ListAdder adder ## Fixture ## Name (List, &test ## Fixture ## Name ## Instance); \ \ void Test ## Fixture ## Name::RunImpl() const \ { \ diff --git a/appveyor.yml b/appveyor.yml index 71e4398..3a4637d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.6.1.{build} +version: 2.1.0.{build} os: - Windows Server 2012 R2 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..347366d --- /dev/null +++ b/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +test -e ./.autotools_aux || mkdir .autotools_aux + +libtoolize -cq +aclocal -I m4 --install # Generate aclocal +autoconf # Generate configure script +autoheader # Generate config.h +automake --add-missing --copy # Generate Makefile.in and other scripts diff --git a/configure.ac b/configure.ac index 6b81131..372f576 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ AM_CONDITIONAL([WINDOWS], LT_INIT() -AC_SUBST([LIBUNITTEST_SO_VERSION], [1:6:0]) +AC_SUBST([LIBUNITTEST_SO_VERSION], [2:1:0]) # Checks for programs. AC_PROG_CXX diff --git a/docs b/docs index 14495a3..a6963b7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 14495a3a81568e9ce187231b629e4eb7bc7e0350 +Subproject commit a6963b798400df760e148a6e15e9c13db965a3ec diff --git a/tests/TestTest.cpp b/tests/TestTest.cpp index 5a4e1ca..0db0650 100644 --- a/tests/TestTest.cpp +++ b/tests/TestTest.cpp @@ -72,7 +72,7 @@ namespace { CHECK_EQUAL(1, results.GetFailureCount()); } -#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) +#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) && !defined(__clang__) // Skip this test in debug because some debuggers don't like it. #if defined(NDEBUG) TEST(CrashingTestsAreReportedAsFailures)