diff --git a/.gitignore b/.gitignore index 51d93617..94c2a674 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ docs/html docs/html.zip docs/*.db docs/*.tmp + +# CLion +.idea/ +cmake-build-*/ diff --git a/changelog.txt b/changelog.txt index e140eac1..d8b3806a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,6 +27,7 @@ FIX: Fix missing return value in gfxQueueFSyncInsert(). FEATURE: Adding support for FreeBSD. FIX: Fix incorrect calls to mmap() and sem_open() in SDL2 driver (lax operating systems such as Linux & MacOS were silently tolerating these). FIX: Minor code improvements +FEATURE: Add cmake support *** Release 2.9 *** diff --git a/cmake/Findugfx.cmake b/cmake/Findugfx.cmake new file mode 100644 index 00000000..f2bc7c6f --- /dev/null +++ b/cmake/Findugfx.cmake @@ -0,0 +1,47 @@ +# Ensure that CHIBIOS_ROOT is set +if(NOT UGFX_ROOT) + message(FATAL_ERROR "No UGFX_ROOT specified") +endif() + +# Assemble list of components +list(APPEND ugfx_COMPONENTS + gadc + gaudio + gdisp + gdriver + gevent + gfile + ginput + gmisc + gos + gqueue + gtimer + gtrans + gwin +) + +# Core sources +list(APPEND ugfx_SOURCES + ${UGFX_ROOT}/src/gfx.c +) + +# Core include directories +list(APPEND ugfx_INCLUDE_DIRS + ${UGFX_ROOT}/src +) + +# Include each component +foreach(component ${ugfx_COMPONENTS}) + include(${UGFX_ROOT}/src/${component}/${component}.cmake) +endforeach() + +# Include target setup for ease-of-use +include(${CMAKE_CURRENT_LIST_DIR}/target_setup.cmake) + +# Remove duplicates from non-cached variables +list(REMOVE_DUPLICATES ugfx_SOURCES) +list(REMOVE_DUPLICATES ugfx_INCLUDE_DIRS) + +# Outsource heavy-lifting to cmake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ugfx DEFAULT_MSG ugfx_SOURCES ugfx_INCLUDE_DIRS) diff --git a/cmake/target_setup.cmake b/cmake/target_setup.cmake new file mode 100644 index 00000000..0dd7a4b2 --- /dev/null +++ b/cmake/target_setup.cmake @@ -0,0 +1,21 @@ +function(ugfx_target_setup TARGET) + + target_include_directories( + ${TARGET} + PRIVATE + ${ugfx_INCLUDE_DIRS} + ) + + target_sources( + ${TARGET} + PRIVATE + ${ugfx_SOURCES} + ) + + target_compile_definitions( + ${TARGET} + PRIVATE + ${ugfx_DEFS} + ) + +endfunction() diff --git a/drivers/multiple/SDL/driver.cmake b/drivers/multiple/SDL/driver.cmake new file mode 100644 index 00000000..0f88e07d --- /dev/null +++ b/drivers/multiple/SDL/driver.cmake @@ -0,0 +1,28 @@ +set(ROOT_PATH ${UGFX_ROOT}/drivers/multiple/SDL) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gdisp_lld_SDL.c +) + +list(APPEND ugfx_DEFS + GFX_OS_PRE_INIT_FUNCTION=sdl_driver_init +) + +# Find SDL2 +find_package( + SDL2 + REQUIRED +) + +# Setup target +function(ugfx_driver_setup_SDL TARGET) + target_link_libraries( + ${TARGET} + PRIVATE + SDL2::SDL2 + ) +endfunction() diff --git a/src/gadc/gadc.cmake b/src/gadc/gadc.cmake new file mode 100644 index 00000000..7caf4174 --- /dev/null +++ b/src/gadc/gadc.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gadc) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gadc.c +) diff --git a/src/gaudio/gaudio.cmake b/src/gaudio/gaudio.cmake new file mode 100644 index 00000000..66f2f915 --- /dev/null +++ b/src/gaudio/gaudio.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gaudio) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gaudio.c +) diff --git a/src/gdisp/gdisp.cmake b/src/gdisp/gdisp.cmake new file mode 100644 index 00000000..b534fcac --- /dev/null +++ b/src/gdisp/gdisp.cmake @@ -0,0 +1,27 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gdisp) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} + ${ROOT_PATH}/mcufont +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gdisp.c + ${ROOT_PATH}/gdisp_fonts.c + ${ROOT_PATH}/gdisp_pixmap.c + ${ROOT_PATH}/gdisp_image.c + ${ROOT_PATH}/gdisp_image_native.c + ${ROOT_PATH}/gdisp_image_gif.c + ${ROOT_PATH}/gdisp_image_bmp.c + ${ROOT_PATH}/gdisp_image_jpg.c + ${ROOT_PATH}/gdisp_image_png.c + + ${ROOT_PATH}/mcufont/mf_encoding.c + ${ROOT_PATH}/mcufont/mf_font.c + ${ROOT_PATH}/mcufont/mf_justify.c + ${ROOT_PATH}/mcufont/mf_kerning.c + ${ROOT_PATH}/mcufont/mf_rlefont.c + ${ROOT_PATH}/mcufont/mf_bwfont.c + ${ROOT_PATH}/mcufont/mf_scaledfont.c + ${ROOT_PATH}/mcufont/mf_wordwrap.c +) diff --git a/src/gdriver/gdriver.cmake b/src/gdriver/gdriver.cmake new file mode 100644 index 00000000..01684d5b --- /dev/null +++ b/src/gdriver/gdriver.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gdriver) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gdriver.c +) diff --git a/src/gevent/gevent.cmake b/src/gevent/gevent.cmake new file mode 100644 index 00000000..b3f7ce64 --- /dev/null +++ b/src/gevent/gevent.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gevent) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gevent.c +) diff --git a/src/gfile/gfile.cmake b/src/gfile/gfile.cmake new file mode 100644 index 00000000..07796d11 --- /dev/null +++ b/src/gfile/gfile.cmake @@ -0,0 +1,24 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gfile) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gfile.c + ${ROOT_PATH}/gfile_fs_native.c + ${ROOT_PATH}/gfile_fs_ram.c + ${ROOT_PATH}/gfile_fs_rom.c + ${ROOT_PATH}/gfile_fs_fatfs.c + ${ROOT_PATH}/gfile_fs_petitfs.c + ${ROOT_PATH}/gfile_fs_mem.c + ${ROOT_PATH}/gfile_fs_chibios.c + ${ROOT_PATH}/gfile_fs_strings.c + ${ROOT_PATH}/gfile_printg.c + ${ROOT_PATH}/gfile_scang.c + ${ROOT_PATH}/gfile_stdio.c + ${ROOT_PATH}/gfile_fatfs_wrapper.c + ${ROOT_PATH}/gfile_fatfs_diskio_chibios.c + ${ROOT_PATH}/gfile_petitfs_wrapper.c + ${ROOT_PATH}/gfile_petitfs_diskio_chibios.c +) diff --git a/src/ginput/ginput.cmake b/src/ginput/ginput.cmake new file mode 100644 index 00000000..34f7f9f8 --- /dev/null +++ b/src/ginput/ginput.cmake @@ -0,0 +1,14 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/ginput) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/ginput.c + ${ROOT_PATH}/ginput_mouse.c + ${ROOT_PATH}/ginput_keyboard.c + ${ROOT_PATH}/ginput_keyboard_microcode.c + ${ROOT_PATH}/ginput_toggle.c + ${ROOT_PATH}/ginput_dial.c +) diff --git a/src/gmisc/gmisc.cmake b/src/gmisc/gmisc.cmake new file mode 100644 index 00000000..632eded6 --- /dev/null +++ b/src/gmisc/gmisc.cmake @@ -0,0 +1,13 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gmisc) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gmisc.c + ${ROOT_PATH}/gmisc_arrayops.c + ${ROOT_PATH}/gmisc_matrix2d.c + ${ROOT_PATH}/gmisc_trig.c + ${ROOT_PATH}/gmisc_hittest.c +) diff --git a/src/gos/gos.cmake b/src/gos/gos.cmake new file mode 100644 index 00000000..6477a926 --- /dev/null +++ b/src/gos/gos.cmake @@ -0,0 +1,22 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gos) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gos_chibios.c + ${ROOT_PATH}/gos_freertos.c + ${ROOT_PATH}/gos_win32.c + ${ROOT_PATH}/gos_linux.c + ${ROOT_PATH}/gos_osx.c + ${ROOT_PATH}/gos_raw32.c + ${ROOT_PATH}/gos_ecos.c + ${ROOT_PATH}/gos_rawrtos.c + ${ROOT_PATH}/gos_arduino.c + ${ROOT_PATH}/gos_cmsis.c + ${ROOT_PATH}/gos_nios.c + ${ROOT_PATH}/gos_zephyr.c + ${ROOT_PATH}/gos_x_threads.c + ${ROOT_PATH}/gos_x_heap.c +) diff --git a/src/gqueue/gqueue.cmake b/src/gqueue/gqueue.cmake new file mode 100644 index 00000000..6ba9a769 --- /dev/null +++ b/src/gqueue/gqueue.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gqueue) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gqueue.c +) diff --git a/src/gtimer/gtimer.cmake b/src/gtimer/gtimer.cmake new file mode 100644 index 00000000..acd5afdb --- /dev/null +++ b/src/gtimer/gtimer.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gtimer) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gtimer.c +) diff --git a/src/gtrans/gtrans.cmake b/src/gtrans/gtrans.cmake new file mode 100644 index 00000000..313cb2aa --- /dev/null +++ b/src/gtrans/gtrans.cmake @@ -0,0 +1,9 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gtrans) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gtrans.c +) diff --git a/src/gwin/gwin.cmake b/src/gwin/gwin.cmake new file mode 100644 index 00000000..b9e045e8 --- /dev/null +++ b/src/gwin/gwin.cmake @@ -0,0 +1,30 @@ +set(ROOT_PATH ${UGFX_ROOT}/src/gwin) + +list(APPEND ugfx_INCLUDE_DIRS + ${ROOT_PATH} + ${UGFX_ROOT}/3rdparty/tinygl-0.4-ugfx/include +) + +list(APPEND ugfx_SOURCES + ${ROOT_PATH}/gwin.c + ${ROOT_PATH}/gwin_widget.c + ${ROOT_PATH}/gwin_wm.c + ${ROOT_PATH}/gwin_console.c + ${ROOT_PATH}/gwin_graph.c + ${ROOT_PATH}/gwin_button.c + ${ROOT_PATH}/gwin_slider.c + ${ROOT_PATH}/gwin_checkbox.c + ${ROOT_PATH}/gwin_image.c + ${ROOT_PATH}/gwin_label.c + ${ROOT_PATH}/gwin_radio.c + ${ROOT_PATH}/gwin_list.c + ${ROOT_PATH}/gwin_progressbar.c + ${ROOT_PATH}/gwin_progressbar.c + ${ROOT_PATH}/gwin_container.c + ${ROOT_PATH}/gwin_frame.c + ${ROOT_PATH}/gwin_tabset.c + ${ROOT_PATH}/gwin_gl3d.c + ${ROOT_PATH}/gwin_keyboard.c + ${ROOT_PATH}/gwin_keyboard_layout.c + ${ROOT_PATH}/gwin_textedit.c +)