Merge pull request #43 from mcharleb/cmake-mc

cmake: fixed posix configs
This commit is contained in:
James Goppert 2015-09-10 23:04:00 -04:00
commit 97cb25254d
13 changed files with 91 additions and 29 deletions

View File

@ -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)
@ -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)

View File

@ -1,10 +1,13 @@
include(posix/px4_impl_posix-arm)
set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf)
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 +50,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()

View File

@ -1,10 +1,13 @@
include(posix/px4_impl_posix-arm)
set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf)
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 +39,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()

View File

@ -1,10 +1,13 @@
include(posix/px4_impl_posix-arm)
set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf)
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 +21,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()

View File

@ -1,10 +1,12 @@
include(posix/px4_impl_posix-arm)
set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf)
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 +33,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()

View File

@ -1,4 +1,5 @@
include(posix/px4_impl_posix)
set(USE_TOOLCHAIN Toolchain-native)
function(px4_get_config)

View File

@ -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)