Improved cmake options.

This commit is contained in:
James Goppert 2012-04-18 23:15:29 -04:00
parent 0f90164f03
commit 53c143a575
4 changed files with 62 additions and 44 deletions

View File

@ -14,12 +14,16 @@
apm_option("APM_PROGRAMMING_PORT" TYPE STRING
DESCRIPTION "Programming upload port?"
DEFAULT "/dev/ttyUSB0")
DEFAULT "/dev/ttyACM0")
apm_option("APM_HARDWARE" TYPE STRING
apm_option("CONFIG_APM_HARDWARE" TYPE STRING
DESCRIPTION "APM Hardware?"
OPTIONS "APM_HARDARE_APM2" "APM2_BETA_HARDWARE" "APM1"
DEFAULT "APM_HARDARE_APM2")
OPTIONS "APM_HARDWARE_APM2" "APM_HARDWARE_APM1"
DEFAULT "APM_HARDWARE_APM2")
apm_option("APM2_BETA_HARDWARE" TYPE BOOL DEFINE_ONLY
DESCRIPTION "Is this an APM 2.0 Beta board?"
DEFAULT OFF)
apm_option("APM_PROCESSOR" TYPE STRING
DESCRIPTION "ArduPilotMega processor (2560 for APM2 and later APM1)?"
@ -105,6 +109,10 @@ apm_option("MAV_SYSTEM_ID" TYPE STRING ADVANCED
DESCRIPTION "MAVLink System ID?"
DEFAULT "1")
apm_option("MAVLINKV10" TYPE BOOL DEFINE_ONLY
DESCRIPTION "Use mavlink version 1.0?"
DEFAULT OFF)
apm_option("SERIAL0_BAUD" TYPE STRING ADVANCED
DESCRIPTION "Serial 0 baudrate?"
DEFAULT "115200"

View File

@ -29,7 +29,7 @@ Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME}
# built variables
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(FIRMWARE_NAME "${PROJECT_NAME}-${APM_HARDWARE}-${APM_PROCESSOR}-${HIL_MODE}")
set(FIRMWARE_NAME "${PROJECT_NAME}-${CONFIG_APM_HARDWARE}-${APM_PROCESSOR}-${HIL_MODE}")
# modify flags from default toolchain flags
set(APM_OPT_FLAGS "-Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2")

View File

@ -16,19 +16,23 @@ apm_option("APM_PROGRAMMING_PORT" TYPE STRING
DESCRIPTION "Programming upload port?"
DEFAULT "/dev/ttyACM0")
apm_option("APM_HARDWARE" TYPE STRING
apm_option("CONFIG_APM_HARDWARE" TYPE STRING
DESCRIPTION "APM Hardware?"
OPTIONS "APM_HARDARE_APM2" "APM2_BETA_HARDWARE" "APM1"
DEFAULT "APM_HARDARE_APM2")
OPTIONS "APM_HARDWARE_APM2" "APM_HARDWARE_APM1"
DEFAULT "APM_HARDWARE_APM2")
apm_option("APM2_BETA_HARDWARE" TYPE BOOL DEFINE_ONLY
DESCRIPTION "Is this an APM 2.0 Beta board?"
DEFAULT OFF)
apm_option("APM_PROCESSOR" TYPE STRING
DESCRIPTION "ArduPilotMega processor (2560 for APM2 and later APM1)?"
DEFAULT "mega2560"
OPTIONS "mega" "mega2560")
apm_option("CLI_ENABLED" TYPE BOOL
DESCRIPTION "Enable command line interface switch?"
DEFAULT OFF)
#apm_option("CLI_SLIDER_ENABLED" TYPE BOOL
#DESCRIPTION "Enable command line interface switch?"
#DEFAULT OFF)
apm_option("LOGGING_ENABLED" TYPE BOOL
DESCRIPTION "Enable logging?"
@ -56,22 +60,30 @@ apm_option("AIRSPEED_SENSOR" TYPE BOOL
DESCRIPTION "Enable airspeed sensor?"
DEFAULT OFF)
apm_option("PITOT_ENABLED" TYPE BOOL
DESCRIPTION "Enable pitot static system?"
DEFAULT OFF)
apm_option("SONAR_ENABLED" TYPE BOOL
DESCRIPTION "Enable sonar?"
DEFAULT OFF)
apm_option("AIRSPEED_RATIO" TYPE STRING ADVANCED
DESCRIPTION "Airspeed ratio?"
DEFAULT "1.9936")
apm_option("MAGNETOMETER" TYPE BOOL
DESCRIPTION "Enable airspeed sensor?"
DEFAULT OFF)
#apm_option("MAGNETOMETER" TYPE BOOL
#DESCRIPTION "Enable airspeed sensor?"
#DEFAULT OFF)
apm_option("MAG_ORIENTATION" TYPE STRING ADVANCED
DESCRIPTION "Magnetometer orientation?"
DEFAULT "AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD"
OPTIONS
"AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD"
"AP_COMPASS_COMPONENTS_DOWN_PINS_BACK"
"AP_COMPASS_COMPONENTS_UP_PINS_FORWARD"
"AP_COMPASS_COMPONENTS_UP_PINS_BACK")
#apm_option("MAG_ORIENTATION" TYPE STRING ADVANCED
#DESCRIPTION "Magnetometer orientation?"
#DEFAULT "AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD"
#OPTIONS
#"AP_COMPASS_COMPONENTS_DOWN_PINS_FORWARD"
#"AP_COMPASS_COMPONENTS_DOWN_PINS_BACK"
#"AP_COMPASS_COMPONENTS_UP_PINS_FORWARD"
#"AP_COMPASS_COMPONENTS_UP_PINS_BACK")
apm_option("HIL_MODE" TYPE STRING
DESCRIPTION "Hardware-in-the-loop- mode?"
@ -81,30 +93,14 @@ apm_option("HIL_MODE" TYPE STRING
"HIL_MODE_ATTITUDE"
"HIL_MODE_SENSORS")
apm_option("HIL_PORT" TYPE STRING
DESCRIPTION "Port for Hardware-in-the-loop communication"
DEFAULT "0"
OPTIONS "0" "1" "2" "3")
apm_option("HIL_PROTOCOL" TYPE STRING
DESCRIPTION "Hardware-in-the-loop protocol?"
DEFAULT "HIL_PROTOCOL_MAVLINK"
OPTIONS "HIL_PROTOCOL_MAVLINK" "HIL_PROTOCOL_XPLANE")
apm_option("GCS_PROTOCOL" TYPE STRING
DESCRIPTION "Ground station protocol?"
DEFAULT "GCS_PROTOCOL_MAVLINK"
OPTIONS "GCS_PROTOCOL_NONE" "GCS_PROTOCOL_MAVLINK")
apm_option("GCS_PORT" TYPE STRING ADVANCED
DESCRIPTION "Ground station port?"
DEFAULT "3"
OPTIONS "0" "1" "2" "3")
apm_option("MAV_SYSTEM_ID" TYPE STRING ADVANCED
DESCRIPTION "MAVLink System ID?"
DEFAULT "1")
apm_option("MAVLINKV10" TYPE BOOL DEFINE_ONLY
DESCRIPTION "Use mavlink version 1.0?"
DEFAULT OFF)
apm_option("SERIAL0_BAUD" TYPE STRING ADVANCED
DESCRIPTION "Serial 0 baudrate?"
DEFAULT "115200"

View File

@ -1,6 +1,6 @@
function(apm_option NAME)
cmake_parse_arguments(ARG
"ADVANCED"
"ADVANCED;DEFINE_ONLY"
"TYPE;DESCRIPTION;DEFAULT" "OPTIONS;DEPENDS" ${ARGN})
#message(STATUS "parsing argument: ${NAME}")
@ -39,6 +39,12 @@ function(apm_option NAME)
mark_as_advanced(FORCE "${NAME}")
endif()
if(ARG_DEFINE_ONLY)
set("${NAME}_DEFINE_ONLY" TRUE CACHE INTERNAL "Define only?" FORCE)
else()
set("${NAME}_DEFINE_ONLY" FALSE CACHE INTERNAL "Define only?" FORCE)
endif()
endfunction()
function(apm_option_generate_config)
@ -50,6 +56,14 @@ function(apm_option_generate_config)
#message(STATUS "item: ${ITEM}")
get_property(ITEM_VALUE CACHE ${ITEM} PROPERTY VALUE)
get_property(ITEM_HELP CACHE ${ITEM} PROPERTY HELPSTRING)
if (${ITEM}_DEFINE_ONLY)
if (${ITEM}_VALUE)
file(APPEND "${CMAKE_BINARY_DIR}/${ARG_FILE}" "\n#define ${ITEM} // ${ITEM_HELP}")
else()
file(APPEND "${CMAKE_BINARY_DIR}/${ARG_FILE}" "\n//#define ${ITEM} // ${ITEM_HELP}")
endif()
else()
file(APPEND "${CMAKE_BINARY_DIR}/${ARG_FILE}" "\n#define ${ITEM} ${ITEM_VALUE} // ${ITEM_HELP}")
endif()
endforeach()
endfunction()