summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt20
-rw-r--r--bench/CMakeLists.txt1
-rw-r--r--editor/CMakeLists.txt1
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--userconfig-sthalik@Windows-Clang.cmake6
5 files changed, 27 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f6b7b01..f4647544 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@ set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_INSTALL_MESSAGE LAZY)
+set(CMAKE_COLOR_DIAGNOSTICS ON)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
@@ -212,6 +213,25 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wno-subobject-linkage -Wno-parentheses -Wno-overloaded-virtual)
endif()
+function(fm_add_debug_info self)
+ if(NOT MSVC AND NOT APPLE)
+ if(CMAKE_RUNTIME_OUTPUT_DIRECTORY STREQUAL "")
+ message(FATAL_ERROR "")
+ endif()
+ if(NOT CMAKE_OBJCOPY)
+ message(FATAL_ERROR "objcopy missing")
+ endif()
+ add_custom_command(TARGET ${self} POST_BUILD
+ COMMAND "${CMAKE_OBJCOPY}" --only-keep-debug "${self}.exe" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${self}.exe.debug"
+ COMMAND "${CMAKE_OBJCOPY}" --strip-all "${self}.exe" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${self}.exe"
+ COMMAND "${CMAKE_OBJCOPY}" --add-gnu-debuglink=${self}.exe.debug "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${self}.exe"
+ BYPRODUCTS "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${self}.exe.debug"
+ WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
+ )
+ install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${self}.exe.debug" DESTINATION bin)
+ endif()
+endfunction()
+
add_subdirectory(src)
add_subdirectory(main)
add_subdirectory(draw)
diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt
index ecce9dee..26afb999 100644
--- a/bench/CMakeLists.txt
+++ b/bench/CMakeLists.txt
@@ -22,3 +22,4 @@ endif()
target_link_libraries(${self} PUBLIC ${self}_o floormat-serialize floormat-draw floormat)
install(TARGETS ${self} RUNTIME DESTINATION bin)
+fm_add_debug_info(${self})
diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt
index e53e36d8..40c7016f 100644
--- a/editor/CMakeLists.txt
+++ b/editor/CMakeLists.txt
@@ -32,3 +32,4 @@ endif()
target_link_libraries(${self} PRIVATE ${self}_o floormat-main floormat-serialize floormat-draw floormat)
install(TARGETS ${self} RUNTIME DESTINATION bin)
+fm_add_debug_info(${self})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f8048278..ab11d536 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -19,6 +19,7 @@ if (FLOORMAT_ASAN)
endif()
install(TARGETS ${self} RUNTIME DESTINATION bin)
+fm_add_debug_info(${self})
set(save-dir "${CMAKE_BINARY_DIR}/test/save")
file(REMOVE_RECURSE "${save-dir}")
diff --git a/userconfig-sthalik@Windows-Clang.cmake b/userconfig-sthalik@Windows-Clang.cmake
index 0c88d7d1..a3070d08 100644
--- a/userconfig-sthalik@Windows-Clang.cmake
+++ b/userconfig-sthalik@Windows-Clang.cmake
@@ -28,10 +28,12 @@ endif()
set(OpenCV_DIR "f:/dev/opentrack-depends/opencv/build-clang-amd64/install" CACHE PATH "" FORCE)
set(CMAKE_INSTALL_MESSAGE NEVER)
+set(_debug_info_flags "-ggdb3 -gsplit-dwarf -gcolumn-info -gdwarf-aranges -gz=zlib")
+
sets(STRING
CMAKE_C_FLAGS ""
- CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb -gcolumn-info -gmodules -gdwarf-aranges -gz=zlib -fstack-protector-all"
- CMAKE_C_FLAGS_RELEASE "-O3 -g -ggdb -gsplit-dwarf -ffast-math -march=nehalem -mtune=native -mpopcnt -mavx -fomit-frame-pointer -fno-stack-protector"
+ CMAKE_C_FLAGS_DEBUG "-O0 ${_debug_info_flags} -fstack-protector-all"
+ CMAKE_C_FLAGS_RELEASE "-O3 ${_debug_info_flags} -ffast-math -march=nehalem -mtune=native -mpopcnt -mavx -fomit-frame-pointer -fno-stack-protector"
CMAKE_EXE_LINKER_FLAGS_DEBUG ""
CMAKE_SHARED_LINKER_FLAGS_DEBUG ""
)