@@ -98,22 +98,13 @@ if(USE_CPP23)
9898 set (CPP23SupportLibrary "" )
9999 else ()
100100 add_definitions (-DDAEMON_CPP23_SUPPORT_LIBRARY_ENABLED=1)
101- # FIXME: Doesn't work?
102- add_compile_options ("-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR} /src=." )
103101
104102 if (CPP23SupportLibraryOldLibrary)
105103 message (STATUS "Using <stacktrace>: found ${CPP23SupportLibrary} (recommended to use libc++exp on this compiler version instead, but it wasn't found)" )
106104 else ()
107105 message (STATUS "Using <stacktrace>: found ${CPP23SupportLibrary} " )
108106 endif ()
109107 endif ()
110- elseif (MSVC )
111- # FIXME: Doesn't work in sgame/cgame?
112- string (REPLACE "/" "\\ " backslashed_dir ${CMAKE_CURRENT_SOURCE_DIR} /src)
113- add_compile_options ("/d1trimfile:${backslashed_dir} " )
114-
115- string (REPLACE "/" "\\ " backslashed_dir ${CMAKE_CURRENT_SOURCE_DIR} /daemon/src)
116- add_compile_options ("/d1trimfile:${backslashed_dir} " )
117108 endif ()
118109endif ()
119110
@@ -226,6 +217,24 @@ macro(try_exe_linker_flag PROP FLAG)
226217 endif ()
227218endmacro ()
228219
220+ # Stripping of absolute paths for __FILE__ / source_location
221+ # Also do without src/ to get libs/
222+ set (FILENAME_STRIP_DIRS "${CMAKE_CURRENT_SOURCE_DIR} /src" "${CMAKE_CURRENT_SOURCE_DIR} " )
223+ if (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL DAEMON_DIR)
224+ set (FILENAME_STRIP_DIRS ${FILENAME_STRIP_DIRS} "${DAEMON_DIR} /src" "${DAEMON_DIR} " )
225+ endif ()
226+ foreach (strip_dir ${FILENAME_STRIP_DIRS} )
227+ if (MSVC )
228+ string (REPLACE "/" "\\ " backslashed_dir ${strip_dir} )
229+ # set_c_cxx_flag can't be used because macros barf if the input contains backslashes
230+ # https://gitlab.kitware.com/cmake/cmake/-/issues/19281
231+ set (CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "/d1trimfile:${backslashed_dir} " )
232+ set (CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} "/d1trimfile:${backslashed_dir} " )
233+ else ()
234+ try_c_cxx_flag(PREFIX_MAP "-fmacro-prefix-map=${strip_dir} =." )
235+ endif ()
236+ endforeach ()
237+
229238if (BE_VERBOSE)
230239 set (WARNMODE "no-error=" )
231240else ()
0 commit comments