Merge "Merge branch release-4-6"
authorErik Lindahl <erik@kth.se>
Fri, 15 Nov 2013 20:51:19 +0000 (21:51 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 15 Nov 2013 20:51:19 +0000 (21:51 +0100)
CMakeLists.txt
src/config.h.cmakein
src/programs/CMakeLists.txt
src/programs/view/view.cpp

index 21f9a7381782865bbe5b3de2847d3063b889c1c1..13d6ab16dbe6857fcf1dc9b6a8316390d6c11ad1 100644 (file)
@@ -514,11 +514,12 @@ if (GMX_X11)
     find_package(X11)
     # X11 includes/libraries are only set in the ngmx subdirectory!
     if(NOT X11_FOUND)
-        message(WARNING "X11 include files and/or libraries were not found. Will not build the GROMACS X11-binaries, such as ngmx")
-    else()
-        set(HAVE_X11 1)
-        include_directories(${X11_INCLUDE_DIR})
+        message(FATAL_ERROR
+                "X11 include files and/or libraries were not found. "
+                "Set GMX_X11=OFF to compile without X11 support. "
+                "gmx view will not be available.")
     endif()
+    include_directories(${X11_INCLUDE_DIR})
 endif(GMX_X11)
 
 include(ThreadMPI)
index 657271e0263aa55bd19677c3d2a8571ba4d4c145..1ae7aec60d2edb678687b83bef8a5587cb38b46e 100644 (file)
 #cmakedefine HAVE_SYSTEM_INFO
 
 /* Define for X-Windows */
-#cmakedefine HAVE_X11
+#cmakedefine GMX_X11
 
 /* Enable x86 gcc inline assembly */
 #cmakedefine GMX_X86_GCC_INLINE_ASM
index a67168a5cfdb44171a8c9b5764d2b90c30d8a36b..94c7bab158460fb9b84b630dff87703d7fcb92e1 100644 (file)
 include_directories(${CMAKE_SOURCE_DIR}/src/gromacs/gmxpreprocess)
 
 file(GLOB MDRUN_SOURCES mdrun/*.c mdrun/*.cpp)
-if(X11_FOUND)
+if(GMX_X11)
     file(GLOB VIEW_SOURCES view/*.cpp)
 else()
     file(GLOB VIEW_SOURCES view/view.cpp)
-endif(X11_FOUND)
+endif()
 
 if(GMX_FAHCORE)
     add_library(fahcore ${MDRUN_SOURCES})
@@ -54,13 +54,11 @@ elseif(GMX_BUILD_MDRUN_ONLY)
 else()
     file(GLOB GMX_EXECUTABLE_SOURCES gmx/*.c gmx/*.cpp)
     add_executable(gmx ${GMX_EXECUTABLE_SOURCES} ${MDRUN_SOURCES} ${VIEW_SOURCES})
-    if(X11_FOUND)
-        target_link_libraries(gmx
-            ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS} ${X11_LIBRARIES})
-    else()
-        target_link_libraries(gmx
-            ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS})
-    endif(X11_FOUND)
+    target_link_libraries(gmx
+        ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS})
+    if(GMX_X11)
+        target_link_libraries(gmx ${X11_LIBRARIES})
+    endif()
     set_target_properties(gmx PROPERTIES
         OUTPUT_NAME "gmx${GMX_BINARY_SUFFIX}"
         COMPILE_FLAGS "${OpenMP_C_FLAGS}")
index b5d0613d564d0249952ea5816ef0dc2156a11060..e751cc098cae01999c4ca80a8c862e133f4ea465 100644 (file)
@@ -50,7 +50,7 @@
 #include "gromacs/fileio/confio.h"
 #include "gromacs/fileio/tpxio.h"
 
-#ifdef HAVE_X11
+#ifdef GMX_X11
 
 #include "Xstuff.h"
 #include "gromacs.bm"
 #include "molps.h"
 #include "nmol.h"
 
-/* Forward declarations: I Don't want all that init shit here */
-void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
-              const output_env_t oenv);
-
 static void dump_it(t_manager *man)
 {
     t_psdata ps;
@@ -262,65 +258,7 @@ static bool MainCallBack(t_x11 *x11, XEvent *event, Window w, void *data)
     }
     return result;
 }
