Introduce a variable to identify in-source build
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 21 Sep 2014 11:11:48 +0000 (14:11 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 21 Sep 2014 11:11:48 +0000 (14:11 +0300)
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

CMakeLists.txt
cmake/gmxVersionInfo.cmake
docs/CMakeLists.txt
docs/manual/CMakeLists.txt

index 28faeb375a5f8afea0ce8ec6288b05daf09e3c45..d3e6720c424f9885ce37444056127471e69db310 100644 (file)
@@ -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. "
index 6430211f29ef31c8f5be264db98ab49345e91246..c37b8cad674505d784fdf7b0f91c818975e046c4 100644 (file)
@@ -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
index 6947156d36a78ac82e5d0f745bbea659dda48a22..cdb1fdcfc0ca78d5450363e7aa4decf25a60330f 100644 (file)
@@ -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
index 0a012e04ff9e5351bf8cfb4e6de4367933abb426..ea6ccbb82a1a5b2c1aecd56714d6e16b21c9ca9e 100644 (file)
@@ -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)