Skip to content

Commit

Permalink
Merge pull request #9082 from iNavFlight/mmosca-sitl-mac
Browse files Browse the repository at this point in the history
[SITL MACOSX] Fix lldb debugging in OSX and improve OSX detection
  • Loading branch information
mmosca authored May 28, 2023
2 parents 8cd3383 + 688a7e8 commit 2a627be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ option(SITL "SITL build for host system" OFF)

set(TOOLCHAIN_OPTIONS none arm-none-eabi host)
if (SITL)
set(TOOLCHAIN "host" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_HOST_APPLE)
set(MACOSX TRUE)
endif()
set(TOOLCHAIN "host" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
else()
set(TOOLCHAIN "arm-none-eabi" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
endif()
Expand Down
12 changes: 10 additions & 2 deletions cmake/host.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ set(CMAKE_CXX_COMPILER "g++${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "c++ compil
set(CMAKE_OBJCOPY "objcopy${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "objcopy tool")
set(CMAKE_OBJDUMP "objdump${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "objdump tool")
set(CMAKE_SIZE "size${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "size tool")
set(CMAKE_DEBUGGER "gdb${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "debugger")
if(CMAKE_HOST_APPLE)
set(CMAKE_DEBUGGER "lldb${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "debugger")
else()
set(CMAKE_DEBUGGER "gdb${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "debugger")
endif()
set(CMAKE_CPPFILT "c++filt${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "c++filt")

set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Build Type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})

set(debug_options "-Og -O0 -g")
set(release_options "-Os -DNDEBUG")
set(relwithdebinfo_options "-ggdb3 ${release_options}")
if(CMAKE_HOST_APPLE)
set(relwithdebinfo_options "-g ${release_options}")
else()
set(relwithdebinfo_options "-ggdb3 ${release_options}")
endif()

set(CMAKE_C_FLAGS_DEBUG ${debug_options} CACHE INTERNAL "c compiler flags debug")
set(CMAKE_CXX_FLAGS_DEBUG ${debug_options} CACHE INTERNAL "c++ compiler flags debug")
Expand Down
2 changes: 1 addition & 1 deletion cmake/main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function(setup_executable exe name)
set_target_properties(${exe} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
if(IS_RELEASE_BUILD)
if(IS_RELEASE_BUILD AND NOT CMAKE_HOST_APPLE)
set_target_properties(${exe} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
)
Expand Down
3 changes: 1 addition & 2 deletions cmake/sitl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ main_sources(SITL_SRC
)


if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(CMAKE_HOST_APPLE)
set(MACOSX ON)
endif()

Expand Down Expand Up @@ -61,7 +61,6 @@ if(NOT MACOSX)
)
else()
set(SITL_COMPILE_OPTIONS ${SITL_COMPILE_OPTIONS}
-Wno-missing-braces
)
endif()

Expand Down

0 comments on commit 2a627be

Please sign in to comment.