diff --git a/CMakeLists.txt b/CMakeLists.txt index a713141b61..a0c3299666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -402,6 +402,19 @@ if (config_io_board) add_subdirectory(src/modules/px4iofirmware) endif() +#============================================================================= +# generate custom target to print for all executable and module cmake targets +# +if(all_posix_cmake_targets) + list(SORT all_posix_cmake_targets) + px4_join(OUT posix_cmake_target_list LIST ${all_posix_cmake_targets} GLUE "\\n") + add_custom_target(list_cmake_targets + COMMAND sh -c "printf \"${posix_cmake_target_list}\\n\"" + COMMENT "List of cmake targets that can be matched by PX4_NO_OPTIMIZATION:" + VERBATIM + ) +endif() + #============================================================================= # generate git version # diff --git a/Makefile b/Makefile index 1e5bdb805a..728426eb4b 100644 --- a/Makefile +++ b/Makefile @@ -148,6 +148,9 @@ endef # -------------------------------------------------------------------- # Do not put any spaces between function arguments. +# For a list of all config targets, please look in cmake/configs, +# For example: ls cmake/configs | sed -e 's/\.cmake$//' + # All nuttx, posix and qurt targets. nuttx_% posix_% qurt_%: $(call cmake-build,$@) @@ -288,7 +291,7 @@ viewers = gazebo jmavsim replay sitl_vmd_triplet_masks = $(foreach viewer,$(viewers),$(viewer) $(viewer)_%) # targets handled by PX4_MAKE make_targets = install test upload package package_source debug debug_tui debug_ddd debug_io debug_io_tui debug_io_ddd check_weak \ - run_cmake_config config $(sitl_vmd_triplet_masks) + run_cmake_config config list_vmd_make_targets list_cmake_targets $(sitl_vmd_triplet_masks) $(foreach targ,$(make_targets),$(eval $(call make-targ,$(targ)))) .PHONY: clean diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 6b5bbec1c5..99c8b5a964 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -1061,14 +1061,21 @@ endfunction() # # px4_add_optimization_flags_for_target # +set(all_posix_cmake_targets "" CACHE INTERNAL "All cmake targets for which optimization can be suppressed") function(px4_add_optimization_flags_for_target target) set(_no_optimization_for_target FALSE) - foreach(_regexp $ENV{PX4_NO_OPTIMIZATION}) - if("${target}" MATCHES "${_regexp}") - set(_no_optimization_for_target TRUE) - set(_matched_regexp "${_regexp}") - endif() - endforeach() + # If the current CONFIG is posix_sitl_* then suppress optimization for certain targets. + if(CONFIG MATCHES "^posix_sitl_") + foreach(_regexp $ENV{PX4_NO_OPTIMIZATION}) + if("${target}" MATCHES "${_regexp}") + set(_no_optimization_for_target TRUE) + set(_matched_regexp "${_regexp}") + endif() + endforeach() + # Create a full list of targets that optimization can be suppressed for. + list(APPEND all_posix_cmake_targets ${target}) + set(all_posix_cmake_targets ${all_posix_cmake_targets} CACHE INTERNAL "All cmake targets for which optimization can be suppressed") + endif() if(NOT ${_no_optimization_for_target}) target_compile_options(${target} PRIVATE ${optimization_flags}) else() diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt index 30cb45cb71..7c1f5dde2f 100644 --- a/src/firmware/posix/CMakeLists.txt +++ b/src/firmware/posix/CMakeLists.txt @@ -152,6 +152,7 @@ set_target_properties(sitl_gazebo PROPERTIES EXCLUDE_FROM_ALL TRUE) set(viewers none jmavsim gazebo replay) set(debuggers none gdb lldb ddd valgrind) set(models none iris iris_opt_flow tailsitter standard_vtol plane solo typhoon_h480) +set(all_posix_vmd_make_targets) foreach(viewer ${viewers}) foreach(debugger ${debuggers}) foreach(model ${models}) @@ -180,6 +181,7 @@ foreach(viewer ${viewers}) WORKING_DIRECTORY ${SITL_WORKING_DIR} USES_TERMINAL ) + list(APPEND all_posix_vmd_make_targets ${_targ_name}) if (viewer STREQUAL "gazebo") add_dependencies(${_targ_name} sitl_gazebo) endif() @@ -187,6 +189,13 @@ foreach(viewer ${viewers}) endforeach() endforeach() +px4_join(OUT posix_vmd_make_target_list LIST ${all_posix_vmd_make_targets} GLUE "\\n") +add_custom_target(list_vmd_make_targets + COMMAND sh -c "printf \"${posix_vmd_make_target_list}\\n\"" + COMMENT "List of acceptable '${CONFIG}' targets:" + VERBATIM + ) + #============================================================================= # install #