8000 Merge pull request #173 from dhuantes/install-improvements · unittest-cpp/unittest-cpp@0ea55a2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ea55a2

Browse files
authored
Merge pull request #173 from dhuantes/install-improvements
UnitTest++ now correctly supports CMake's find_package config mode
2 parents d355e12 + f871471 commit 0ea55a2

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

CMakeLists.txt

+28-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cmake_minimum_required(VERSION 2.8.1)
2-
project(UnitTest++)
1+
cmake_minimum_required(VERSION 3.0)
2+
project(UnitTest++ VERSION 2.1.0)
33

44
option(UTPP_USE_PLUS_SIGN
55
"Set this to OFF if you wish to use '-cpp' instead of '++' in lib/include paths"
@@ -64,6 +64,8 @@ source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
6464

6565
# create the lib
6666
add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
67+
add_library(UnitTest++::UnitTest++ ALIAS UnitTest++)
68+
6769

6870
if(${UTPP_USE_PLUS_SIGN})
6971
set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
@@ -74,13 +76,16 @@ endif()
7476
file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
7577
source_group( "" FILES ${TEST_SRCS})
7678
add_executable(TestUnitTest++ ${TEST_SRCS})
77-
include_directories(.)
79+
7880

7981
if(${UTPP_USE_PLUS_SIGN})
8082
set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
8183
endif()
8284

83-
target_link_libraries(TestUnitTest++ UnitTest++)
85+
target_link_libraries(TestUnitTest++
86+
PUBLIC
87+
UnitTest++::UnitTest++
88+
)
8489

8590
# run unit tests as post build step
8691
add_custom_command(TARGET TestUnitTest++
@@ -100,14 +105,31 @@ else()
100105
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
101106
endif()
102107

108+
target_include_directories( UnitTest++
109+
PUBLIC
110+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
111+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/UnitTest++>
112+
)
113+
set_target_properties(UnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
114+
set_target_properties(TestUnitTest++ PROPERTIES DEBUG_POSTFIX "-d")
115+
103116
set(config_install_dir_ lib${LIB_SUFFIX}/cmake/${PROJECT_NAME})
104117
set(targets_export_name_ "${PROJECT_NAME}Targets")
118+
include(CMakePackageConfigHelpers)
119+
write_basic_package_version_file(
120+
cmake/UnitTest++ConfigVersion.cmake
121+
VERSION ${UnitTest++_VERSION}
122+
COMPATIBILITY SameMajorVersion
123+
)
105124

106125
install(TARGETS UnitTest++ EXPORT "${targets_export_name_}" DESTINATION lib${LIB_SUFFIX})
107126
install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
108127
install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})
109-
install(FILES cmake/UnitTest++Config.cmake DESTINATION "${config_install_dir_}")
110-
install(EXPORT "${targets_export_name_}" DESTINATION "${config_install_dir_}")
128+
install(FILES
129+
cmake/UnitTest++Config.cmake
130+
${CMAKE_CURRENT_BINARY_DIR}/cmake/UnitTest++ConfigVersion.cmake
131+
DESTINATION "${config_install_dir_}")
132+
install(EXPORT "${targets_export_name_}" NAMESPACE "UnitTest++::" DESTINATION "${config_install_dir_}")
111133

112134
set(prefix ${CMAKE_INSTALL_PREFIX})
113135
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2.0.0.{build}
1+
version: 2.1.0.{build}
22

33
os:
44
- Windows Server 2012 R2

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AM_CONDITIONAL([WINDOWS],
2323

2424
LT_INIT()
2525

26-
AC_SUBST([LIBUNITTEST_SO_VERSION], [2:0:0])
26+
AC_SUBST([LIBUNITTEST_SO_VERSION], [2:1:0])
2727

2828
# Checks for programs.
2929
AC_PROG_CXX

tests/TestTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace {
7272
CHECK_EQUAL(1, results.GetFailureCount());
7373
}
7474

75-
#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32)
75+
#if !defined(UNITTEST_MINGW) && !defined(UNITTEST_WIN32) && !defined(__clang__)
7676
// Skip this test in debug because some debuggers don't like it.
7777
#if defined(NDEBUG)
7878
TEST(CrashingTestsAreReportedAsFailures)

0 commit comments

Comments
 (0)
0