Enable debugging on Mac via VSCode
@@ -19,8 +19,31 @@ IF((NOT WIN32) AND (NOT MACOS) AND (NOT IOS) AND (NOT AOSP) AND (NOT LINUX))
RETURN()
ENDIF()
-# TODO: specify c++ 14
-#ADD_DEFINITIONS(-std=c++14)
+IF(MACOS)
+ # Incredibly, for both clang and g++, while a single compile-and-link
+ # invocation will create an executable.dSYM/ dir with debug info,
+ # with separate compilation the final link does NOT create the
+ # dSYM dir.
+ # The "dsymutil" program will create the dSYM dir for us.
+ # Strangely it takes in the executable and not the object
+ # files even though it's the latter that contain the debug info.
+ # Thus it will only work if the object files are still sitting around.
+ find_program(DSYMUTIL_PROGRAM dsymutil)
+ if (DSYMUTIL_PROGRAM)
+ set(CMAKE_C_LINK_EXECUTABLE
+ "${CMAKE_C_LINK_EXECUTABLE}"
+ "${DSYMUTIL_PROGRAM} <TARGET>")
+ set(CMAKE_C_CREATE_SHARED_LIBRARY
+ "${CMAKE_C_CREATE_SHARED_LIBRARY}"
+ "${DSYMUTIL_PROGRAM} <TARGET>")
+ set(CMAKE_CXX_LINK_EXECUTABLE
+ "${CMAKE_CXX_LINK_EXECUTABLE}"
+ "${DSYMUTIL_PROGRAM} <TARGET>")
+ set(CMAKE_CXX_CREATE_SHARED_LIBRARY
+ "${CMAKE_CXX_CREATE_SHARED_LIBRARY}"
+ "${DSYMUTIL_PROGRAM} <TARGET>")
+ endif ()
+ENDIF()
enable_testing() # needed on top-level CMakeLists.txt
