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 )
3
3
4
4
option (UTPP_USE_PLUS_SIGN
5
5
"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_})
64
64
65
65
# create the lib
66
66
add_library (UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_} )
67
+ add_library (UnitTest++::UnitTest++ ALIAS UnitTest++)
68
+
67
69
68
70
if (${UTPP_USE_PLUS_SIGN} )
69
71
set_target_properties (UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
@@ -74,13 +76,16 @@ endif()
74
76
file (GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
75
77
source_group ( "" FILES ${TEST_SRCS} )
76
78
add_executable (TestUnitTest++ ${TEST_SRCS} )
77
- include_directories (.)
79
+
78
80
79
81
if (${UTPP_USE_PLUS_SIGN} )
80
82
set_target_properties (TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
81
83
endif ()
82
84
83
- target_link_libraries (TestUnitTest++ UnitTest++)
85
+ target_link_libraries (TestUnitTest++
86
+ PUBLIC
87
+ UnitTest++::UnitTest++
88
+ )
84
89
85
90
# run unit tests as post build step
86
91
add_custom_command (TARGET TestUnitTest++
@@ -100,14 +105,31 @@ else()
100
105
set (UTPP_INSTALL_DESTINATION "include/UnitTestPP" )
101
106
endif ()
102
107
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
+
103
116
set (config_install_dir_ lib${LIB_SUFFIX} /cmake/${PROJECT_NAME} )
104
117
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
+ )
105
124
106
125
install (TARGETS UnitTest++ EXPORT "${targets_export_name_} " DESTINATION lib${LIB_SUFFIX} )
107
126
install (FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION} )
108
127
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_} " )
111
133
112
134
set (prefix ${CMAKE_INSTALL_PREFIX} )
113
135
set (exec_prefix ${CMAKE_INSTALL_PREFIX} /bin)
0 commit comments