|
| 1 | +if(CONFIG_UTILS_RUST_ENABLED) |
| 2 | + ############## Import package ################# |
| 3 | + include(cargo_build.cmake) |
| 4 | + rust_header_gen() |
| 5 | + add_crate(adder) |
| 6 | + add_crate(suber) |
| 7 | + ############################################### |
| 8 | + |
| 9 | + ################# Add include ################# |
| 10 | + # list(APPEND ADD_INCLUDE "inc") |
| 11 | + # list(APPEND ADD_PRIVATE_INCLUDE "include_private") |
| 12 | + ############################################### |
| 13 | + |
| 14 | + ############## Add source files ############### |
| 15 | + # list(APPEND ADD_SRCS "src/lib1.c") |
| 16 | + # FILE(GLOB_RECURSE EXTRA_SRC "src/*.c") |
| 17 | + # FILE(GLOB EXTRA_SRC "src/*.c") |
| 18 | + # list(APPEND ADD_SRCS ${EXTRA_SRC}) |
| 19 | + # aux_source_directory(src ADD_SRCS) # collect all source file in src dir, will set var ADD_SRCS |
| 20 | + # append_srcs_dir(ADD_SRCS "src") # append source file in src dir to var ADD_SRCS |
| 21 | + # list(REMOVE_ITEM COMPONENT_SRCS "src/test.c") |
| 22 | + # set(ADD_ASM_SRCS "src/asm.S") |
| 23 | + # list(APPEND ADD_SRCS ${ADD_ASM_SRCS}) |
| 24 | + # SET_PROPERTY(SOURCE ${ADD_ASM_SRCS} PROPERTY LANGUAGE C) # set .S ASM file as C language |
| 25 | + # SET_SOURCE_FILES_PROPERTIES(${ADD_ASM_SRCS} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp -D BBBBB") |
| 26 | + ############################################### |
| 27 | + |
| 28 | + ###### Add required/dependent components ###### |
| 29 | + # list(APPEND ADD_REQUIREMENTS component1) |
| 30 | + ############################################### |
| 31 | + |
| 32 | + ###### Add link search path for requirements/libs ###### |
| 33 | + # list(APPEND ADD_LINK_SEARCH_PATH "${CONFIG_TOOLCHAIN_PATH}/lib") |
| 34 | + # list(APPEND ADD_REQUIREMENTS pthread m) # add system libs, pthread and math lib for example here |
| 35 | + # set (OpenCV_DIR opencv/lib/cmake/opencv4) |
| 36 | + # find_package(OpenCV REQUIRED) |
| 37 | + list(APPEND ADD_REQUIREMENTS adder suber) |
| 38 | + ############################################### |
| 39 | + |
| 40 | + ############ Add static libs ################## |
| 41 | + # list(APPEND ADD_STATIC_LIB "lib/libtest.a") |
| 42 | + ############################################### |
| 43 | + |
| 44 | + ############ Add dynamic libs ################## |
| 45 | + # list(APPEND ADD_DYNAMIC_LIB "libtest.so") |
| 46 | + ############################################### |
| 47 | + |
| 48 | + #### Add compile option for this component #### |
| 49 | + #### Just for this component, won't affect other |
| 50 | + #### modules, including component that depend |
| 51 | + #### on this component |
| 52 | + # list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAA=1) |
| 53 | + ############################################### |
| 54 | + |
| 55 | + #### Add compile option for this component |
| 56 | + #### and components denpend on this component |
| 57 | + # list(APPEND ADD_DEFINITIONS -DAAAA=1) |
| 58 | + ############################################### |
| 59 | + |
| 60 | + ############ Add static libs ################## |
| 61 | + #### Update parent's variables like CMAKE_C_LINK_FLAGS |
| 62 | + # set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group libmaix/libtest.a -ltest2 -Wl,--end-group" PARENT_SCOPE) |
| 63 | + ############################################### |
| 64 | + |
| 65 | + # register component, DYNAMIC or SHARED flags will make component compiled to dynamic(shared) lib |
| 66 | + register_component() |
| 67 | +endif() |
0 commit comments