@@ -8,9 +8,14 @@ project(
88
99option (build_testing "Should we build our examples and tests" OFF )
1010option (EnableMainHelperClasses
11- "Aims to allow for drop in replacement. Users should prefer refactoring the main function"
12- OFF )
13- option (InstallAsCppUnit "Install the package as 'cppunit' to allow drop-in replacement" OFF )
11+ "Aims to allow for drop in replacement. Users should prefer refactoring the main function"
12+ OFF
13+ )
14+
15+ option (InstallAsCppUnit
16+ "Install the package as 'cppunit' to allow drop-in replacement"
17+ OFF
18+ )
1419
1520if (build_testing)
1621 enable_testing ()
@@ -66,6 +71,36 @@ install(
6671 DESTINATION "share/cmake/${PROJECT_NAME } "
6772)
6873
74+ if (InstallAsCppUnit)
75+ message (STATUS "CppUnit2Gtest will be installed as 'cppunit' to allow drop-in replacement" )
76+ add_library (cppunit ALIAS CppUnit2Gtest )
77+ add_library (CppUnit ALIAS CppUnit2Gtest )
78+ install (
79+ FILES
80+ "${CMAKE_CURRENT_BINARY_DIR } /CppUnitConfig.cmake"
81+ "${CMAKE_CURRENT_BINARY_DIR } /CppUnitConfigVersion.cmake"
82+ DESTINATION "share/cmake/CppUnit"
83+ )
84+ install (TARGETS CppUnit2Gtest
85+ EXPORT CppUnitTargets
86+ INCLUDES DESTINATION include
87+ )
88+ install (EXPORT CppUnitTargets
89+ FILE CppUnitTargets.cmake
90+ NAMESPACE CppUnit::
91+ DESTINATION "share/cmake/CppUnit"
92+ )
93+ configure_package_config_file (
94+ ${CMAKE_CURRENT_SOURCE_DIR } /cmake/Config.cmake.in
95+ "${CMAKE_CURRENT_BINARY_DIR } /CppUnitConfig.cmake"
96+ INSTALL_DESTINATION "share/cmake/CppUnit"
97+ )
98+ write_basic_package_version_file (
99+ CppUnitConfigVersion.cmake
100+ VERSION ${PACKAGE_VERSION}
101+ COMPATIBILITY AnyNewerVersion
102+ )
103+ endif ()
69104# install the header as expected
70105install (
71106 FILES "${CMAKE_CURRENT_SOURCE_DIR } /CppUnit2Gtest.hpp"
@@ -85,7 +120,7 @@ create_header_alias(\${SOURCE_FILE} \${INSTALL_INCLUDE_DIR}/cppunit/config/Sourc
85120create_header_alias(\$ {SOURCE_FILE} \$ {INSTALL_INCLUDE_DIR}/cppunit/TestAssert.h)
86121" )
87122if (EnableMainHelperClasses)
88- install (CODE "
123+ install (CODE "
89124set(INSTALL_INCLUDE_DIR \$ {CMAKE_INSTALL_PREFIX}/include)
90125set(SOURCE_FILE CppUnit2Gtest.hpp)
91126include(tests/CreateSymlink.cmake)
0 commit comments