From 4beabff26bfbdfe6253cf5ea44fea8788c310cf7 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 10 Sep 2015 19:38:22 -0700 Subject: [PATCH 1/4] cmake: fixed posix configs Signed-off-by: Mark Charlebois --- cmake/configs/config_posix_eagle_default.cmake | 5 +++-- cmake/configs/config_posix_eagle_hil.cmake | 5 +++-- cmake/configs/config_posix_eagle_muorb.cmake | 5 +++-- cmake/configs/config_posix_eagle_release.cmake | 4 ++-- cmake/configs/config_posix_sitl_simple.cmake | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmake/configs/config_posix_eagle_default.cmake b/cmake/configs/config_posix_eagle_default.cmake index 04f80c7523..ddbf058bc7 100644 --- a/cmake/configs/config_posix_eagle_default.cmake +++ b/cmake/configs/config_posix_eagle_default.cmake @@ -4,7 +4,8 @@ function(px4_get_config) px4_parse_function_args( NAME px4_set_config_modules - ONE_VALUE OUT_MODULES OUT_FW_OPTS OUT_EXTRA_CMDS + ONE_VALUE OUT_MODULES + REQUIRED OUT_MODULES ARGN ${ARGN}) set(config_module_list @@ -47,7 +48,7 @@ function(px4_get_config) platforms/posix/work_queue ) - set(${out_module_list} ${config_module_list} PARENT_SCOPE) + set(${OUT_MODULES} ${config_module_list} PARENT_SCOPE) endfunction() diff --git a/cmake/configs/config_posix_eagle_hil.cmake b/cmake/configs/config_posix_eagle_hil.cmake index 115f70d406..be779e143f 100644 --- a/cmake/configs/config_posix_eagle_hil.cmake +++ b/cmake/configs/config_posix_eagle_hil.cmake @@ -4,7 +4,8 @@ function(px4_get_config) px4_parse_function_args( NAME px4_set_config_modules - ONE_VALUE OUT_MODULES OUT_FW_OPTS OUT_EXTRA_CMDS + ONE_VALUE OUT_MODULES + REQUIRED OUT_MODULES ARGN ${ARGN}) set(config_module_list @@ -36,7 +37,7 @@ function(px4_get_config) modules/muorb/krait ) - set(${out_module_list} ${config_module_list} PARENT_SCOPE) + set(${OUT_MODULES} ${config_module_list} PARENT_SCOPE) endfunction() diff --git a/cmake/configs/config_posix_eagle_muorb.cmake b/cmake/configs/config_posix_eagle_muorb.cmake index 44fe4cebe0..c08e43861d 100644 --- a/cmake/configs/config_posix_eagle_muorb.cmake +++ b/cmake/configs/config_posix_eagle_muorb.cmake @@ -4,7 +4,8 @@ function(px4_get_config) px4_parse_function_args( NAME px4_set_config_modules - ONE_VALUE OUT_MODULES OUT_FW_OPTS OUT_EXTRA_CMDS + ONE_VALUE OUT_MODULES + REQUIRED OUT_MODULES ARGN ${ARGN}) set(config_module_list @@ -18,7 +19,7 @@ function(px4_get_config) modules/muorb/krait ) - set(${out_module_list} ${config_module_list} PARENT_SCOPE) + set(${OUT_MODULES} ${config_module_list} PARENT_SCOPE) endfunction() diff --git a/cmake/configs/config_posix_eagle_release.cmake b/cmake/configs/config_posix_eagle_release.cmake index 90c81fd411..90d2e40b86 100644 --- a/cmake/configs/config_posix_eagle_release.cmake +++ b/cmake/configs/config_posix_eagle_release.cmake @@ -4,7 +4,7 @@ function(px4_get_config) px4_parse_function_args( NAME px4_set_config_modules - ONE_VALUE OUT_MODULES OUT_FW_OPTS OUT_EXTRA_CMDS + ONE_VALUE OUT_MODULES ARGN ${ARGN}) set(config_module_list @@ -31,7 +31,7 @@ function(px4_get_config) modules/muorb/krait ) - set(${out_module_list} ${config_module_list} PARENT_SCOPE) + set(${OUT_MODULES} ${config_module_list} PARENT_SCOPE) endfunction() diff --git a/cmake/configs/config_posix_sitl_simple.cmake b/cmake/configs/config_posix_sitl_simple.cmake index 20481bdb1e..39aed67046 100644 --- a/cmake/configs/config_posix_sitl_simple.cmake +++ b/cmake/configs/config_posix_sitl_simple.cmake @@ -1,4 +1,5 @@ include(posix/px4_impl_posix) +set(USE_TOOLCHAIN Toolchain-native) function(px4_get_config) From 3b118a0ea7f4734ec6fbd9d6550cb0f10c975fa4 Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 10 Sep 2015 19:43:54 -0700 Subject: [PATCH 2/4] cmake: Removed obsolete UPLOAD and TEST logic Signed-off-by: Mark Charlebois --- CMakeLists.txt | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fba35c4d7a..93370c61f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,15 +130,6 @@ if (NOT NESTED_CMAKE_CALL) list(GET TARGET_PARAMS 0 OS) list(GET TARGET_PARAMS 1 BOARD) list(GET TARGET_PARAMS 2 LABEL) - message(STATUS "CONFIG ${OS} ${BOARD} ${LABEL}") - if ("${LABEL}" STREQUAL "upload") - set(LABEL "simple") - set(DOUPLOAD "1") - endif() - if ("${LABEL}" STREQUAL "test") - set(LABEL "simple") - set(DOTEST "1") - endif() execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CONFIG} ) set(NESTED_CMAKE_CALL 1) message(STATUS "Before") @@ -149,14 +140,6 @@ if (NOT NESTED_CMAKE_CALL) COMMAND make -s ) message(STATUS "${CMAKE_COMMAND} VERBOSE=1 ${CMAKE_SOURCE_DIR} ${TOOLCHAIN} -DOS=${OS} -DBOARD=${BOARD} -DLABEL=${LABEL}") - if ("${DOUPLOAD}" STREQUAL "1") - execute_process( WORKING_DIRECTORY ${CONFIG} - COMMAND make upload) - endif() - if ("${DOTEST}" STREQUAL "1") - execute_process( WORKING_DIRECTORY ${CONFIG} - COMMAND make test) - endif() return() endif(NOT NESTED_CMAKE_CALL) From 0047b38c5491dbf4d397b8de9991d322ba3f55ec Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 10 Sep 2015 19:52:23 -0700 Subject: [PATCH 3/4] cmake: added Toolchain-arm-linux-gnueabihf Signed-off-by: Mark Charlebois --- .../configs/config_posix_eagle_default.cmake | 2 + cmake/configs/config_posix_eagle_hil.cmake | 2 + cmake/configs/config_posix_eagle_muorb.cmake | 2 + .../configs/config_posix_eagle_release.cmake | 2 + .../Toolchain-arm-linux-gnueabihf.cmake | 67 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake diff --git a/cmake/configs/config_posix_eagle_default.cmake b/cmake/configs/config_posix_eagle_default.cmake index ddbf058bc7..228b4e50ae 100644 --- a/cmake/configs/config_posix_eagle_default.cmake +++ b/cmake/configs/config_posix_eagle_default.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_hil.cmake b/cmake/configs/config_posix_eagle_hil.cmake index be779e143f..af3785f5c7 100644 --- a/cmake/configs/config_posix_eagle_hil.cmake +++ b/cmake/configs/config_posix_eagle_hil.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_muorb.cmake b/cmake/configs/config_posix_eagle_muorb.cmake index c08e43861d..450d7b1e4e 100644 --- a/cmake/configs/config_posix_eagle_muorb.cmake +++ b/cmake/configs/config_posix_eagle_muorb.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_release.cmake b/cmake/configs/config_posix_eagle_release.cmake index 90d2e40b86..cc220cb306 100644 --- a/cmake/configs/config_posix_eagle_release.cmake +++ b/cmake/configs/config_posix_eagle_release.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake new file mode 100644 index 0000000000..2db5cf82b9 --- /dev/null +++ b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake @@ -0,0 +1,67 @@ +# defines: +# +# NM +# OBJCOPY +# LD +# CXX_COMPILER +# C_COMPILER +# CMAKE_SYSTEM_NAME +# CMAKE_SYSTEM_VERSION +# GENROMFS +# LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_FIND_ROOT_PATH +# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM +# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY +# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + +include(CMakeForceCompiler) + +# this one is important +set(CMAKE_SYSTEM_NAME Generic) + +#this one not so much +set(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +find_program(C_COMPILER arm-linux-gnueabihf-gcc) +if(NOT C_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-gcc compiler") +endif() +cmake_force_c_compiler(${C_COMPILER} GNU) + +find_program(CXX_COMPILER arm-linux-gnueabihf-g++) +if(NOT CXX_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-g++ compiler") +endif() +cmake_force_cxx_compiler(${CXX_COMPILER} GNU) + +# compiler tools +foreach(tool objcopy nm ld) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} arm-linux-gnueabihf-${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# os tools +foreach(tool echo patch grep rm mkdir nm genromfs awk cp touch make unzip) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${TOOL}") + endif() +endforeach() + +set(LINKER_FLAGS "-Wl,-gc-sections") +set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) From 98897960e13a63bad674c36e4247f99aefbf8ffc Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 10 Sep 2015 20:02:31 -0700 Subject: [PATCH 4/4] cmake: removed config_ prefix Signed-off-by: Mark Charlebois --- CMakeLists.txt | 8 ++++---- ...fmu-v2_default.cmake => nuttx_px4fmu-v2_default.cmake} | 0 ...x4fmu-v2_simple.cmake => nuttx_px4fmu-v2_simple.cmake} | 0 ...nfig_nuttx_sim_simple.cmake => nuttx_sim_simple.cmake} | 0 ...osix_eagle_default.cmake => posix_eagle_default.cmake} | 0 ...config_posix_eagle_hil.cmake => posix_eagle_hil.cmake} | 0 ...ig_posix_eagle_muorb.cmake => posix_eagle_muorb.cmake} | 0 ...osix_eagle_release.cmake => posix_eagle_release.cmake} | 0 ...ig_posix_sitl_simple.cmake => posix_sitl_simple.cmake} | 0 ...nfig_qurt_eagle_hello.cmake => qurt_eagle_hello.cmake} | 0 .../{config_qurt_eagle_hil.cmake => qurt_eagle_hil.cmake} | 0 ...nfig_qurt_eagle_muorb.cmake => qurt_eagle_muorb.cmake} | 0 12 files changed, 4 insertions(+), 4 deletions(-) rename cmake/configs/{config_nuttx_px4fmu-v2_default.cmake => nuttx_px4fmu-v2_default.cmake} (100%) rename cmake/configs/{config_nuttx_px4fmu-v2_simple.cmake => nuttx_px4fmu-v2_simple.cmake} (100%) rename cmake/configs/{config_nuttx_sim_simple.cmake => nuttx_sim_simple.cmake} (100%) rename cmake/configs/{config_posix_eagle_default.cmake => posix_eagle_default.cmake} (100%) rename cmake/configs/{config_posix_eagle_hil.cmake => posix_eagle_hil.cmake} (100%) rename cmake/configs/{config_posix_eagle_muorb.cmake => posix_eagle_muorb.cmake} (100%) rename cmake/configs/{config_posix_eagle_release.cmake => posix_eagle_release.cmake} (100%) rename cmake/configs/{config_posix_sitl_simple.cmake => posix_sitl_simple.cmake} (100%) rename cmake/configs/{config_qurt_eagle_hello.cmake => qurt_eagle_hello.cmake} (100%) rename cmake/configs/{config_qurt_eagle_hil.cmake => qurt_eagle_hil.cmake} (100%) rename cmake/configs/{config_qurt_eagle_muorb.cmake => qurt_eagle_muorb.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93370c61f6..b80e97b1c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,16 +112,16 @@ set(package-contact "px4users@googlegroups.com") list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) #============================================================================= -# cmake modules +# Validate build configuration and build # if (NOT NESTED_CMAKE_CALL) message(STATUS "IN TOP") - if (EXISTS ${CMAKE_SOURCE_DIR}/cmake/configs/config_${CONFIG}.cmake) + if (EXISTS ${CMAKE_SOURCE_DIR}/cmake/configs/${CONFIG}.cmake) # Get the toolchain information - include(configs/config_${CONFIG}) + include(configs/${CONFIG}) else() - message(FATAL_ERROR "build config not found: config_${CONFIG}.cmake") + message(FATAL_ERROR "build config not found: ${CONFIG}.cmake") endif() if (NOT "${USE_TOOLCHAIN}" STREQUAL "") set(TOOLCHAIN -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake/toolchains/${USE_TOOLCHAIN}.cmake) diff --git a/cmake/configs/config_nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake similarity index 100% rename from cmake/configs/config_nuttx_px4fmu-v2_default.cmake rename to cmake/configs/nuttx_px4fmu-v2_default.cmake diff --git a/cmake/configs/config_nuttx_px4fmu-v2_simple.cmake b/cmake/configs/nuttx_px4fmu-v2_simple.cmake similarity index 100% rename from cmake/configs/config_nuttx_px4fmu-v2_simple.cmake rename to cmake/configs/nuttx_px4fmu-v2_simple.cmake diff --git a/cmake/configs/config_nuttx_sim_simple.cmake b/cmake/configs/nuttx_sim_simple.cmake similarity index 100% rename from cmake/configs/config_nuttx_sim_simple.cmake rename to cmake/configs/nuttx_sim_simple.cmake diff --git a/cmake/configs/config_posix_eagle_default.cmake b/cmake/configs/posix_eagle_default.cmake similarity index 100% rename from cmake/configs/config_posix_eagle_default.cmake rename to cmake/configs/posix_eagle_default.cmake diff --git a/cmake/configs/config_posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake similarity index 100% rename from cmake/configs/config_posix_eagle_hil.cmake rename to cmake/configs/posix_eagle_hil.cmake diff --git a/cmake/configs/config_posix_eagle_muorb.cmake b/cmake/configs/posix_eagle_muorb.cmake similarity index 100% rename from cmake/configs/config_posix_eagle_muorb.cmake rename to cmake/configs/posix_eagle_muorb.cmake diff --git a/cmake/configs/config_posix_eagle_release.cmake b/cmake/configs/posix_eagle_release.cmake similarity index 100% rename from cmake/configs/config_posix_eagle_release.cmake rename to cmake/configs/posix_eagle_release.cmake diff --git a/cmake/configs/config_posix_sitl_simple.cmake b/cmake/configs/posix_sitl_simple.cmake similarity index 100% rename from cmake/configs/config_posix_sitl_simple.cmake rename to cmake/configs/posix_sitl_simple.cmake diff --git a/cmake/configs/config_qurt_eagle_hello.cmake b/cmake/configs/qurt_eagle_hello.cmake similarity index 100% rename from cmake/configs/config_qurt_eagle_hello.cmake rename to cmake/configs/qurt_eagle_hello.cmake diff --git a/cmake/configs/config_qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake similarity index 100% rename from cmake/configs/config_qurt_eagle_hil.cmake rename to cmake/configs/qurt_eagle_hil.cmake diff --git a/cmake/configs/config_qurt_eagle_muorb.cmake b/cmake/configs/qurt_eagle_muorb.cmake similarity index 100% rename from cmake/configs/config_qurt_eagle_muorb.cmake rename to cmake/configs/qurt_eagle_muorb.cmake