2 set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
3 set (_fw_dir "${APPS_SHARE_DIR}")
5 collector_list (_list PROJECT_INC_DIRS)
6 collector_list (_app_list APP_INC_DIRS)
7 include_directories (${_list} ${_app_list} ${CMAKE_CURRENT_SOURCE_DIR})
9 collector_list (_list PROJECT_LIB_DIRS)
10 collector_list (_app_list APP_LIB_DIRS)
11 link_directories (${_list} ${_app_list})
13 get_property (_linker_opt GLOBAL PROPERTY APP_LINKER_OPT)
14 collector_list (_deps PROJECT_LIB_DEPS)
16 set (OPENAMP_LIB open_amp)
18 foreach (_app echo_test echo_testd)
19 collector_list (_sources APP_COMMON_SOURCES)
20 set (build_app 1)
21 if (WITH_REMOTEPROC_MASTER)
22 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_app}_remoteproc_master.c")
23 list (APPEND _sources "${CMAKE_CURRENT_SOURCE_DIR}/${_app}_remoteproc_master.c")
24 set (_cflags "${_cflags} -DBAREMETAL_MASTER=1")
25 else ()
26 set (build_app 0)
27 endif ()
28 else (WITH_REMOTEPROC_MASTER)
29 list (APPEND _sources "${CMAKE_CURRENT_SOURCE_DIR}/${_app}.c")
30 endif (WITH_REMOTEPROC_MASTER)
32 if (${build_app} EQUAL "1")
33 if (WITH_SHARED_LIB)
34 add_executable (${_app}-shared ${_sources})
35 target_link_libraries (${_app}-shared ${OPENAMP_LIB}-shared ${_deps})
36 install (TARGETS ${_app}-shared RUNTIME DESTINATION bin)
37 endif (WITH_SHARED_LIB)
39 if (WITH_STATIC_LIB)
40 if (${PROJECT_SYSTEM} STREQUAL "linux")
41 add_executable (${_app}-static ${_sources})
42 target_link_libraries (${_app}-static ${OPENAMP_LIB}-static ${_deps})
43 install (TARGETS ${_app}-static RUNTIME DESTINATION bin)
44 else (${PROJECT_SYSTEM})
45 add_executable (${_app}.out ${_sources})
46 set_source_files_properties(${_sources} PROPERTIES COMPILE_FLAGS "${_cflags}")
48 if (WITH_REMOTEPROC_MASTER)
49 target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections ${_linker_opt} -Wl,--start-group ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o ${OPENAM__LIB}-static ${_deps} -Wl,--end-group)
50 add_custom_target (${_app}.bin ALL
51 ${CROSS_PREFIX}objcopy -O binary ${_app}.out ${_app}.bin
52 DEPENDS ${_app}.out)
54 add_dependencies (${_app}.out ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o)
56 install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${_app}.bin" DESTINATION bin)
58 else (WITH_REMOTEPROC_MASTER)
60 target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections ${_linker_opt} -Wl,--start-group ${OPENAMP_LIB}-static ${_deps} -Wl,--end-group)
62 install (TARGETS ${_app}.out RUNTIME DESTINATION bin)
63 endif (WITH_REMOTEPROC_MASTER)
64 endif (${PROJECT_SYSTEM} STREQUAL "linux" )
65 endif (WITH_STATIC_LIB)
66 endif (${build_app} EQUAL "1")
67 endforeach(_app)