Skip to content

Commit 7394286

Browse files
alisanikiforovasophimao
authored andcommitted
Security: Remove hardcoded paths being built into libraries
1 parent 96963e2 commit 7394286

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ if(ACL_TSAN)
220220
endforeach()
221221
endif()
222222

223+
function(define_file_basename_for_sources targetname)
224+
get_target_property(source_files "${targetname}" SOURCES)
225+
foreach(sourcefile ${source_files})
226+
# Add the FILE_BASENAME=filename compile definition to the list.
227+
get_filename_component(basename "${sourcefile}" NAME)
228+
# Set the updated compile definitions on the source file.
229+
set_property(
230+
SOURCE "${sourcefile}" APPEND
231+
PROPERTY COMPILE_DEFINITIONS "__FILE__=\"${basename}\"")
232+
endforeach()
233+
endfunction()
234+
223235
include(CPack)
224236
include(CTest)
225237

lib/acl_hash/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ set_property(TARGET acl_hash PROPERTY PUBLIC_HEADER
88
include/acl_hash/acl_hash.h
99
)
1010

11+
12+
define_file_basename_for_sources(acl_hash)
13+
1114
install(TARGETS acl_hash
1215
COMPONENT acl_hash
1316
EXCLUDE_FROM_ALL

lib/acl_threadsupport/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set_property(TARGET acl_threadsupport PROPERTY PUBLIC_HEADER
88
include/acl_threadsupport/acl_threadsupport.h
99
)
1010

11+
define_file_basename_for_sources(acl_threadsupport)
12+
1113
install(TARGETS acl_threadsupport
1214
COMPONENT acl_threadsupport
1315
EXCLUDE_FROM_ALL

lib/pkg_editor/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ if(ZLIB_FOUND)
2222
target_link_libraries(pkg_editor PRIVATE ZLIB::ZLIB)
2323
endif()
2424

25+
define_file_basename_for_sources(pkg_editor)
26+
2527
install(TARGETS pkg_editor
2628
COMPONENT pkg_editor
2729
EXCLUDE_FROM_ALL

0 commit comments

Comments
 (0)