2022-10-01 13:42:36 +00:00
|
|
|
|
#[=======================================================================[.rst:
|
|
|
|
|
|
|
|
|
|
Запись результатов сборки проекта внутрь иерархии каталогов с исходными текстами
|
|
|
|
|
приводит к засорению файлами формируемыми на этапе сборки, которые затрудняют
|
|
|
|
|
разработку, поиск в оригинальных файлах и мешают ориентироваться в проекте.
|
|
|
|
|
При работе с несколькими типами сборки, например, отладка и выпуск, появляется
|
|
|
|
|
необходимость корректного полного удаления результатов предыдущего варианта.
|
|
|
|
|
|
|
|
|
|
#]=======================================================================]
|
2022-09-28 23:46:29 +00:00
|
|
|
|
|
|
|
|
|
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)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(cmake_install_prefix STREQUAL cmake_source_dir)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(cmake_install_prefix STREQUAL project_binary_dir)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(cmake_install_prefix STREQUAL project_source_dir)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(cmake_binary_dir STREQUAL cmake_source_dir)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(project_binary_dir STREQUAL project_source_dir)
|
2022-10-04 03:59:45 +00:00
|
|
|
|
myx_message_fatal_error(
|
2022-09-28 23:46:29 +00:00
|
|
|
|
"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)
|