[CMAKE] Use -ffile-prefix-map for GCC builds

And also simplify the __RELFILE__ macro definition for the other cases
This commit is contained in:
Jérôme Gardou 2020-09-18 16:19:46 +02:00 committed by Jérôme Gardou
parent ed61512236
commit 683489ccf1
2 changed files with 10 additions and 17 deletions

View file

@ -44,13 +44,18 @@ include(sdk/cmake/compilerflags.cmake)
add_definitions(-D__REACTOS__)
# Double escape, since CMake unescapes before putting it on the command-line, where it's unescaped again by GCC/CL.
add_definitions(-DREACTOS_SOURCE_DIR="${REACTOS_SOURCE_DIR}")
add_definitions(-DREACTOS_BINARY_DIR="${REACTOS_BINARY_DIR}")
# There doesn't seem to be a standard for __FILE__ being relative or absolute, so detect it at runtime.
file(RELATIVE_PATH _PATH_PREFIX ${REACTOS_BINARY_DIR} ${REACTOS_SOURCE_DIR})
add_compile_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof REACTOS_SOURCE_DIR]")
if (GCC AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0"))
# Thankfully, GCC has this
add_compile_options(-ffile-prefix-map=${REACTOS_SOURCE_DIR}=)
add_compile_options(-ffile-prefix-map=${_PATH_PREFIX}=)
else()
string(LENGTH ${_PATH_PREFIX} _PATH_PREFIX_LENGTH)
string(LENGTH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_LENGTH)
math(EXPR REACTOS_SOURCE_DIR_LENGTH "${REACTOS_SOURCE_DIR_LENGTH} + 1")
add_compile_definitions("__RELFILE__=&__FILE__[__FILE__[0] == '.' ? ${_PATH_PREFIX_LENGTH} : ${REACTOS_SOURCE_DIR_LENGTH}]")
endif()
if(MSVC_IDE)
add_compile_flags("/MP")

View file

@ -69,18 +69,6 @@ if(DBG)
endif()
endif()
#bug
#file(TO_NATIVE_PATH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_NATIVE)
#workaround
set(REACTOS_SOURCE_DIR_NATIVE ${REACTOS_SOURCE_DIR})
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
string(REPLACE "/" "\\" REACTOS_SOURCE_DIR_NATIVE ${REACTOS_SOURCE_DIR})
endif()
if((NOT CMAKE_C_COMPILER_ID STREQUAL "Clang") AND (NOT SEPARATE_DBG))
add_compile_flags("-fdebug-prefix-map=\"${REACTOS_SOURCE_DIR_NATIVE}\"=ReactOS")
endif()
# Debugging
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
if(SEPARATE_DBG)