Commit 72c1042d authored by jcfr's avatar jcfr

ENH: Prevent in source build

* Adapated from ITKv4/CMake/PreventInSourceBuilds.cmake

git-svn-id: http://svn.slicer.org/Slicer4/trunk@17361 3bd1e089-480b-0410-8dfb-8563597acbee
parent 02257d87
# Adapated from ITKv4/CMake/PreventInSourceBuilds.cmake
#
# This function will prevent in-source builds
function(AssureOutOfSourceBuilds)
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
# disallow in-source builds
if("${srcdir}" STREQUAL "${bindir}")
message("######################################################")
message("# Slicer should not be configured & built in the Slicer source directory")
message("# You must run cmake in a build directory.")
message("# For example:")
message("# mkdir Slicer-Sandbox ; cd Slicer-sandbox")
message("# svn co http://svn.slicer.org/Slicer4/trunk Slicer4 # or download & unpack the source tarball")
message("# mkdir Slicer-build")
message("# this will create the following directory structure")
message("#")
message("# Slicer-Sandbox")
message("# +--Slicer")
message("# +--Slicer-SuperBuild")
message("#")
message("# Then you can proceed to configure and build")
message("# by using the following commands")
message("#")
message("# cd Slicer-build")
message("# cmake ../Slicer # or ccmake, or cmake-gui ")
message("# make")
message("#")
message("# NOTE: Given that you already tried to make an in-source build")
message("# CMake have already created several files & directories")
message("# in your source tree. run 'git status' to find them and")
message("# remove them by doing:")
message("#")
message("# cd Slicer-Sandbox/Slicer")
message("# git clean -n -d")
message("# git clean -f -d")
message("# git checkout --")
message("#")
message("######################################################")
message(FATAL_ERROR "Quitting configuration")
endif()
endfunction()
AssureOutOfSourceBuilds()
......@@ -20,6 +20,23 @@ if(POLICY CMP0017)
cmake_policy(SET CMP0017 OLD)
endif()
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${Slicer_SOURCE_DIR}/CMake
${Slicer_SOURCE_DIR}/Extensions/CMake
${CMAKE_MODULE_PATH}
)
set(Slicer_CMAKE_DIR ${Slicer_SOURCE_DIR}/CMake)
set(Slicer_EXTENSIONS_CMAKE_DIR ${Slicer_SOURCE_DIR}/Extensions/CMake)
#-----------------------------------------------------------------------------
# Sanity checks
#------------------------------------------------------------------------------
include(PreventInSourceBuilds)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#-----------------------------------------------------------------------------
......@@ -38,18 +55,6 @@ endif()
set(Slicer_EXPORT_HEADER_TEMPLATE "${Slicer_SOURCE_DIR}/qSlicerExport.h.in")
set(Slicer_LOGOS_RESOURCE "${Slicer_SOURCE_DIR}/Resources/qSlicerLogos.qrc")
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
${Slicer_SOURCE_DIR}/CMake
${Slicer_SOURCE_DIR}/Extensions/CMake
${CMAKE_MODULE_PATH}
)
set(Slicer_CMAKE_DIR ${Slicer_SOURCE_DIR}/CMake)
set(Slicer_EXTENSIONS_CMAKE_DIR ${Slicer_SOURCE_DIR}/Extensions/CMake)
#-----------------------------------------------------------------------------
# CMake Function(s) and Macro(s)
#-----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment