mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: [CMake] detect source files with duplicate names
This commit is contained in:
parent
c77184aa35
commit
b0f8890ba5
|
@ -9,7 +9,17 @@ function(_add_files_tgt tgt)
|
|||
endif()
|
||||
|
||||
foreach(FILE IN LISTS PARAM_FILES)
|
||||
target_sources(openttd_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
||||
# Some IDEs are not happy with duplicated filenames, so we detect that before adding the file.
|
||||
get_target_property(${tgt}_FILES ${tgt} SOURCES)
|
||||
if(${tgt}_FILES MATCHES "/${FILE}(;|$)")
|
||||
string(REGEX REPLACE "(^|.+;)([^;]+/${FILE})(;.+|$)" "\\2" RES "${${tgt}_FILES}")
|
||||
# Ignore header files duplicates in 3rdparty.
|
||||
if(NOT (${FILE} MATCHES "\.h" AND (${RES} MATCHES "3rdparty" OR ${CMAKE_CURRENT_SOURCE_DIR} MATCHES "3rdparty")))
|
||||
message(FATAL_ERROR "${tgt}: ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} filename is a duplicate of ${RES}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_sources(${tgt} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
|
Loading…
Reference in New Issue