px4-firmware/src/firmware/posix/CMakeLists.txt

149 lines
3.2 KiB
CMake
Raw Normal View History

include (common/px4_upload)
2015-09-08 21:50:18 -03:00
include_directories(${CMAKE_CURRENT_BINARY_DIR})
get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES)
px4_posix_generate_builtin_commands(
OUT apps
2015-09-10 00:00:58 -03:00
MODULE_LIST ${module_libraries})
# Define build target
set(APP_NAME px4)
set(MAIN_SRC ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp)
set(UPLOAD_NAME upload)
if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
include(fastrpc)
include(linux_app)
FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
2015-09-08 21:50:18 -03:00
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")
LINUX_APP(
APP_NAME ${APP_NAME}
IDL_NAME px4muorb
APPS_DEST "/home/linaro"
SOURCES
px4muorb_stub.c
${MAIN_SRC}
apps.cpp
LINK_LIBS
-Wl,--start-group
${module_libraries}
${df_driver_libs}
${FASTRPC_ARM_LIBS}
pthread m rt
-Wl,--end-group
)
2016-04-29 01:09:23 -03:00
px4_add_adb_push(OUT ${UPLOAD_NAME}
OS ${OS}
BOARD ${BOARD}
2017-10-05 16:03:32 -03:00
FILES $<TARGET_FILE:${APP_NAME}>
${PX4_SOURCE_DIR}/posix-configs/eagle/flight/mainapp.config
DEPENDS ${APP_NAME}
DEST /home/linaro)
elseif ("${BOARD}" STREQUAL "rpi")
px4_add_executable(${APP_NAME}
${MAIN_SRC}
apps.cpp
)
target_link_libraries(${APP_NAME}
-Wl,--start-group
${module_libraries}
df_driver_framework
${df_driver_libs}
pthread m rt
-Wl,--end-group
)
file(GLOB RPI_CONFIG_FILES ${PX4_SOURCE_DIR}/posix-configs/rpi/*.config)
px4_add_scp_push(OUT ${UPLOAD_NAME}
OS ${OS}
BOARD ${BOARD}
2017-10-05 16:03:32 -03:00
FILES $<TARGET_FILE:${APP_NAME}>
${RPI_CONFIG_FILES}
${PX4_SOURCE_DIR}/ROMFS
DEPENDS ${APP_NAME}
DEST /home/pi)
elseif ("${BOARD}" STREQUAL "bebop")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
px4_add_executable(${APP_NAME}
${MAIN_SRC}
apps.cpp
)
if (NOT APPLE)
target_link_libraries(${APP_NAME}
-Wl,--start-group
${module_libraries}
${df_driver_libs}
pthread m rt
-Wl,--end-group
)
else()
target_link_libraries(${APP_NAME}
${module_libraries}
${df_driver_libs}
pthread m
)
endif()
px4_add_adb_push_to_bebop(OUT ${UPLOAD_NAME}
OS ${OS}
BOARD ${BOARD}
FILES $<TARGET_FILE:px4>.stripped
2017-10-05 16:03:32 -03:00
DEPENDS px4
DEST /usr/bin)
Target specific optimization control. This allows one to set a semi-colon separated list of regular expressions in the environment variable PX4_NO_OPTIMIZATION to control which (cmake generated) targets should be compiled without optimization. Suppressing optimization can be necessary for debugging in a debugger, especially when trying to step through the code or needing to print variables that otherwise are optimized out. EXAMPLE export PX4_NO_OPTIMIZATION="px4;^modules__uORB;^modules__systemlib$" will result in the following messages during cmake configuration: [...] -- Disabling optimization for target 'platforms__posix__px4_layer' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__systemlib' because it matches the regexp '^modules__systemlib$' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'examples__px4_simple_app' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'modules__uORB__uORB_tests' because it matches the regexp '^modules__uORB' in env var PX4_NO_OPTIMIZATION -- Disabling optimization for target 'px4' because it matches the regexp 'px4' in env var PX4_NO_OPTIMIZATION Note that a list of all (currently used) target names can be printed with the following command line from within the required build directory: find . -wholename '*/CMakeFiles/*.dir/flags.make' | xargs dirname | xargs basename -a | sort -u | sed -e 's/.dir$//'
2016-09-01 20:12:05 -03:00
elseif ("${BOARD}" STREQUAL "sitl")
include(./sitl_target.cmake)
2017-01-04 23:19:08 -04:00
include(./sitl_tests.cmake)
else()
px4_add_executable(${APP_NAME}
${MAIN_SRC}
apps.cpp
)
if (NOT APPLE)
target_link_libraries(${APP_NAME}
-Wl,--start-group
${module_libraries}
${df_driver_libs}
pthread m rt
-Wl,--end-group
)
else()
target_link_libraries(${APP_NAME}
${module_libraries}
${df_driver_libs}
pthread m
)
endif()
endif()
#=============================================================================
# install
#
install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
add_custom_command(OUTPUT ${APP_NAME}.stripped
COMMAND ${STRIP_TOOL} -R .comment -R .gnu.version -o $<TARGET_FILE:px4>.stripped $<TARGET_FILE:px4>
DEPENDS px4
)
2017-10-05 16:03:32 -03:00
add_custom_target(strip DEPENDS "${APP_NAME}.stripped")