Skip to content

Commit

Permalink
cmake:support nxlib cmake compilation
Browse files Browse the repository at this point in the history
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
  • Loading branch information
xuxin930 authored and xiaoxiang781216 committed Aug 10, 2023
1 parent 4668b5f commit b3678b1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
2 changes: 1 addition & 1 deletion graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if(CONFIG_NX)
nuttx_add_kernel_library(graphics)

target_include_directories(graphics PRIVATE nxmu nxbe)
target_include_directories(graphics PRIVATE nxmu nxbe nxterm)

nuttx_add_subdirectory()
endif()
45 changes: 28 additions & 17 deletions graphics/nxglib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
# ##############################################################################

nuttx_add_aux_library(nxglib)

set(SRCS)

set(OPERATIONS setpixel fillrectangle getrectangle filltrapezoid moverectangle
copyrectangle)
set(BPPS
1
2
8
4
8
16
24
32)
Expand All @@ -40,22 +41,29 @@ endif()

foreach(op ${OPERATIONS})
foreach(bpp ${BPPS})
configure_file(${BLITDIR}/nxglib_${op}.c.in nxglib_${op}_${bpp}bpp.c)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}_${bpp}bpp.c
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}_${bpp}bpp.c)
set(BPP_SUFFIX _${bpp}bpp)
configure_file(${BLITDIR}/nxglib_${op}.c nxglib_${op}${BPP_SUFFIX}.c
COPYONLY)
set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}${BPP_SUFFIX}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}${BPP_SUFFIX}.c)
endforeach()
endforeach()

if(CONFIG_NX_RAMBACKED)
foreach(op ${OPERATIONS})
foreach(bpp ${BPPS})
configure_file(pwfb/pwfb_${op}.c.in pwfb_${op}_${bpp}bpp.c)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}_${bpp}bpp.c
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}_${bpp}bpp.c)
set(BPP_SUFFIX _${bpp}bpp)
configure_file(pwfb/pwfb_${op}.c pwfb_${op}${BPP_SUFFIX}.c COPYONLY)
set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}${BPP_SUFFIX}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}${BPP_SUFFIX}.c)
endforeach()
endforeach()
endif()
Expand All @@ -66,13 +74,16 @@ if(CONFIG_NX_SWCURSOR)

foreach(op ${CURSOR_OPS})
foreach(bpp ${CURSOR_BPPS})
configure_file(cursor/nxglib_cursor_${op}.c.in
nxglib_cursor_${op}_${bpp}bpp.c)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}_${bpp}bpp.c
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp})
set(BPP_SUFFIX _${bpp}bpp)
configure_file(cursor/nxglib_cursor_${op}.c
nxglib_cursor_${op}${BPP_SUFFIX}.c COPYONLY)
set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}${BPP_SUFFIX}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
list(APPEND SRCS
${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}_${bpp}bpp.c)
${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}${BPP_SUFFIX}.c)
endforeach()
endforeach()
endif()
Expand Down
4 changes: 0 additions & 4 deletions graphics/nxterm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,5 @@ if(CONFIG_NXTERM)
list(APPEND SRCS nxterm_kbdin.c)
endif()

if(CONFIG_DEBUG_GRAPHICS)
list(APPEND SRCS nxterm_sem.c)
endif()

target_sources(graphics PRIVATE ${SRCS})
endif()
25 changes: 15 additions & 10 deletions libs/libnx/nxfonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
#
# ##############################################################################
function(add_font name id)
string(REPLACE "-" "_" prefix "g_${name}")
configure_file(nxfonts_bitmaps.c.in nxfonts_bitmaps_${name}.c)
string(REPLACE "-" "_" prefix "g_${name}_")
configure_file(nxfonts_bitmaps.c nxfonts_bitmaps_${name}.c)
target_sources(nxfonts
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c
PROPERTIES COMPILE_FLAGS -DNXFONTS_FONTID=${id})
set(CUSTOM_DEFINES NXFONTS_FONTID=${id} NXFONTS_PREFIX=${prefix})
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
endfunction()

if(CONFIG_NXFONTS)
Expand All @@ -45,11 +47,14 @@ if(CONFIG_NXFONTS)
24
32)
foreach(bpp ${BPPS})
configure_file(nxfonts_convert.c.in nxfonts_convert_${bpp}bpp.c)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert_${bpp}bpp.c
PROPERTIES COMPILE_FLAGS -DNXFONTS_BITSPERPIXEL=${bpp})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert_${bpp}bpp.c)
set(BPP_SUFFIX _${bpp}bpp)
configure_file(nxfonts_convert.c nxfonts_convert${BPP_SUFFIX}.c)
set(CUSTOM_DEFINES NXFONTS_BITSPERPIXEL=${bpp} NXFONTS_SUFFIX=${BPP_SUFFIX})
set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert${BPP_SUFFIX}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert${BPP_SUFFIX}.c)
endforeach()

target_sources(nxfonts PRIVATE ${SRCS})
Expand Down

0 comments on commit b3678b1

Please sign in to comment.