cmake:support nxlib cmake compilation

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2023-08-10 11:30:44 +08:00 committed by Xiang Xiao
parent 4668b5fa22
commit b3678b1454
4 changed files with 44 additions and 32 deletions

View File

@ -20,7 +20,7 @@
if(CONFIG_NX) if(CONFIG_NX)
nuttx_add_kernel_library(graphics) nuttx_add_kernel_library(graphics)
target_include_directories(graphics PRIVATE nxmu nxbe) target_include_directories(graphics PRIVATE nxmu nxbe nxterm)
nuttx_add_subdirectory() nuttx_add_subdirectory()
endif() endif()

View File

@ -19,6 +19,7 @@
# ############################################################################## # ##############################################################################
nuttx_add_aux_library(nxglib) nuttx_add_aux_library(nxglib)
set(SRCS) set(SRCS)
set(OPERATIONS setpixel fillrectangle getrectangle filltrapezoid moverectangle set(OPERATIONS setpixel fillrectangle getrectangle filltrapezoid moverectangle
@ -26,8 +27,8 @@ set(OPERATIONS setpixel fillrectangle getrectangle filltrapezoid moverectangle
set(BPPS set(BPPS
1 1
2 2
8
4 4
8
16 16
24 24
32) 32)
@ -40,22 +41,29 @@ endif()
foreach(op ${OPERATIONS}) foreach(op ${OPERATIONS})
foreach(bpp ${BPPS}) foreach(bpp ${BPPS})
configure_file(${BLITDIR}/nxglib_${op}.c.in nxglib_${op}_${bpp}bpp.c) set(BPP_SUFFIX _${bpp}bpp)
set_source_files_properties( configure_file(${BLITDIR}/nxglib_${op}.c nxglib_${op}${BPP_SUFFIX}.c
${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}_${bpp}bpp.c COPYONLY)
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp}) set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxglib_${op}_${bpp}bpp.c) 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()
endforeach() endforeach()
if(CONFIG_NX_RAMBACKED) if(CONFIG_NX_RAMBACKED)
foreach(op ${OPERATIONS}) foreach(op ${OPERATIONS})
foreach(bpp ${BPPS}) foreach(bpp ${BPPS})
configure_file(pwfb/pwfb_${op}.c.in pwfb_${op}_${bpp}bpp.c) set(BPP_SUFFIX _${bpp}bpp)
set_source_files_properties( configure_file(pwfb/pwfb_${op}.c pwfb_${op}${BPP_SUFFIX}.c COPYONLY)
${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}_${bpp}bpp.c set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp}) set_property(
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/pwfb_${op}_${bpp}bpp.c) 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()
endforeach() endforeach()
endif() endif()
@ -66,13 +74,16 @@ if(CONFIG_NX_SWCURSOR)
foreach(op ${CURSOR_OPS}) foreach(op ${CURSOR_OPS})
foreach(bpp ${CURSOR_BPPS}) foreach(bpp ${CURSOR_BPPS})
configure_file(cursor/nxglib_cursor_${op}.c.in set(BPP_SUFFIX _${bpp}bpp)
nxglib_cursor_${op}_${bpp}bpp.c) configure_file(cursor/nxglib_cursor_${op}.c
set_source_files_properties( nxglib_cursor_${op}${BPP_SUFFIX}.c COPYONLY)
${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}_${bpp}bpp.c set(CUSTOM_DEFINES NXGLIB_BITSPERPIXEL=${bpp} NXGLIB_SUFFIX=${BPP_SUFFIX})
PROPERTIES COMPILE_FLAGS -DNXGLIB_BITSPERPIXEL=${bpp}) set_property(
SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxglib_cursor_${op}${BPP_SUFFIX}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
list(APPEND SRCS 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()
endforeach() endforeach()
endif() endif()

View File

@ -41,9 +41,5 @@ if(CONFIG_NXTERM)
list(APPEND SRCS nxterm_kbdin.c) list(APPEND SRCS nxterm_kbdin.c)
endif() endif()
if(CONFIG_DEBUG_GRAPHICS)
list(APPEND SRCS nxterm_sem.c)
endif()
target_sources(graphics PRIVATE ${SRCS}) target_sources(graphics PRIVATE ${SRCS})
endif() endif()

View File

@ -18,13 +18,15 @@
# #
# ############################################################################## # ##############################################################################
function(add_font name id) function(add_font name id)
string(REPLACE "-" "_" prefix "g_${name}") string(REPLACE "-" "_" prefix "g_${name}_")
configure_file(nxfonts_bitmaps.c.in nxfonts_bitmaps_${name}.c) configure_file(nxfonts_bitmaps.c nxfonts_bitmaps_${name}.c)
target_sources(nxfonts target_sources(nxfonts
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c) PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c)
set_source_files_properties( set(CUSTOM_DEFINES NXFONTS_FONTID=${id} NXFONTS_PREFIX=${prefix})
${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c set_property(
PROPERTIES COMPILE_FLAGS -DNXFONTS_FONTID=${id}) SOURCE ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_bitmaps_${name}.c
APPEND
PROPERTY COMPILE_DEFINITIONS ${CUSTOM_DEFINES})
endfunction() endfunction()
if(CONFIG_NXFONTS) if(CONFIG_NXFONTS)
@ -45,11 +47,14 @@ if(CONFIG_NXFONTS)
24 24
32) 32)
foreach(bpp ${BPPS}) foreach(bpp ${BPPS})
configure_file(nxfonts_convert.c.in nxfonts_convert_${bpp}bpp.c) set(BPP_SUFFIX _${bpp}bpp)
set_source_files_properties( configure_file(nxfonts_convert.c nxfonts_convert${BPP_SUFFIX}.c)
${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert_${bpp}bpp.c set(CUSTOM_DEFINES NXFONTS_BITSPERPIXEL=${bpp} NXFONTS_SUFFIX=${BPP_SUFFIX})
PROPERTIES COMPILE_FLAGS -DNXFONTS_BITSPERPIXEL=${bpp}) set_property(
list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/nxfonts_convert_${bpp}bpp.c) 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() endforeach()
target_sources(nxfonts PRIVATE ${SRCS}) target_sources(nxfonts PRIVATE ${SRCS})