-
Notifications
You must be signed in to change notification settings - Fork 814
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
-ffile-prefix-map
for relative __FILE__
Fixes #4420
- Loading branch information
Showing
3 changed files
with
20 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Sets the __FILE__ macro value to be relative to CMAKE_SOURCE_DIR. | ||
function(set_relative_file_macro TARGET) | ||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") | ||
if((CMAKE_CXX_COMPILER_ID MATCHES "CLANG" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) | ||
OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8)) | ||
target_compile_options(${TARGET} PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}/=") | ||
else() | ||
get_target_property(_srcs ${TARGET} SOURCES) | ||
foreach(_src ${_srcs}) | ||
set_source_files_properties(${_src} PROPERTIES COMPILE_DEFINITIONS __FILE__="${_src}") | ||
endforeach() | ||
target_compile_options(${TARGET} PRIVATE -Wno-builtin-macro-redefined) | ||
endif() | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters