mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[CMAKE] Use -ffile-prefix-map for GCC builds
And also simplify the __RELFILE__ macro definition for the other cases
This commit is contained in:
parent
ed61512236
commit
683489ccf1
|
@ -44,13 +44,18 @@ include(sdk/cmake/compilerflags.cmake)
|
||||||
|
|
||||||
add_definitions(-D__REACTOS__)
|
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.
|
# 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})
|
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)
|
if(MSVC_IDE)
|
||||||
add_compile_flags("/MP")
|
add_compile_flags("/MP")
|
||||||
|
|
|
@ -69,18 +69,6 @@ if(DBG)
|
||||||
endif()
|
endif()
|
||||||
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
|
# Debugging
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
if(SEPARATE_DBG)
|
if(SEPARATE_DBG)
|
||||||
|
|
Loading…
Reference in a new issue