myx/MyxCMake/lib/macro/SkipExternalTarget.cmake

34 lines
944 B
CMake
Raw Normal View History

2022-10-08 18:00:28 +00:00
include_guard(GLOBAL)
# Пропуск целей, которые создаются автоматически в `CMAKE_BINARY_DIR`
macro(myx_skip_external_target NAME)
2022-10-08 19:23:10 +00:00
get_target_property(__type ${NAME} TYPE)
if(__type STREQUAL "INTERFACE_LIBRARY")
get_target_property(__sources ${NAME} INTERFACE_SOURCES)
2022-10-08 19:31:13 +00:00
foreach(iter ${__sources})
2022-10-08 19:23:10 +00:00
string(FIND ${iter} ${CMAKE_BINARY_DIR} __pos)
if(__pos EQUAL 0)
unset(__type)
unset(__pos)
unset(__sources)
return()
endif()
endforeach()
unset(__type)
unset(__pos)
unset(__sources)
else()
get_target_property(__source_dir ${NAME} SOURCE_DIR)
string(FIND ${__source_dir} ${CMAKE_BINARY_DIR} __pos)
if(__pos EQUAL 0)
unset(__type)
unset(__pos)
unset(__source_dir)
return()
endif()
2022-10-08 18:00:28 +00:00
unset(__pos)
unset(__source_dir)
endif()
2022-10-08 19:23:10 +00:00
unset(__type)
2022-10-08 18:00:28 +00:00
endmacro(myx_skip_external_target NAME)