Add targets for making CMake find_package work

This commit is contained in:
Joost Molenaar 2023-09-30 16:30:13 +02:00
parent 0e788dc396
commit 513b499707
2 changed files with 14 additions and 1 deletions

View File

@ -10,11 +10,18 @@ if(COMMAND register_component)
register_component()
else()
add_library(u8g2 ${COMPONENT_SRCS})
target_include_directories(u8g2 PUBLIC ${CMAKE_CURRENT_LIST_DIR}/csrc )
target_include_directories(u8g2 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/csrc>" "$<INSTALL_INTERFACE:include>")
endif()
install(TARGETS u8g2
EXPORT u8g2-targets
ARCHIVE DESTINATION lib)
install(FILES ${COMPONENT_HDRS}
DESTINATION include/u8g2)
install(EXPORT u8g2-targets
DESTINATION lib/cmake/u8g2)
install(FILES ${u8g2_SOURCE_DIR}/pkg/u8g2-config.cmake
DESTINATION lib/cmake/u8g2)

6
pkg/u8g2-config.cmake Normal file
View File

@ -0,0 +1,6 @@
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "${_dir}/../../.." ABSOLUTE)
include("${_prefix}/lib/cmake/u8g2/u8g2-targets.cmake")
set(u8g2_INCLUDE_DIRS "${_prefix}/include/u8g2")