myx/lib/DirectoriesGuards.cmake
2022-09-29 02:46:29 +03:00

51 lines
2.1 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Запись результатов сборки проекта внутрь иерархии каталогов с исходными текстами
# приводит к засорению файлами формируемыми на этапе сборки, которые затрудняют
# разработку, поиск в оригинальных файлах и мешают ориентироваться в проекте.
# При работе с несколькими типами сборки, например, отладка и выпуск, появляется
# необходимость корректного полного удаления результатов предыдущего варианта.
include_guard(GLOBAL)
get_filename_component(cmake_source_dir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(cmake_binary_dir "${CMAKE_BINARY_DIR}" REALPATH)
get_filename_component(project_source_dir "${PROJECT_SOURCE_DIR}" REALPATH)
get_filename_component(project_binary_dir "${PROJECT_BINARY_DIR}" REALPATH)
get_filename_component(cmake_install_prefix "${CMAKE_INSTALL_PREFIX}" REALPATH)
if(cmake_install_prefix STREQUAL cmake_binary_dir)
myx_message_error(
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL cmake_source_dir)
myx_message_error(
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL project_binary_dir)
myx_message_error(
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL project_source_dir)
myx_message_error(
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_binary_dir STREQUAL cmake_source_dir)
myx_message_error(
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
endif()
if(project_binary_dir STREQUAL project_source_dir)
myx_message_error(
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
endif()
unset(cmake_source_dir)
unset(cmake_binary_dir)
unset(project_source_dir)
unset(project_binary_dir)
unset(cmake_install_prefix)