Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake install targets and package discovery #2275

Merged
merged 5 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 18 additions & 92 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,101 +1,27 @@
cmake_minimum_required(VERSION 3.5)
project(u8g2)

set(COMPONENT_ADD_INCLUDEDIRS csrc)
set(COMPONENT_SRCS "csrc/u8x8_setup.c"
"csrc/u8x8_u8toa.c"
"csrc/u8x8_d_ssd1306_96x16.c"
"csrc/u8g2_d_memory.c"
"csrc/u8g2_selection_list.c"
"csrc/u8g2_hvline.c"
"csrc/u8x8_d_ssd1306_128x64_noname.c"
"csrc/u8x8_message.c"
"csrc/u8x8_d_ssd1306_48x64.c"
"csrc/u8x8_d_ssd1305.c"
"csrc/u8g2_kerning.c"
"csrc/u8x8_input_value.c"
"csrc/u8x8_d_st7586s_s028hn118a.c"
"csrc/u8g2_polygon.c"
"csrc/u8x8_d_uc1604.c"
"csrc/u8x8_d_ssd1306_128x32.c"
"csrc/u8x8_d_ssd1306_72x40.c"
"csrc/u8x8_d_ssd1322.c"
"csrc/u8x8_d_sbn1661.c"
"csrc/u8g2_input_value.c"
"csrc/u8x8_8x8.c"
"csrc/u8x8_debounce.c"
"csrc/u8x8_d_uc1638.c"
"csrc/u8g2_setup.c"
"csrc/u8x8_d_ist3020.c"
"csrc/u8x8_display.c"
"csrc/u8x8_d_ssd1317.c"
"csrc/u8x8_d_ks0108.c"
"csrc/u8g2_box.c"
"csrc/u8x8_selection_list.c"
"csrc/u8x8_d_ssd1326.c"
"csrc/u8x8_d_st75256.c"
"csrc/u8x8_d_ssd1309.c"
"csrc/u8x8_byte.c"
"csrc/u8x8_d_ssd1607_200x200.c"
"csrc/u8x8_d_pcd8544_84x48.c"
"csrc/u8log.c"
"csrc/u8x8_d_sh1107.c"
"csrc/u8log_u8x8.c"
"csrc/u8g2_message.c"
"csrc/u8x8_d_uc1610.c"
"csrc/u8x8_d_sh1106_72x40.c"
"csrc/u8g2_line.c"
"csrc/u8g2_intersection.c"
"csrc/u8g2_fonts.c"
"csrc/u8x8_d_sh1106_64x32.c"
"csrc/u8x8_d_sed1330.c"
"csrc/u8x8_d_pcf8814_hx1230.c"
"csrc/u8x8_d_il3820_296x128.c"
"csrc/u8x8_d_uc1701_dogs102.c"
"csrc/u8g2_cleardisplay.c"
"csrc/u8x8_d_ssd1325.c"
"csrc/u8g2_font.c"
"csrc/u8x8_d_uc1601.c"
"csrc/u8x8_d_pcf8812.c"
"csrc/u8x8_cad.c"
"csrc/u8x8_d_uc1611.c"
"csrc/u8x8_string.c"
"csrc/u8g2_ll_hvline.c"
"csrc/u8x8_fonts.c"
"csrc/u8x8_d_ld7032_60x32.c"
"csrc/u8x8_d_max7219.c"
"csrc/u8x8_d_st7588.c"
"csrc/u8x8_d_ssd1606_172x72.c"
"csrc/u8x8_d_st7586s_erc240160.c"
"csrc/u8x8_d_stdio.c"
"csrc/u8x8_d_sh1122.c"
"csrc/u8log_u8g2.c"
"csrc/u8g2_circle.c"
"csrc/u8x8_d_ssd1306_64x48.c"
"csrc/u8g2_buffer.c"
"csrc/u8g2_bitmap.c"
"csrc/u8x8_d_lc7981.c"
"csrc/u8x8_d_st7920.c"
"csrc/u8x8_d_t6963.c"
"csrc/u8x8_d_st7567.c"
"csrc/u8x8_d_ls013b7dh03.c"
"csrc/u8x8_d_ssd1327.c"
"csrc/u8x8_d_sh1108.c"
"csrc/u8x8_gpio.c"
"csrc/u8x8_d_uc1608.c"
"csrc/u8x8_d_uc1617.c"
"csrc/u8x8_d_ssd1329.c"
"csrc/u8x8_d_ssd1306_64x32.c"
"csrc/u8g2_d_setup.c"
"csrc/u8x8_d_uc1701_mini12864.c"
"csrc/u8x8_u16toa.c"
"csrc/u8x8_d_a2printer.c"
"csrc/u8x8_d_st7565.c"
"csrc/u8x8_capture.c"
"csrc/u8g2_button.c")
file(GLOB COMPONENT_SRCS csrc/*.c)
file(GLOB COMPONENT_HDRS csrc/*.h)

if(COMMAND register_component)
set(COMPONENT_NAME ".")
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 changes: 6 additions & 0 deletions pkg/u8g2-config.cmake
Original file line number Diff line number Diff line change
@@ -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")