From: Teemu Murtola Date: Sun, 25 Aug 2013 04:24:28 +0000 (+0300) Subject: Add option to build a standalone mdrun binary only. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=6603baa6248477688d01eb720309a92aa9191e87;p=alexxy%2Fgromacs.git Add option to build a standalone mdrun binary only. This makes it again possible to build a leaner version of mdrun, without the whole wrapper binary. Enabling the option also removes unnecessary stuff from libgromacs, and suffixes it with _mdrun. This also replaces install-mdrun: 'make' builds only mdrun and 'make install' installs only mdrun when the new option is enabled. Part of #685. Change-Id: I8d309fadebfcdabc484d632a213ac52c558bfbf4 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d88211e9a..43750c1d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,7 @@ option(GMX_DEFAULT_SUFFIX "Use default suffixes for GROMACS binaries and libs (_ if(UNIX) option(GMX_SYMLINK_OLD_BINARY_NAMES "Create symbolic links for pre-5.0 binary names" ON) endif() +option(GMX_BUILD_MDRUN_ONLY "Build and install only the mdrun binary" OFF) if(UNIX) option(GMX_PREFER_STATIC_LIBS "When finding libraries prefer static archives (not available on non-*nix platforms and it will only work if static versions of external dependencies are available and found)!" OFF) @@ -318,6 +319,9 @@ else(GMX_DEFAULT_SUFFIX) message(STATUS "Using manually set library suffix: \"${GMX_LIBS_SUFFIX}\"") endif (NOT SUFFIX_QUIETLY) endif(GMX_DEFAULT_SUFFIX) +if (GMX_BUILD_MDRUN_ONLY) + set(GMX_LIBS_SUFFIX "_mdrun${GMX_LIBS_SUFFIX}") +endif () set(SUFFIX_QUIETLY TRUE CACHE INTERNAL "") set(PKG_CFLAGS "") @@ -1182,9 +1186,11 @@ else() # TODO: Propagate the above settings to the installed CMakeFiles.txt template # (from share/template/) set(PKG_CFLAGS "${PKG_CFLAGS} -DBOOST_NO_TYPEID -I${INCL_INSTALL_DIR}/gromacs/external/boost") - install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/external/boost/boost - DESTINATION ${INCL_INSTALL_DIR}/gromacs/external/boost - COMPONENT development) + if (NOT GMX_BUILD_MDRUN_ONLY) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/external/boost/boost + DESTINATION ${INCL_INSTALL_DIR}/gromacs/external/boost + COMPONENT development) + endif () endif() if (GMX_BUILD_FOR_COVERAGE) @@ -1196,10 +1202,12 @@ if (GMX_BUILD_FOR_COVERAGE) add_definitions(-DNDEBUG -DBOOST_DISABLE_ASSERTS -DGMX_DISABLE_ASSERTS) endif () -add_subdirectory(doxygen) -add_subdirectory(share) +if (NOT GMX_BUILD_MDRUN_ONLY) + add_subdirectory(doxygen) + add_subdirectory(share) + add_subdirectory(scripts) +endif () add_subdirectory(src) -add_subdirectory(scripts) # Issue a warning if NVIDIA GPUs were detected, but CUDA was not found. # Don't bother the user after the first configure pass. @@ -1229,14 +1237,18 @@ ADD_CUSTOM_TARGET(uninstall include(CTest) mark_as_advanced(BUILD_TESTING) -#gmxtests target builds all binaries required for running gmxtest -add_custom_target(gmxtests DEPENDS gmx links) IF(BUILD_TESTING) enable_testing() - add_subdirectory(tests) #"check" target builds and runs all tests add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) - add_dependencies(check gmxtests tests) + add_dependencies(check tests) + # TODO: This would be better within tests/CMakeLists.txt + if (NOT GMX_BUILD_MDRUN_ONLY) + #gmxtests target builds all binaries required for running gmxtest + add_custom_target(gmxtests DEPENDS gmx links) + add_dependencies(check gmxtests) + add_subdirectory(tests) + endif() #TODO: Add warning if NOT REGRESSIONTEST_PATH OR NOT GMX_XML that regression/unit tests are not run. ENDIF() diff --git a/admin/installguide/installguide.tex b/admin/installguide/installguide.tex index e890e46f92..74c0a71f99 100644 --- a/admin/installguide/installguide.tex +++ b/admin/installguide/installguide.tex @@ -715,9 +715,10 @@ routines - it is rare for this to be a bottleneck. \begin{verbatim} cmake .. -DCMAKE_TOOLCHAIN_FILE=BlueGeneQ-static-XL-C \ - -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix -make mdrun -make install-mdrun + -DCMAKE_PREFIX_PATH=/your/fftw/installation/prefix \ + -DGMX_BUILD_MDRUN_ONLY=ON +make +make install \end{verbatim} It is possible to configure and make the remaining \gromacs{} tools with the compute node toolchain, but as none of those tools are diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a18a3a3894..2f1d6f02a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,9 @@ configure_file(config.h.cmakein config.h) configure_file(buildinfo.h.cmakein buildinfo.h) -include(../cmake/BuildManPages.cmake) +if (NOT GMX_BUILD_MDRUN_ONLY) + include(../cmake/BuildManPages.cmake) +endif() if (BUILD_TESTING) add_custom_target(tests) if (GMX_BUILD_UNITTESTS) @@ -16,7 +18,9 @@ endif (BUILD_TESTING) add_subdirectory(gromacs) add_subdirectory(programs) -if(NOT GMX_FAHCORE) - add_subdirectory(ngmx) +if (NOT GMX_FAHCORE AND NOT GMX_BUILD_MDRUN_ONLY) + add_subdirectory(ngmx) +endif() +if (NOT GMX_FAHCORE) add_subdirectory(contrib) -endif(NOT GMX_FAHCORE) +endif() diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index 44c59fce56..1807870f92 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -34,31 +34,40 @@ set(LIBGROMACS_SOURCES) -add_subdirectory(legacyheaders) +function (gmx_install_headers DESTINATION) + if (NOT GMX_BUILD_MDRUN_ONLY) + if (DESTINATION) + set(DESTINATION ${INCL_INSTALL_DIR}/gromacs/${DESTINATION}) + else() + set(DESTINATION ${INCL_INSTALL_DIR}/gromacs) + endif() + install(FILES ${ARGN} DESTINATION ${DESTINATION} COMPONENT development) + endif() +endfunction () + add_subdirectory(gmxlib) add_subdirectory(mdlib) add_subdirectory(gmxpreprocess) -add_subdirectory(gmxana) -add_subdirectory(analysisdata) add_subdirectory(commandline) add_subdirectory(fft) add_subdirectory(linearalgebra) add_subdirectory(onlinehelp) add_subdirectory(options) -add_subdirectory(selection) -add_subdirectory(trajectoryanalysis) add_subdirectory(utility) - -file(GLOB LIBGROMACS_HEADERS *.h) -install(FILES ${LIBGROMACS_HEADERS} DESTINATION ${INCL_INSTALL_DIR}/gromacs - COMPONENT development) +if (NOT GMX_BUILD_MDRUN_ONLY) + add_subdirectory(legacyheaders) + add_subdirectory(gmxana) + add_subdirectory(analysisdata) + add_subdirectory(selection) + add_subdirectory(trajectoryanalysis) +endif () list(APPEND LIBGROMACS_SOURCES ${GMXLIB_SOURCES} ${MDLIB_SOURCES}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/version.h) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h - DESTINATION ${INCL_INSTALL_DIR}/gromacs - COMPONENT development) +file(GLOB LIBGROMACS_HEADERS *.h) +configure_file(version.h.cmakein version.h) +gmx_install_headers("" ${LIBGROMACS_HEADERS}) +gmx_install_headers("" ${CMAKE_CURRENT_BINARY_DIR}/version.h) # Add target that generates gitversion.c every time make is run # if git version info is requested @@ -115,14 +124,20 @@ set_target_properties(libgromacs PROPERTIES SOVERSION ${SOVERSION} COMPILE_FLAGS "${OpenMP_C_FLAGS}") -install(TARGETS libgromacs DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries) +# Only install the library in mdrun-only mode if it is actually necessary +# for the binary +if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS) + install(TARGETS libgromacs DESTINATION ${LIB_INSTALL_DIR} COMPONENT libraries) +endif() -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc - DESTINATION ${LIB_INSTALL_DIR}/pkgconfig - RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc" - COMPONENT development) +if (NOT GMX_BUILD_MDRUN_ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libgromacs.pc.cmakein + ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libgromacs.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig + RENAME "libgromacs${GMX_LIBS_SUFFIX}.pc" + COMPONENT development) +endif() if (INSTALL_CUDART_LIB) #can be set manual by user if (GMX_GPU) diff --git a/src/gromacs/analysisdata/CMakeLists.txt b/src/gromacs/analysisdata/CMakeLists.txt index e492426ffb..276fda2a05 100644 --- a/src/gromacs/analysisdata/CMakeLists.txt +++ b/src/gromacs/analysisdata/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2010,2011,2012, by the GROMACS development team, led by +# Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -41,9 +41,7 @@ set(ANALYSISDATA_PUBLIC_HEADERS arraydata.h dataframe.h datamodule.h) -install(FILES ${ANALYSISDATA_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/analysisdata - COMPONENT development) +gmx_install_headers(analysisdata ${ANALYSISDATA_PUBLIC_HEADERS}) add_subdirectory(modules) diff --git a/src/gromacs/analysisdata/modules/CMakeLists.txt b/src/gromacs/analysisdata/modules/CMakeLists.txt index 8a10932477..e61d205d3e 100644 --- a/src/gromacs/analysisdata/modules/CMakeLists.txt +++ b/src/gromacs/analysisdata/modules/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2010, by the GROMACS development team, led by +# Copyright (c) 2010,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -37,6 +37,4 @@ set(ANALYSISDATA_MODULES_PUBLIC_HEADERS displacement.h histogram.h plot.h) -install(FILES ${ANALYSISDATA_MODULES_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/analysisdata/modules - COMPONENT development) +gmx_install_headers(analysisdata/modules ${ANALYSISDATA_MODULES_PUBLIC_HEADERS}) diff --git a/src/gromacs/commandline/CMakeLists.txt b/src/gromacs/commandline/CMakeLists.txt index d694568ad7..c3dcf4ffbb 100644 --- a/src/gromacs/commandline/CMakeLists.txt +++ b/src/gromacs/commandline/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2012, by the GROMACS development team, led by +# Copyright (c) 2012,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -38,10 +38,10 @@ set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${COMMANDLINE_SOURCES} PARENT_SCOPE set(COMMANDLINE_PUBLIC_HEADERS cmdlinehelpwriter.h cmdlineparser.h) -install(FILES ${COMMANDLINE_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/commandline - COMPONENT development) +gmx_install_headers(commandline ${COMMANDLINE_PUBLIC_HEADERS}) -if (BUILD_TESTING) +# mdrun build does not include the selection machinery, which is used in the +# tests +if (BUILD_TESTING AND NOT GMX_BUILD_MDRUN_ONLY) add_subdirectory(tests) -endif (BUILD_TESTING) +endif() diff --git a/src/gromacs/fft/CMakeLists.txt b/src/gromacs/fft/CMakeLists.txt index 116b807ae3..26ca0bd1b9 100644 --- a/src/gromacs/fft/CMakeLists.txt +++ b/src/gromacs/fft/CMakeLists.txt @@ -53,9 +53,7 @@ set(LIBGROMACS_SOURCES set(FFT_PUBLIC_HEADERS fft.h) -install(FILES ${FFT_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/fft - COMPONENT development) +gmx_install_headers(fft ${FFT_PUBLIC_HEADERS}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/linearalgebra/CMakeLists.txt b/src/gromacs/linearalgebra/CMakeLists.txt index f7ec12ed8e..02ed0984bd 100644 --- a/src/gromacs/linearalgebra/CMakeLists.txt +++ b/src/gromacs/linearalgebra/CMakeLists.txt @@ -19,6 +19,4 @@ set(LINEARALGEBRA_PUBLIC_HEADERS matrix.h mtxio.h sparsematrix.h) -install(FILES ${LINEARALGEBRA_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/linearalgebra - COMPONENT development) +gmx_install_headers(linearalgebra ${LINEARALGEBRA_PUBLIC_HEADERS}) diff --git a/src/gromacs/onlinehelp/CMakeLists.txt b/src/gromacs/onlinehelp/CMakeLists.txt index bfe8236856..91934860f2 100644 --- a/src/gromacs/onlinehelp/CMakeLists.txt +++ b/src/gromacs/onlinehelp/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2012, by the GROMACS development team, led by +# Copyright (c) 2012,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -37,9 +37,7 @@ set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${ONLINEHELP_SOURCES} PARENT_SCOPE) set(ONLINEHELP_PUBLIC_HEADERS helptopicinterface.h) -install(FILES ${ONLINEHELP_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/onlinehelp - COMPONENT development) +gmx_install_headers(onlinehelp ${ONLINEHELP_PUBLIC_HEADERS}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/options/CMakeLists.txt b/src/gromacs/options/CMakeLists.txt index 6d633e2380..dc858de983 100644 --- a/src/gromacs/options/CMakeLists.txt +++ b/src/gromacs/options/CMakeLists.txt @@ -43,9 +43,7 @@ set(OPTIONS_PUBLIC_HEADERS optionflags.h options.h timeunitmanager.h) -install(FILES ${OPTIONS_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/options - COMPONENT development) +gmx_install_headers(options ${OPTIONS_PUBLIC_HEADERS}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/selection/CMakeLists.txt b/src/gromacs/selection/CMakeLists.txt index b207465775..64bf4199b6 100644 --- a/src/gromacs/selection/CMakeLists.txt +++ b/src/gromacs/selection/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2010,2012, by the GROMACS development team, led by +# Copyright (c) 2010,2012,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -44,9 +44,7 @@ set(SELECTION_PUBLIC_HEADERS selectionenums.h selectionoption.h selectionoptionmanager.h) -install(FILES ${SELECTION_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/selection - COMPONENT development) +gmx_install_headers(selection ${SELECTION_PUBLIC_HEADERS}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/trajectoryanalysis/CMakeLists.txt b/src/gromacs/trajectoryanalysis/CMakeLists.txt index 645b75c476..1b1becadf2 100644 --- a/src/gromacs/trajectoryanalysis/CMakeLists.txt +++ b/src/gromacs/trajectoryanalysis/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2010, by the GROMACS development team, led by +# Copyright (c) 2010,2013, by the GROMACS development team, led by # David van der Spoel, Berk Hess, Erik Lindahl, and including many # others, as listed in the AUTHORS file in the top-level source # directory and at http://www.gromacs.org. @@ -39,9 +39,7 @@ set(TRAJECTORYANALYSIS_PUBLIC_HEADERS analysismodule.h analysissettings.h cmdlinerunner.h) -install(FILES ${TRAJECTORYANALYSIS_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/trajectoryanalysis - COMPONENT development) +gmx_install_headers(trajectoryanalysis ${TRAJECTORYANALYSIS_PUBLIC_HEADERS}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/utility/CMakeLists.txt b/src/gromacs/utility/CMakeLists.txt index ae211ba7a7..d9de332c6d 100644 --- a/src/gromacs/utility/CMakeLists.txt +++ b/src/gromacs/utility/CMakeLists.txt @@ -53,12 +53,8 @@ set(UTILITY_PUBLIC_HEADERS programinfo.h stringutil.h uniqueptr.h) -install(FILES ${UTILITY_PUBLIC_HEADERS} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/utility - COMPONENT development) -install(FILES ${GENERATED_HEADER_CONFIG} - DESTINATION ${INCL_INSTALL_DIR}/gromacs/utility - COMPONENT development) +gmx_install_headers(utility ${UTILITY_PUBLIC_HEADERS}) +gmx_install_headers(utility ${GENERATED_HEADER_CONFIG}) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/programs/CMakeLists.txt b/src/programs/CMakeLists.txt index 4ddf1b5f36..02998643d4 100644 --- a/src/programs/CMakeLists.txt +++ b/src/programs/CMakeLists.txt @@ -38,6 +38,14 @@ file(GLOB MDRUN_SOURCES mdrun/*.c mdrun/*.cpp) if(GMX_FAHCORE) add_library(fahcore ${MDRUN_SOURCES}) +elseif(GMX_BUILD_MDRUN_ONLY) + add_executable(mdrun ${MDRUN_SOURCES} mdrun_main.cpp) + target_link_libraries(mdrun + ${GMX_EXTRA_LIBRARIES} libgromacs ${GMX_EXE_LINKER_FLAGS}) + set_target_properties(mdrun PROPERTIES + OUTPUT_NAME "mdrun${GMX_BINARY_SUFFIX}" + COMPILE_FLAGS "${OpenMP_C_FLAGS}") + install(TARGETS mdrun DESTINATION ${BIN_INSTALL_DIR} COMPONENT mdrun) else() file(GLOB GMX_EXECUTABLE_SOURCES gmx/*.c gmx/*.cpp) add_executable(gmx ${GMX_EXECUTABLE_SOURCES} ${MDRUN_SOURCES}) diff --git a/src/programs/mdrun_main.cpp b/src/programs/mdrun_main.cpp new file mode 100644 index 0000000000..632280312e --- /dev/null +++ b/src/programs/mdrun_main.cpp @@ -0,0 +1,42 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2013, by the GROMACS development team, led by + * David van der Spoel, Berk Hess, Erik Lindahl, and including many + * others, as listed in the AUTHORS file in the top-level source + * directory and at http://www.gromacs.org. + * + * GROMACS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 + * of the License, or (at your option) any later version. + * + * GROMACS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with GROMACS; if not, see + * http://www.gnu.org/licenses, or write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * If you want to redistribute modifications to GROMACS, please + * consider that scientific software is very special. Version + * control is crucial - bugs must be traceable. We will be happy to + * consider code for inclusion in the official distribution, but + * derived work must not be called official GROMACS. Details are found + * in the README & COPYING files - if they are missing, get the + * official version at http://www.gromacs.org. + * + * To help us fund GROMACS development, we humbly ask that you cite + * the research papers on the package. Check out http://www.gromacs.org. + */ +#include "mdrun/mdrun_main.h" + +#include "gromacs/commandline/cmdlinemodulemanager.h" + +int main(int argc, char *argv[]) +{ + return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, &gmx_mdrun); +}