Skip to content

Commit c13d247

Browse files
committed
Merge pull request #34 from pjohnmeyer/version1.4CompatibilityFixes
Address multiple version 1.4 incompatibilities
2 parents 57e049c + c23eddd commit c13d247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+134
-97
lines changed

CMakeLists.txt

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
cmake_minimum_required(VERSION 2.8.1)
22
project(UnitTest++)
33

4+
option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON)
5+
46
# get the main sources
5-
file(GLOB SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp src/*.h)
6-
source_group("" FILES ${SRCS})
7+
file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
8+
file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)
9+
source_group("" FILES ${headers_} ${sources_})
710

811
# get platform specific sources
912
if (WIN32)
10-
set(PLAT_DIR Win32)
13+
set(platformDir_ Win32)
1114
else()
12-
set(PLAT_DIR Posix)
15+
set(platformDir_ Posix)
1316
endif(WIN32)
14-
file(GLOB PLAT_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/${PLAT_DIR}/*.cpp src/${PLAT_DIR}/*.h)
15-
source_group(${PLAT_DIR} FILES ${PLAT_SRCS})
17+
18+
file(GLOB platformHeaders_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.h)
19+
file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.cpp)
20+
source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
1621

1722
# create the lib
18-
add_library(UnitTestPP STATIC ${SRCS} ${PLAT_SRCS})
19-
set_target_properties(UnitTestPP PROPERTIES OUTPUT_NAME UnitTest++)
20-
include_directories(src)
23+
add_library(UnitTestPP STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
24+
25+
if(${UTPP_USE_PLUS_SIGN})
26+
set_target_properties(UnitTestPP PROPERTIES OUTPUT_NAME UnitTest++)
27+
endif()
28+
2129

2230
# build the test runner
23-
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/tests/*.cpp src/tests/*.h)
31+
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
2432
source_group( "" FILES ${TEST_SRCS})
2533
add_executable(TestUnitTestPP ${TEST_SRCS})
26-
set_target_properties(TestUnitTestPP PROPERTIES OUTPUT_NAME TestUnitTest++)
34+
include_directories(.)
35+
36+
if(${UTPP_USE_PLUS_SIGN})
37+
set_target_properties(TestUnitTestPP PROPERTIES OUTPUT_NAME TestUnitTest++)
38+
endif()
39+
2740
target_link_libraries(TestUnitTestPP UnitTestPP)
2841

2942
# turn on testing
@@ -33,3 +46,17 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V)
3346
# add the test runner as a test
3447
add_test(NAME TestUnitTestPP COMMAND TestUnitTest++ ${CONFIG_PATH} ${CONFIG_TASKS_PATH} ${SOUND_LOG_PATH})
3548
add_dependencies(check TestUnitTestPP)
49+
50+
51+
# add install targets
52+
# need a custom install path?
53+
# define CMAKE_INSTALL_PREFIX to change root folder
54+
if(${UTPP_USE_PLUS_SIGN})
55+
set (UTPP_INSTALL_DESTINATION "include/UnitTest++")
56+
else()
57+
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
58+
endif()
59+
60+
install(TARGETS UnitTestPP DESTINATION lib)
61+
install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
62+
install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})
File renamed without changes.

src/AssertException.h renamed to UnitTest++/AssertException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef UNITTEST_ASSERTEXCEPTION_H
22
#define UNITTEST_ASSERTEXCEPTION_H
33

4-
#include "../config.h"
4+
#include "Config.h"
55
#ifndef UNITTEST_NO_EXCEPTIONS
66

77
#include "HelperMacros.h"
File renamed without changes.
File renamed without changes.

src/Checks.h renamed to UnitTest++/Checks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef UNITTEST_CHECKS_H
22
#define UNITTEST_CHECKS_H
33

4-
#include "../config.h"
4+
#include "Config.h"
55
#include "TestResults.h"
66
#include "MemoryOutStream.h"
77

File renamed without changes.
File renamed without changes.

config.h renamed to UnitTest++/Config.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@
2828
#endif
2929

3030

31-
// MemoryOutStream is a custom reimplementation of parts of std::ostringstream.
32-
// Uncomment this line to have MemoryOutStream implemented in terms of std::ostringstream.
31+
// By default, MemoryOutStream is implemented in terms of std::ostringstream.
3332
// This is useful if you are using the CHECK macros on objects that have something like this defined:
3433
// std::ostringstream& operator<<(std::ostringstream& s, const YourObject& value)
35-
36-
//#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
37-
34+
//
35+
// On the other hand, it can be more expensive.
36+
// Un-comment this line to use the custom MemoryOutStream (no deps on std::ostringstream).
37+
38+
// #define UNITTEST_USE_CUSTOM_STREAMS
39+
40+
// Developer note: This dual-macro setup is to preserve compatibility with UnitTest++ 1.4 users
41+
// who may have used or defined UNITTEST_USE_CUSTOM_STREAMS outside of this configuration file, as
42+
// well as Google Code HEAD users that may have used or defined
43+
// UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM outside of this configuration file.
44+
#ifndef UNITTEST_USE_CUSTOM_STREAMS
45+
#define UNITTEST_MEMORYOUTSTREAM_IS_STD_OSTRINGSTREAM
46+
#endif
3847

3948
// DeferredTestReporter uses the STL to collect test results for subsequent export by reporters like
4049
// XmlTestReporter. If you don't want to use this functionality, uncomment this line and no STL
File renamed without changes.

0 commit comments

Comments
 (0)