@@ -79,6 +79,10 @@ if (BUILD_STATIC_LIBRARY)
7979else ()
8080 add_library (printf SHARED)
8181endif ()
82+
83+ add_library ("printf::printf" ALIAS printf)
84+
85+
8286set (GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR} /include" )
8387configure_file ("printf_config.h.in" "${GENERATED_INCLUDE_DIR} /printf_config.h" @ONLY)
8488target_sources (printf PRIVATE src/printf/printf.c "${GENERATED_INCLUDE_DIR} /printf_config.h" src/printf/printf.h)
@@ -99,8 +103,8 @@ target_include_directories(
99103)
100104
101105set_target_properties (printf PROPERTIES
102- LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
103- ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib)
106+ LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib
107+ ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib)
104108
105109if (CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
106110 target_compile_options (printf PRIVATE /W4)
@@ -149,6 +153,9 @@ endif()
149153
150154include (GNUInstallDirs)
151155
156+ # Note: No need for a config.cmake file for setting dependencies - as there
157+ # are no dependencies; this library is self-contained
158+
152159install (
153160 TARGETS printf
154161 EXPORT printf_export
@@ -163,11 +170,17 @@ install(
163170 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} /printf"
164171)
165172
173+ export (
174+ EXPORT printf_export
175+ NAMESPACE "printf::"
176+ FILE "${PROJECT_BINARY_DIR} /printf-targets.cmake"
177+ )
178+
166179install (
167180 EXPORT printf_export
181+ FILE "printf-targets.cmake"
168182 DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/printf"
169183 NAMESPACE "printf::"
170- FILE "printf-config.cmake"
171184)
172185
173186include (CMakePackageConfigHelpers)
@@ -182,6 +195,3 @@ install(
182195 FILES "${CMAKE_CURRENT_BINARY_DIR} /printf-config-version.cmake"
183196 DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/printf"
184197)
185-
186-
187-
0 commit comments