diff --git a/cmake/px4_base.cmake b/cmake/px4_base.cmake index cf808a8152..888011fe76 100644 --- a/cmake/px4_base.cmake +++ b/cmake/px4_base.cmake @@ -610,4 +610,29 @@ function(px4_add_common_flags) endfunction() +#============================================================================= +# +# px4_mangle_name +# +# Convert a path name to a module name +# +# Usage: +# px4_mangle_name(dirname newname) +# +# Input: +# dirname : path to module dir +# +# Output: +# newname : module name +# +# Example: +# px4_mangle_name(${dirpath} mangled_name) +# message(STATUS "module name is ${mangled_name}") +# +function(px4_mangle_name dirname newname) + set(tmp) + string(REPLACE "/" "__" tmp ${dirname}) + set(${newname} ${tmp} PARENT_SCOPE) +endfunction() + # vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 470e99aa30..e69837558c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,3 @@ -#============================================================================= -# module subdirectories, need to include first -# add_subdirectory(./lib) add_subdirectory(./drivers) add_subdirectory(./platforms) @@ -8,108 +5,5 @@ add_subdirectory(./systemcmds) add_subdirectory(./examples) add_subdirectory(./modules) add_subdirectory(./firmware) -#============================================================================= -# executable -# - -function(px4_mangle_name dirname newname) - set(tmp) - string(REPLACE "/" "__" tmp ${dirname}) - set(${newname} ${tmp} PARENT_SCOPE) -endfunction() - -if (${OS} STREQUAL "nuttx") - - # a list of modules that will be linked to main - set(module_list) - - if (${LABEL} STREQUAL "simple") - list(APPEND module_list - drivers__led - drivers__device - platforms__common - modules__systemlib - modules__uORB - examples__px4_simple_app - lib__mathlib__math__filter - lib__conversion - ) - endif() - - if (${LABEL} STREQUAL "simple") - list(APPEND module_list ${module_list_simple}) - endif() - - list(APPEND module_list - platforms__nuttx - platforms__nuttx__px4_layer - drivers__boards__px4fmu-v2 - drivers__stm32 - ) - - px4_nuttx_generate_builtin_commands( - OUT builtin_commands.c - MODULE_LIST ${module_list}) - - px4_nuttx_generate_romfs(OUT romfs.o - ROOT ROMFS/px4fmu_common) - - # add executable - add_executable(main builtin_commands.c romfs.o) - set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) - set(main_link_flags - "-T${nuttx_export_dir}/build/ld.script" - "-Wl,-Map=${CMAKE_BINARY_DIR}/main.map" - ) - px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") - set_target_properties(main PROPERTIES LINK_FLAGS ${main_link_flags}) - - target_link_libraries(main - -Wl,--start-group - ${module_list} - apps nuttx nosys m gcc - -Wl,--end-group) - - px4_nuttx_add_firmware(OUT ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4 - EXE ${CMAKE_CURRENT_BINARY_DIR}/main) - - px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} - BUNDLE ${CMAKE_CURRENT_BINARY_DIR}/fw_main.px4) - -elseif(${OS} STREQUAL "qurt") - - set(V_ARCH v5) - set(HEXAGON_TOOLS_ROOT /opt/6.4.03) - set(TOOLSLIB - ${HEXAGON_TOOLS_ROOT}/dinkumware/lib/${V_ARCH}/G0) - set(module_dir_list) - set(module_list) - px4_qurt_add_modules(module_dir_list ${BOARD}) - message(STATUS "module list: ${module_dir_list}") - - foreach(directory ${module_dir_list}) - message(STATUS "directory: ${directory}") - px4_mangle_name(${directory} mangled_name) - list(APPEND module_list - ${mangled_name}) - endforeach() - px4_qurt_generate_builtin_commands( - OUT builtin_commands.cpp - MODULE_LIST ${module_list}) - - # FIXME @jgoppert - how to work around issues like this? - # Without changing global variables? - # Clear -rdynamic flag which fails for hexagon - set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") - set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - - add_executable(mainapp builtin_commands.cpp) - target_link_libraries(mainapp - -Wl,--whole-archive - ${module_list} - m - -Wl,--no-whole-archive - -Wl,${TOOLSLIB}/pic/libstdc++.a) -endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt index 9a49794627..fa0720c743 100644 --- a/src/firmware/qurt/CMakeLists.txt +++ b/src/firmware/qurt/CMakeLists.txt @@ -1,3 +1,5 @@ +include(px4_base) + set(V_ARCH v5) set(HEXAGON_TOOLS_ROOT /opt/6.4.03) set(TOOLSLIB