Ardupilot2/cmake/modules/APMOption.cmake

37 lines
1.2 KiB
CMake
Raw Normal View History

2012-04-17 22:31:10 -03:00
function(apm_option NAME)
2012-04-17 17:59:52 -03:00
cmake_parse_arguments(ARG
"ADVANCED"
2012-04-17 22:31:10 -03:00
"TYPE;DESCRIPTION;DEFAULT" "OPTIONS;DEPENDS" ${ARGN})
2012-04-17 17:59:52 -03:00
2012-04-17 22:31:10 -03:00
#message(STATUS "parsing argument: ${NAME}")
2012-04-17 17:59:52 -03:00
2012-04-17 22:31:10 -03:00
# if option dependencies not met, hide the option
foreach(DEPEND ${ARG_DEPENDS})
if (NOT ${${DEPEND}})
#message(STATUS "\tfailed dep: ${DEPEND}")
set(ARG_TYPE "INTERNAL")
set("${NAME}" "${ARG_DEFAULT}" CACHE INTERNAL "${ARG_DESCRIPTION}" FORCE)
return()
2012-04-17 17:59:52 -03:00
endif()
2012-04-17 22:31:10 -03:00
endforeach()
# set variable
set("${NAME}" "${ARG_DEFAULT}" CACHE "${ARG_TYPE}" "${ARG_DESCRIPTION}")
# force variable reinit if it was internal (hidden)
get_property(VAR_TYPE CACHE ${NAME} PROPERTY TYPE)
if ("${VAR_TYPE}" STREQUAL "INTERNAL")
message(STATUS "\tVAR_TYPE: ${VAR_TYPE}")
set("${NAME}" "${ARG_DEFAULT}" CACHE "${ARG_TYPE}" "${ARG_DESCRIPTION}" FORCE)
2012-04-17 17:59:52 -03:00
endif()
2012-04-17 22:31:10 -03:00
# set options for combo box
set_property(CACHE "${NAME}" PROPERTY STRINGS ${ARG_OPTIONS})
# mark as advanced if advanced option given
if(ARG_ADVANCED)
2012-04-17 17:59:52 -03:00
mark_as_advanced(FORCE "${NAME}")
endif()
2012-04-17 22:31:10 -03:00
endfunction()