-//! HAVE_X11
-#endif
-
-int gmx_view(int argc, char *argv[])
-{
-    const char  *desc[] = {
-        "[TT]view[tt] is the GROMACS trajectory viewer. This program reads a",
-        "trajectory file, a run input file and an index file and plots a",
-        "3D structure of your molecule on your standard X Window",
-        "screen. No need for a high end graphics workstation, it even",
-        "works on Monochrome screens.[PAR]",
-        "The following features have been implemented:",
-        "3D view, rotation, translation and scaling of your molecule(s),",
-        "labels on atoms, animation of trajectories,",
-        "hardcopy in PostScript format, user defined atom-filters",
-        "runs on MIT-X (real X), open windows and motif,",
-        "user friendly menus, option to remove periodicity, option to",
-        "show computational box.[PAR]",
-        "Some of the more common X command line options can be used: ",
-        "[TT]-bg[tt], [TT]-fg[tt] change colors, [TT]-font fontname[tt] changes the font."
-    };
-    const char  *bugs[] = {
-        "Balls option does not work",
-        "Some times dumps core without a good reason"
-    };
 
-    output_env_t oenv;
-    t_filenm     fnm[] = {
-        { efTRX, "-f", NULL, ffREAD },
-        { efTPX, NULL, NULL, ffREAD },
-        { efNDX, NULL, NULL, ffOPTRD }
-    };
-#define NFILE asize(fnm)
-
-    if (parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm,
-                          0, NULL, asize(desc), desc, asize(bugs), bugs, &oenv))
-    {
-#ifndef HAVE_X11
-        fprintf(stderr, "Compiled without X-Windows - can not run viewer.\n");
-#else
-        t_x11 *x11;
-
-        if ((x11 = GetX11(&argc, argv)) == NULL)
-        {
-            fprintf(stderr, "Can't connect to X Server.\n"
-                    "Check your DISPLAY environment variable\n");
-        }
-        else
-        {
-            init_gmx(x11, argv[0], NFILE, fnm, oenv);
-            x11->MainLoop(x11);
-            x11->CleanUp(x11);
-        }
-#endif
-    }
-    return 0;
-}
-
-#ifdef HAVE_X11
 static t_mentry  FileMenu[] = {
     { 0,  IDEXPORT,   false,  "Export..." },
     { 0,  IDDUMPWIN,  false,  "Print"     },
@@ -352,8 +290,8 @@ static const char *MenuTitle[MSIZE] = {
     "File", "Display", "Help"
 };
 
-void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
-              const output_env_t oenv)
+static void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
+                     const output_env_t oenv)
 {
     Pixmap                pm;
     t_gmx                *gmx;
@@ -430,6 +368,59 @@ void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
 
     ShowDlg(gmx->dlgs[edFilter]);
 }
+#endif
+
+int gmx_view(int argc, char *argv[])
+{
+    const char  *desc[] = {
+        "[TT]view[tt] is the GROMACS trajectory viewer. This program reads a",
+        "trajectory file, a run input file and an index file and plots a",
+        "3D structure of your molecule on your standard X Window",
+        "screen. No need for a high end graphics workstation, it even",
+        "works on Monochrome screens.[PAR]",
+        "The following features have been implemented:",
+        "3D view, rotation, translation and scaling of your molecule(s),",
+        "labels on atoms, animation of trajectories,",
+        "hardcopy in PostScript format, user defined atom-filters",
+        "runs on MIT-X (real X), open windows and motif,",
+        "user friendly menus, option to remove periodicity, option to",
+        "show computational box.[PAR]",
+        "Some of the more common X command line options can be used: ",
+        "[TT]-bg[tt], [TT]-fg[tt] change colors, [TT]-font fontname[tt] changes the font."
+    };
+    const char  *bugs[] = {
+        "Balls option does not work",
+        "Some times dumps core without a good reason"
+    };
+
+    output_env_t oenv;
+    t_filenm     fnm[] = {
+        { efTRX, "-f", NULL, ffREAD },
+        { efTPX, NULL, NULL, ffREAD },
+        { efNDX, NULL, NULL, ffOPTRD }
+    };
+#define NFILE asize(fnm)
+
+    if (parse_common_args(&argc, argv, PCA_CAN_TIME, NFILE, fnm,
+                          0, NULL, asize(desc), desc, asize(bugs), bugs, &oenv))
+    {
+#ifndef GMX_X11
+        fprintf(stderr, "Compiled without X-Windows - can not run viewer.\n");
+#else
+        t_x11 *x11;
 
-//! HAVE_X11
+        if ((x11 = GetX11(&argc, argv)) == NULL)
+        {
+            fprintf(stderr, "Can't connect to X Server.\n"
+                    "Check your DISPLAY environment variable\n");
+        }
+        else
+        {
+            init_gmx(x11, argv[0], NFILE, fnm, oenv);
+            x11->MainLoop(x11);
+            x11->CleanUp(x11);
+        }
 #endif
+    }
+    return 0;
+}