From 513b49970730101cdca3f5fb74ee33af4c97a936 Mon Sep 17 00:00:00 2001 From: Joost Molenaar Date: Sat, 30 Sep 2023 16:30:13 +0200 Subject: [PATCH] Add targets for making CMake find_package work --- CMakeLists.txt | 9 ++++++++- pkg/u8g2-config.cmake | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 pkg/u8g2-config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d5bfa47f..e4c5dd31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "$" "$") 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) diff --git a/pkg/u8g2-config.cmake b/pkg/u8g2-config.cmake new file mode 100644 index 00000000..8b25e05f --- /dev/null +++ b/pkg/u8g2-config.cmake @@ -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")