From: Teemu Murtola Date: Sun, 21 Sep 2014 11:11:48 +0000 (+0300) Subject: Introduce a variable to identify in-source build X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=b3ae494f455717ff3af6c25c1cb4b3fb86759373 Introduce a variable to identify in-source build This makes it easier to find all conditionals that test for it (in case someone may want to fix those), and makes the CMake code easier to read. Change-Id: Ic7df20cd9829080005d021e101c4559143bb3cc1 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 28faeb375a..d3e6720c42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -705,9 +705,7 @@ endif() option(GMX_BUILD_HELP "Build man pages, HTML help, and completions automatically (requires that compiled binaries can be executed on the build host)" OFF) mark_as_advanced(GMX_BUILD_HELP) -if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND - "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") - +if (GMX_BUILD_HELP AND SOURCE_IS_SOURCE_DISTRIBUTION AND BUILD_IS_INSOURCE) message(FATAL_ERROR "Rebuilding HTML and man pages is not supported for in-source " "builds from a source distribution. " diff --git a/cmake/gmxVersionInfo.cmake b/cmake/gmxVersionInfo.cmake index 6430211f29..c37b8cad67 100644 --- a/cmake/gmxVersionInfo.cmake +++ b/cmake/gmxVersionInfo.cmake @@ -83,6 +83,8 @@ # SOURCE_IS_GIT_REPOSITORY The source tree is a git repository. # Note that both can be false if the tree has been extracted, e.g., as a # tarball directly from git. +# Additionally, the following variable is defined: +# BUILD_IS_INSOURCE The build is happening in-source. # # This script also declares machinery to generate and obtain version # information from a git repository. This is enabled by default if the source @@ -185,6 +187,10 @@ endif() if (NOT EXISTS "${PROJECT_SOURCE_DIR}/admin/.isreposource") set(SOURCE_IS_SOURCE_DISTRIBUTION ON) endif() +set(BUILD_IS_INSOURCE OFF) +if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + set(BUILD_IS_INSOURCE ON) +endif() ##################################################################### # Manually maintained version info diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 6947156d36..cdb1fdcfc0 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -56,7 +56,7 @@ set(HTML_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") file(MAKE_DIRECTORY ${HTML_OUTPUT_DIR}) -if(${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) +if (BUILD_IS_INSOURCE) set(MARKDOWN_CONFIGURE_IS_POSSIBLE off) else() set(MARKDOWN_CONFIGURE_IS_POSSIBLE on) @@ -165,7 +165,7 @@ set(HTML_BUILD_IS_POSSIBLE OFF) # never need to know. if(GMX_BUILD_WEBPAGE AND GMX_BUILD_HELP AND - NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR} AND + NOT BUILD_IS_INSOURCE AND MARKDOWN_CONFIGURE_IS_POSSIBLE AND MANUAL_BUILD_IS_POSSIBLE AND PANDOC_EXECUTABLE AND diff --git a/docs/manual/CMakeLists.txt b/docs/manual/CMakeLists.txt index 0a012e04ff..ea6ccbb82a 100644 --- a/docs/manual/CMakeLists.txt +++ b/docs/manual/CMakeLists.txt @@ -32,7 +32,7 @@ # To help us fund GROMACS development, we humbly ask that you cite # the research papers on the package. Check out http://www.gromacs.org. -if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) +if (BUILD_IS_INSOURCE) # UseLATEX.cmake does not work with an in-source build message(STATUS "Cannot build the manual when building in the source directory") set(MANUAL_BUILD_IS_POSSIBLE OFF)