From 09dd1e79075321f629995192009f843d3c41cd44 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Wed, 4 Nov 2020 08:03:33 +0000 Subject: [PATCH] Establish `api/` as the home for installed headers. Prepare to remove `src/` from global build tree include path. * Create `api/legacy` for the new `legacy_api` target. * Move gmxapi and nblib public header dependencies to `api/legacy`. This change is orthogonal to the clarification of the public API. The purpose is to normalize the way we manage installed headers. gmxapi and nblib already provide their public interfaces through files and CMake targets in `api/`. For the remaining installed libgromacs headers, the `legacy_api` target provides a transitional home as the modules are individually updated in terms of CMake machinery and as the legacy API functionality is reexamined. Refs #3288 --- admin/gitlab-ci/gromacs.gitlab-ci.yml | 2 +- api/CMakeLists.txt | 3 + api/legacy/CMakeLists.txt | 65 ++++++++++ .../legacy/include}/gromacs/fileio/confio.h | 0 .../include}/gromacs/fileio/filetypes.h | 2 +- .../legacy/include}/gromacs/fileio/oenv.h | 0 .../legacy/include}/gromacs/fileio/pdbio.h | 0 .../legacy/include}/gromacs/fileio/tpxio.h | 0 .../legacy/include}/gromacs/math/do_fit.h | 0 .../legacy/include}/gromacs/math/functions.h | 2 +- .../legacy/include}/gromacs/math/units.h | 2 +- .../legacy/include}/gromacs/math/utilities.h | 0 .../legacy/include}/gromacs/math/vec.h | 0 .../legacy/include}/gromacs/math/vectypes.h | 0 .../gromacs/restraint/restraintpotential.h | 2 +- .../include}/gromacs/utility/arrayref.h | 0 .../gromacs/utility/basedefinitions.h | 0 .../gromacs/utility/current_function.h | 2 +- .../include}/gromacs/utility/exceptions.h | 0 .../include}/gromacs/utility/gmxassert.h | 2 +- .../include}/gromacs/utility/listoflists.h | 0 .../legacy/include}/gromacs/utility/real.h | 0 api/legacy/version.h.cmakein | 105 ++++++++++++++++ api/nblib/CMakeLists.txt | 2 + api/nblib/tests/CMakeLists.txt | 1 + docs/dev-manual/includestyle.rst | 35 ++---- docs/doxygen/Doxyfile-common.cmakein | 6 +- docs/doxygen/check-source.py | 31 ++--- docs/doxygen/cycle-suppressions.txt | 1 - docs/doxygen/suppressions.txt | 116 ++++++++++-------- .../sample_restraint/src/cpp/CMakeLists.txt | 2 +- .../sample_restraint/tests/CMakeLists.txt | 2 +- src/gromacs/CMakeLists.txt | 7 +- src/gromacs/analysisdata/tests/CMakeLists.txt | 1 + src/gromacs/fileio/CMakeLists.txt | 11 -- src/gromacs/fileio/confio.cpp | 2 +- src/gromacs/fileio/filetypes.cpp | 2 +- src/gromacs/fileio/oenv.cpp | 2 +- src/gromacs/fileio/pdbio.cpp | 2 +- src/gromacs/fileio/tests/CMakeLists.txt | 1 + src/gromacs/fileio/tpxio.cpp | 2 +- src/gromacs/linearalgebra/CMakeLists.txt | 5 + src/gromacs/math/CMakeLists.txt | 19 --- src/gromacs/math/do_fit.cpp | 2 +- src/gromacs/math/functions.cpp | 4 +- src/gromacs/math/units.cpp | 2 +- src/gromacs/math/utilities.cpp | 2 +- src/gromacs/mdrunutility/tests/CMakeLists.txt | 1 + src/gromacs/modularsimulator/CMakeLists.txt | 1 + src/gromacs/restraint/CMakeLists.txt | 4 +- src/gromacs/selection/CMakeLists.txt | 2 + src/gromacs/utility/CMakeLists.txt | 11 -- src/gromacs/utility/exceptions.cpp | 2 +- src/gromacs/utility/gmxassert.cpp | 4 +- src/programs/CMakeLists.txt | 12 +- src/programs/mdrun/tests/CMakeLists.txt | 1 + src/testutils/CMakeLists.txt | 2 + 57 files changed, 320 insertions(+), 167 deletions(-) create mode 100644 api/legacy/CMakeLists.txt rename {src => api/legacy/include}/gromacs/fileio/confio.h (100%) rename {src => api/legacy/include}/gromacs/fileio/filetypes.h (97%) rename {src => api/legacy/include}/gromacs/fileio/oenv.h (100%) rename {src => api/legacy/include}/gromacs/fileio/pdbio.h (100%) rename {src => api/legacy/include}/gromacs/fileio/tpxio.h (100%) rename {src => api/legacy/include}/gromacs/math/do_fit.h (100%) rename {src => api/legacy/include}/gromacs/math/functions.h (99%) rename {src => api/legacy/include}/gromacs/math/units.h (98%) rename {src => api/legacy/include}/gromacs/math/utilities.h (100%) rename {src => api/legacy/include}/gromacs/math/vec.h (100%) rename {src => api/legacy/include}/gromacs/math/vectypes.h (100%) rename {src => api/legacy/include}/gromacs/restraint/restraintpotential.h (99%) rename {src => api/legacy/include}/gromacs/utility/arrayref.h (100%) rename {src => api/legacy/include}/gromacs/utility/basedefinitions.h (100%) rename {src => api/legacy/include}/gromacs/utility/current_function.h (97%) rename {src => api/legacy/include}/gromacs/utility/exceptions.h (100%) rename {src => api/legacy/include}/gromacs/utility/gmxassert.h (98%) rename {src => api/legacy/include}/gromacs/utility/listoflists.h (100%) rename {src => api/legacy/include}/gromacs/utility/real.h (100%) create mode 100644 api/legacy/version.h.cmakein diff --git a/admin/gitlab-ci/gromacs.gitlab-ci.yml b/admin/gitlab-ci/gromacs.gitlab-ci.yml index f5c9ea23ca..a7ec874ed8 100644 --- a/admin/gitlab-ci/gromacs.gitlab-ci.yml +++ b/admin/gitlab-ci/gromacs.gitlab-ci.yml @@ -225,7 +225,7 @@ gromacs:gcc-7:configure: image: gromacs/cmake-3.13.0-gcc-7-amdopencl-clfft-openmpi-master variables: CMAKE_SIMD_OPTIONS: "-DGMX_SIMD=AVX2_256" - CMAKE_EXTRA_OPTIONS: "-DGMX_EXTERNAL_CLFFT=ON" + CMAKE_EXTRA_OPTIONS: "-DGMX_EXTERNAL_CLFFT=ON -DGMX_INSTALL_LEGACY_API=ON" COMPILER_MAJOR_VERSION: 7 gromacs:gcc-8-cuda-11.0:configure: diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 80375188fa..c71f607fe6 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -32,6 +32,9 @@ # To help us fund GROMACS development, we humbly ask that you cite # the research papers on the package. Check out http://www.gromacs.org. +# The legacy public API headers may still be installed, +# but may be removed or changed without warning. +add_subdirectory(legacy) # Activate targets for new C++ API components and docs. if(GMX_NATIVE_WINDOWS OR GMX_BUILD_MDRUN_ONLY) diff --git a/api/legacy/CMakeLists.txt b/api/legacy/CMakeLists.txt new file mode 100644 index 0000000000..116bf49ada --- /dev/null +++ b/api/legacy/CMakeLists.txt @@ -0,0 +1,65 @@ +# +# This file is part of the GROMACS molecular simulation package. +# +# Copyright (c) 2020, by the GROMACS development team, led by +# Mark Abraham, David van der Spoel, Berk Hess, and 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. + +# The legacy installed API consists of headers that are not considered +# to be maintainable in terms of a stable API specification. These headers +# will no longer be available to install in a future release. + +# Note: Any usage requirements that should be transitive should be added to +# this INTERFACE target. Compiler and linker options (that do not need to +# be propagated when linking to the `common` target) can be added directly +# to the `common` target. +add_library(legacy_api INTERFACE) +target_include_directories(legacy_api INTERFACE + $ + $ + $) + +configure_file(version.h.cmakein include/gromacs/version.h) + +# Allow an export target for legacy_api since it is a dependency of the +# installable libgromacs target. +install(TARGETS legacy_api + EXPORT libgromacs + INCLUDES DESTINATION include) + +if(GMX_INSTALL_LEGACY_API) + # Install public header directories. + install(DIRECTORY include/gromacs + DESTINATION include) + + # Install "configured" files from the build tree. + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/gromacs/version.h + DESTINATION include/gromacs) +endif() diff --git a/src/gromacs/fileio/confio.h b/api/legacy/include/gromacs/fileio/confio.h similarity index 100% rename from src/gromacs/fileio/confio.h rename to api/legacy/include/gromacs/fileio/confio.h diff --git a/src/gromacs/fileio/filetypes.h b/api/legacy/include/gromacs/fileio/filetypes.h similarity index 97% rename from src/gromacs/fileio/filetypes.h rename to api/legacy/include/gromacs/fileio/filetypes.h index d56e1997b1..b3bad3c783 100644 --- a/src/gromacs/fileio/filetypes.h +++ b/api/legacy/include/gromacs/fileio/filetypes.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/fileio/oenv.h b/api/legacy/include/gromacs/fileio/oenv.h similarity index 100% rename from src/gromacs/fileio/oenv.h rename to api/legacy/include/gromacs/fileio/oenv.h diff --git a/src/gromacs/fileio/pdbio.h b/api/legacy/include/gromacs/fileio/pdbio.h similarity index 100% rename from src/gromacs/fileio/pdbio.h rename to api/legacy/include/gromacs/fileio/pdbio.h diff --git a/src/gromacs/fileio/tpxio.h b/api/legacy/include/gromacs/fileio/tpxio.h similarity index 100% rename from src/gromacs/fileio/tpxio.h rename to api/legacy/include/gromacs/fileio/tpxio.h diff --git a/src/gromacs/math/do_fit.h b/api/legacy/include/gromacs/math/do_fit.h similarity index 100% rename from src/gromacs/math/do_fit.h rename to api/legacy/include/gromacs/math/do_fit.h diff --git a/src/gromacs/math/functions.h b/api/legacy/include/gromacs/math/functions.h similarity index 99% rename from src/gromacs/math/functions.h rename to api/legacy/include/gromacs/math/functions.h index 35150b3ddd..271e1cf760 100644 --- a/src/gromacs/math/functions.h +++ b/api/legacy/include/gromacs/math/functions.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2016,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2016,2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/math/units.h b/api/legacy/include/gromacs/math/units.h similarity index 98% rename from src/gromacs/math/units.h rename to api/legacy/include/gromacs/math/units.h index 865fd31175..bb9f8075ac 100644 --- a/src/gromacs/math/units.h +++ b/api/legacy/include/gromacs/math/units.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2012,2014,2015,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2012,2014,2015,2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/math/utilities.h b/api/legacy/include/gromacs/math/utilities.h similarity index 100% rename from src/gromacs/math/utilities.h rename to api/legacy/include/gromacs/math/utilities.h diff --git a/src/gromacs/math/vec.h b/api/legacy/include/gromacs/math/vec.h similarity index 100% rename from src/gromacs/math/vec.h rename to api/legacy/include/gromacs/math/vec.h diff --git a/src/gromacs/math/vectypes.h b/api/legacy/include/gromacs/math/vectypes.h similarity index 100% rename from src/gromacs/math/vectypes.h rename to api/legacy/include/gromacs/math/vectypes.h diff --git a/src/gromacs/restraint/restraintpotential.h b/api/legacy/include/gromacs/restraint/restraintpotential.h similarity index 99% rename from src/gromacs/restraint/restraintpotential.h rename to api/legacy/include/gromacs/restraint/restraintpotential.h index 72bf0dbe71..872d069016 100644 --- a/src/gromacs/restraint/restraintpotential.h +++ b/api/legacy/include/gromacs/restraint/restraintpotential.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/utility/arrayref.h b/api/legacy/include/gromacs/utility/arrayref.h similarity index 100% rename from src/gromacs/utility/arrayref.h rename to api/legacy/include/gromacs/utility/arrayref.h diff --git a/src/gromacs/utility/basedefinitions.h b/api/legacy/include/gromacs/utility/basedefinitions.h similarity index 100% rename from src/gromacs/utility/basedefinitions.h rename to api/legacy/include/gromacs/utility/basedefinitions.h diff --git a/src/gromacs/utility/current_function.h b/api/legacy/include/gromacs/utility/current_function.h similarity index 97% rename from src/gromacs/utility/current_function.h rename to api/legacy/include/gromacs/utility/current_function.h index 1f18cab6ff..e771889328 100644 --- a/src/gromacs/utility/current_function.h +++ b/api/legacy/include/gromacs/utility/current_function.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2015,2019, by the GROMACS development team, led by + * Copyright (c) 2015,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/utility/exceptions.h b/api/legacy/include/gromacs/utility/exceptions.h similarity index 100% rename from src/gromacs/utility/exceptions.h rename to api/legacy/include/gromacs/utility/exceptions.h diff --git a/src/gromacs/utility/gmxassert.h b/api/legacy/include/gromacs/utility/gmxassert.h similarity index 98% rename from src/gromacs/utility/gmxassert.h rename to api/legacy/include/gromacs/utility/gmxassert.h index c278f2c2fc..089b73c1df 100644 --- a/src/gromacs/utility/gmxassert.h +++ b/api/legacy/include/gromacs/utility/gmxassert.h @@ -2,7 +2,7 @@ * This file is part of the GROMACS molecular simulation package. * * Copyright (c) 2011-2018, The GROMACS development team. - * Copyright (c) 2019, by the GROMACS development team, led by + * Copyright (c) 2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/gromacs/utility/listoflists.h b/api/legacy/include/gromacs/utility/listoflists.h similarity index 100% rename from src/gromacs/utility/listoflists.h rename to api/legacy/include/gromacs/utility/listoflists.h diff --git a/src/gromacs/utility/real.h b/api/legacy/include/gromacs/utility/real.h similarity index 100% rename from src/gromacs/utility/real.h rename to api/legacy/include/gromacs/utility/real.h diff --git a/api/legacy/version.h.cmakein b/api/legacy/version.h.cmakein new file mode 100644 index 0000000000..ffe1a25184 --- /dev/null +++ b/api/legacy/version.h.cmakein @@ -0,0 +1,105 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2012,2014,2020, by the GROMACS development team, led by + * Mark Abraham, David van der Spoel, Berk Hess, and 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. + */ +/*! \file + * \brief + * Version information for software that links to \Gromacs. + * + * \if libapi + * This include file will be configured by CMake and contains version + * information. It is not used by \Gromacs, but intended for software that + * links to \Gromacs. + * The values come from the main CMakeLists.txt. + * \endif + * + * This file exists from 4.6 onward, and can be included as + * ``. In 4.6, it is also included by + * `, but that header has already moved in 5.0. + * + * This header defines two values, the \Gromacs version, and the API version. + * The versions are in numerical form, where, for example, version + * 4.6.1 would be 40601. + * + * The API version is defined in ::GMX_API_VERSION, and denotes the + * version of the programmer interface, i.e. the installed header files + * and compatible library. + * + * Programs written against the \Gromacs library can use this file + * to provide some backward compatibility even though parts of the API + * change. For example: + * \code + #include + #if (GMX_API_VERSION < 50000) + .... + #else + .... + #endif + \endcode + * where version.h is included directly. For code that must be compatible + * between 4.5 and 4.6, an interim solution is to include typedefs.h, which + * includes this file: + * \code + #include + #if !defined(GMX_API_VERSION) || (GMX_API_VERSION < 40600) + .... + #elif (GMX_API_VERSION < 40700) + .... + #endif + \endcode + * + * \inpublicapi + */ +#ifndef GMX_VERSION_H +#define GMX_VERSION_H + +/*! \brief + * API version of this set of \Gromacs headers. + * + * If there are multiple versions of \Gromacs that work with the same set of + * headers, then this version is not updated between the versions, even though + * ::GMX_VERSION is. + * For 4.6 and 5.0 (and likely for some time in the future as well), this + * tracks the exact \Gromacs version. + */ +#define GMX_API_VERSION @GMX_API_VERSION@ + +/*! \brief + * Exact \Gromacs version of this set of headers. + * + * This specifies the version number of the actual \Gromacs library that + * installed these headers. + */ +#define GMX_VERSION @GMX_VERSION_NUMERIC@ + +#endif diff --git a/api/nblib/CMakeLists.txt b/api/nblib/CMakeLists.txt index e2054314c1..d41c856c20 100644 --- a/api/nblib/CMakeLists.txt +++ b/api/nblib/CMakeLists.txt @@ -116,6 +116,8 @@ set_target_properties(nblib target_link_libraries(nblib PRIVATE libgromacs) target_include_directories(nblib PRIVATE ${PROJECT_SOURCE_DIR}/api) include_directories(BEFORE ${CMAKE_SOURCE_DIR}/api) +# There are transitive dependencies on the legacy GROMACS headers. +target_link_libraries(nblib PUBLIC legacy_api) install(TARGETS nblib EXPORT nblib diff --git a/api/nblib/tests/CMakeLists.txt b/api/nblib/tests/CMakeLists.txt index 366027339c..67cf8a51dc 100644 --- a/api/nblib/tests/CMakeLists.txt +++ b/api/nblib/tests/CMakeLists.txt @@ -46,6 +46,7 @@ gmx_add_unit_test_library(nblib_test_infrastructure ) target_include_directories(nblib_test_infrastructure PRIVATE ${PROJECT_SOURCE_DIR}/api) target_include_directories(nblib_test_infrastructure SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external) +target_link_libraries(nblib_test_infrastructure PRIVATE legacy_api) set(testname "NbLibSetupTests") set(exename "nblib-setup-test") diff --git a/docs/dev-manual/includestyle.rst b/docs/dev-manual/includestyle.rst index 5c2b890297..ece8fbaf1a 100644 --- a/docs/dev-manual/includestyle.rst +++ b/docs/dev-manual/includestyle.rst @@ -7,8 +7,8 @@ between each group, and headers within each group sorted alphabetically. 1. Each *source* file should include ``gmxpre.h`` first. 2. If a *source* file has a corresponding header, it should be included next. If the header is in the same directory as the source, then it is included - without any path (i.e., relative to the source), otherwise relative to - ``src/`` (the latter case should be rare). + without any path (i.e., relative to the source). Otherwise, the canonical + include path of ``libraryname/modulename/header.h`` is used. 3. If the file depends on defines from ``config.h``, that comes next. 4. This is followed by standard C/C++ headers, grouped as follows: @@ -23,15 +23,11 @@ between each group, and headers within each group sorted alphabetically. ````. 6. |Gromacs|-specific libraries from ``src/external/``, such as ``"thread_mpi/threads.h"``. -7. |Gromacs|-specific headers that are not internal to the including module, - included with a path relative to ``src/``. -8. In *test* files, headers not internal to the module, but specific to - testing code, are in a separate block at this point, paths relative to - ``src/``. -9. Finally, |Gromacs| headers that are internal to the including module are - included using a relative path (but never with a path starting with ``../``; - such headers go into group 7 instead). For test files, this group contains - headers that are internal to tests for that module. +7. |Gromacs| headers that are not part of the including module. +8. Public |Gromacs| headers that are part of the including module. +9. Finally, |Gromacs| headers that are internal to the including module, + executable, or test target + (typically at the same path as the source file). All |Gromacs| headers are included with quotes (``"gromacs/utility/path.h"``), other headers with angle brackets (````). Headers under ``src/external/`` @@ -48,20 +44,11 @@ is up to the author of the code to put the headers in proper order in such cases. Trailing comments on the same line as #include statements are preserved and do not affect the checker/sorter. -The includestyle used to differentiate between header files that were declared -to be part of the module and not used outside the module, and those that were -either not part of a module, used in other modules, or installed. -As the possibility of installation has been removed (for now), changes to the -previous organization might occur where such installed files were implicitly -marked as being used outside of a module even though they were not used within -|Gromacs| outside their module. - As part of the effort to build a proper API, a new scheme of separating between public, library and module functionality in header files is planned. - -The guidelines are enforced by an automatic checker script that can also -sort/reformat include statements to follow the guidelines. -See :doc:`gmxtree` for details. +See also :doc:`gmxtree` and +`API restructuring issues `__ +for details. Enforcing a consistent order and style has a few advantages: @@ -73,7 +60,7 @@ Enforcing a consistent order and style has a few advantages: first. With this order, the person working on the header is most likely to see these problems instead of someone else seeing them later when refactoring unrelated code. -* Consistent usage of paths in #include directives makes it easy to use +* Consistent usage of paths in ``#include`` directives makes it easy to use ``grep`` to find all uses of a header, as well as all include dependencies between two modules. * An automatic script can be used to re-establish clean code after diff --git a/docs/doxygen/Doxyfile-common.cmakein b/docs/doxygen/Doxyfile-common.cmakein index d713ea9b56..e9cc7b858c 100644 --- a/docs/doxygen/Doxyfile-common.cmakein +++ b/docs/doxygen/Doxyfile-common.cmakein @@ -3,6 +3,7 @@ PROJECT_NAME = @CMAKE_PROJECT_NAME@ LAYOUT_FILE = @CMAKE_CURRENT_SOURCE_DIR@/DoxygenLayout.xml INPUT = @CMAKE_CURRENT_SOURCE_DIR@ \ @CMAKE_SOURCE_DIR@/src \ + @CMAKE_SOURCE_DIR@/api/legacy/include \ @CMAKE_SOURCE_DIR@/share/template FILE_PATTERNS = *.c *.cpp *.h *.md # CUDA files could be included like this, but currently produce a lot of @@ -29,7 +30,10 @@ EXCLUDE_SYMBOLS += TEST TEST_F TEST_P TYPED_TEST_CASE TYPED_TEST INSTANTIA EXCLUDE_SYMBOLS += MOCK_METHOD* MOCK_CONST_METHOD* FULL_PATH_NAMES = YES STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@ -STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/src +STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@/src \ + @CMAKE_SOURCE_DIR@/src/include \ + @CMAKE_SOURCE_DIR@/src/gromacs/*/include \ + @CMAKE_SOURCE_DIR@/api/legacy/include INCLUDE_PATH = @CMAKE_SOURCE_DIR@/src HAVE_DOT = @DOXYGEN_DOT_FOUND@ DOT_PATH = @DOXYGEN_DOT_PATH@ diff --git a/docs/doxygen/check-source.py b/docs/doxygen/check-source.py index 8790eb6a17..b37ea833cb 100755 --- a/docs/doxygen/check-source.py +++ b/docs/doxygen/check-source.py @@ -2,7 +2,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2014,2015,2018,2019, by the GROMACS development team, led by +# Copyright (c) 2014,2015,2018,2019,2020, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. @@ -340,19 +340,22 @@ class ModuleDependencyGraph(object): def check_all(tree, reporter, check_ignored): """Do all checks for the GROMACS tree.""" - includesorter = IncludeSorter() - for fileobj in tree.get_files(): - if isinstance(fileobj, gmxtree.GeneratorSourceFile): - continue - check_file(fileobj, tree, reporter) - for includedfile in fileobj.get_includes(): - check_include(fileobj, includedfile, reporter) - if fileobj.should_includes_be_sorted(): - is_sorted, details = includesorter.check_sorted(fileobj) - if not is_sorted: - details.append("You can use includesorter.py to do the sorting automatically; see docs/dev-manual/gmxtree.rst") - reporter.code_issue(fileobj, - "include style/order is not consistent; see docs/dev-manual/includestyle.rst", details) + # Include sorting is disabled pending resolution of + # https://gitlab.com/gromacs/gromacs/-/issues/3288 and + # https://gitlab.com/gromacs/gromacs/-/issues/3659 + # includesorter = IncludeSorter() + # for fileobj in tree.get_files(): + # if isinstance(fileobj, gmxtree.GeneratorSourceFile): + # continue + # check_file(fileobj, tree, reporter) + # for includedfile in fileobj.get_includes(): + # check_include(fileobj, includedfile, reporter) + # if fileobj.should_includes_be_sorted(): + # is_sorted, details = includesorter.check_sorted(fileobj) + # if not is_sorted: + # details.append("You can use includesorter.py to do the sorting automatically; see docs/dev-manual/gmxtree.rst") + # reporter.code_issue(fileobj, + # "include style/order is not consistent; see docs/dev-manual/includestyle.rst", details) for classobj in tree.get_classes(): check_class(classobj, reporter) diff --git a/docs/doxygen/cycle-suppressions.txt b/docs/doxygen/cycle-suppressions.txt index ad53e6cb20..2bbaeef306 100644 --- a/docs/doxygen/cycle-suppressions.txt +++ b/docs/doxygen/cycle-suppressions.txt @@ -16,7 +16,6 @@ nbnxm -> mdlib simd -> hardware gpu_utils -> hardware listed_forces -> mdlib -utility -> math # modular simulator uses shellfc from mdrun, but is later included in mdrun by simulator builder modularsimulator -> mdrun diff --git a/docs/doxygen/suppressions.txt b/docs/doxygen/suppressions.txt index a6538a629f..c32d4efeea 100644 --- a/docs/doxygen/suppressions.txt +++ b/docs/doxygen/suppressions.txt @@ -1,63 +1,71 @@ -# The script is currently a bit too eager -share/template/template.cpp: error: source file documentation appears outside full documentation -# The parser in the script is not clever enough -src/gromacs/version.h: warning: includes local file as - -# These are OK -src/gromacs/linearalgebra/eigensolver.cpp: warning: should include "config.h" -src/gromacs/linearalgebra/gmx_arpack.cpp: warning: should include "config.h" -src/gromacs/linearalgebra/gmx_blas/*: warning: does not include "gmxpre.h" first -src/gromacs/linearalgebra/gmx_blas/*: warning: should include "config.h" -src/gromacs/linearalgebra/gmx_lapack/*: warning: does not include "gmxpre.h" first -src/gromacs/linearalgebra/gmx_lapack/*: warning: should include "config.h" -src/gromacs/utility/baseversion-gen.cpp: warning: does not include "gmxpre.h" first - -# Exclude header files that are used for inlining code; the responsibility for -# making the right #includes should be on the source file that uses these. -# TODO: # Stop using the preprocessor for meta-programming! -src/gromacs/ewald/pme_simd4.h: warning: should include "pme_simd.h" -src/gromacs/ewald/pme_spline_work.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/ewald/pme_spline_work.h: warning: includes "simd.h" unnecessarily -src/gromacs/ewald/pme_spread.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/nbnxm/boundingboxes.h: warning: includes "simd.h" unnecessarily -src/gromacs/nbnxm/kernels_simd_2xmm/kernel_inner.h: warning: should include "simd.h" -src/gromacs/nbnxm/kernels_simd_2xmm/kernel_outer.h: warning: should include "simd.h" -src/gromacs/nbnxm/kernels_simd_4xm/kernel_inner.h: warning: should include "simd.h" -src/gromacs/nbnxm/kernels_simd_4xm/kernel_outer.h: warning: should include "simd.h" -src/gromacs/nbnxm/pairlist_simd_2xmm.h: warning: should include "simd.h" -src/gromacs/nbnxm/pairlist_simd_4xm.h: warning: should include "simd.h" - -# This module name doesn't really fall into any currently used pattern; needs some thought -: error: no matching directory for module: module_mdrun_integration_tests - -# These would be nice to fix, but can wait for later / deletion / rewrites -src/gromacs/nbnxm/kernels_simd_2xmm/kernel_common.h: warning: should include "nbnxm_simd.h" -src/gromacs/nbnxm/kernels_simd_4xm/kernel_common.h: warning: should include "nbnxm_simd.h" - # This seems to be a false positive src/gromacs/nbnxm/cuda/nbnxm_cuda_types.h: error: NbnxmGpu: is in internal file(s), but appears in public documentation +# doxygen has problems with the template construct in this file +src/gromacs/modularsimulator/signallers.h: error: build: is documented, but does not have brief description + # False positive caused by forward-declaration of BasicVector in src/testutils/refdata.h -src/gromacs/math/vectypes.h: error: gmx::BasicVector: is in library file(s), but appears in public documentation +src/testutils/refdata.h: error: gmx::BasicVector: is in library file(s), but appears in public documentation -# Temporary while we change the SIMD implementation -src/gromacs/simd/impl_sparc64_hpc_ace/impl_sparc64_hpc_ace_common.h: warning: should include "simd.h" +# +# All following suppressions are disabled while the include checker +# is temporarily disabled pending resolution of +# https://gitlab.com/gromacs/gromacs/-/issues/3288 and +# https://gitlab.com/gromacs/gromacs/-/issues/3659 +# -src/gromacs/simd/tests/scalar.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/simd/tests/scalar_math.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/simd/tests/scalar_util.cpp: warning: includes "simd.h" unnecessarily -src/gromacs/tables/cubicsplinetable.h: warning: includes "simd.h" unnecessarily -src/gromacs/tables/quadraticsplinetable.h: warning: includes "simd.h" unnecessarily +# # The script is currently a bit too eager +# share/template/template.cpp: error: source file documentation appears outside full documentation +# # The parser in the script is not clever enough +# src/gromacs/version.h: warning: includes local file as -# These are specific to Folding@Home, and easiest to suppress here -src/gmxpre.h: warning: includes non-local file as "swindirect.h" +# # These are OK +# src/gromacs/linearalgebra/eigensolver.cpp: warning: should include "config.h" +# src/gromacs/linearalgebra/gmx_arpack.cpp: warning: should include "config.h" +# src/gromacs/linearalgebra/gmx_blas/*: warning: does not include "gmxpre.h" first +# src/gromacs/linearalgebra/gmx_blas/*: warning: should include "config.h" +# src/gromacs/linearalgebra/gmx_lapack/*: warning: does not include "gmxpre.h" first +# src/gromacs/linearalgebra/gmx_lapack/*: warning: should include "config.h" +# src/gromacs/utility/baseversion-gen.cpp: warning: does not include "gmxpre.h" first -# New external API (see https://gitlab.com/gromacs/gromacs/-/issues/2586) has some unresolved -# conflicts with previous definitions of public API, installed API, and other things -# described or implemented in check-source.py, gmxtree.py, gmxtree.rst, and others -# TODO: resolve definitions, update testing heuristics, and activate policy checks -# for src/api/cpp files. -src/api/cpp/*: * +# # Exclude header files that are used for inlining code; the responsibility for +# # making the right #includes should be on the source file that uses these. +# # TODO: # Stop using the preprocessor for meta-programming! +# src/gromacs/ewald/pme_simd4.h: warning: should include "pme_simd.h" +# src/gromacs/ewald/pme_spline_work.cpp: warning: includes "simd.h" unnecessarily +# src/gromacs/ewald/pme_spline_work.h: warning: includes "simd.h" unnecessarily +# src/gromacs/ewald/pme_spread.cpp: warning: includes "simd.h" unnecessarily +# src/gromacs/nbnxm/boundingboxes.h: warning: includes "simd.h" unnecessarily +# src/gromacs/nbnxm/kernels_simd_2xmm/kernel_inner.h: warning: should include "simd.h" +# src/gromacs/nbnxm/kernels_simd_2xmm/kernel_outer.h: warning: should include "simd.h" +# src/gromacs/nbnxm/kernels_simd_4xm/kernel_inner.h: warning: should include "simd.h" +# src/gromacs/nbnxm/kernels_simd_4xm/kernel_outer.h: warning: should include "simd.h" +# src/gromacs/nbnxm/pairlist_simd_2xmm.h: warning: should include "simd.h" +# src/gromacs/nbnxm/pairlist_simd_4xm.h: warning: should include "simd.h" -# doxygen has problems with the template construct in this file -src/gromacs/modularsimulator/signallers.h: error: build: is documented, but does not have brief description +# # This module name doesn't really fall into any currently used pattern; needs some thought +# : error: no matching directory for module: module_mdrun_integration_tests + +# # These would be nice to fix, but can wait for later / deletion / rewrites +# src/gromacs/nbnxm/kernels_simd_2xmm/kernel_common.h: warning: should include "nbnxm_simd.h" +# src/gromacs/nbnxm/kernels_simd_4xm/kernel_common.h: warning: should include "nbnxm_simd.h" + + +# # Temporary while we change the SIMD implementation +# src/gromacs/simd/impl_sparc64_hpc_ace/impl_sparc64_hpc_ace_common.h: warning: should include "simd.h" + +# src/gromacs/simd/tests/scalar.cpp: warning: includes "simd.h" unnecessarily +# src/gromacs/simd/tests/scalar_math.cpp: warning: includes "simd.h" unnecessarily +# src/gromacs/simd/tests/scalar_util.cpp: warning: includes "simd.h" unnecessarily +# src/gromacs/tables/cubicsplinetable.h: warning: includes "simd.h" unnecessarily +# src/gromacs/tables/quadraticsplinetable.h: warning: includes "simd.h" unnecessarily + +# # These are specific to Folding@Home, and easiest to suppress here +# src/gmxpre.h: warning: includes non-local file as "swindirect.h" + +# # New external API (see https://gitlab.com/gromacs/gromacs/-/issues/2586) has some unresolved +# # conflicts with previous definitions of public API, installed API, and other things +# # described or implemented in check-source.py, gmxtree.py, gmxtree.rst, and others +# # TODO: resolve definitions, update testing heuristics, and activate policy checks +# # for src/api/cpp files. +# src/api/cpp/*: * diff --git a/python_packaging/sample_restraint/src/cpp/CMakeLists.txt b/python_packaging/sample_restraint/src/cpp/CMakeLists.txt index 9fac443fd7..6e70fb46df 100644 --- a/python_packaging/sample_restraint/src/cpp/CMakeLists.txt +++ b/python_packaging/sample_restraint/src/cpp/CMakeLists.txt @@ -20,4 +20,4 @@ set_target_properties(gmxapi_extension_ensemblepotential PROPERTIES SKIP_BUILD_R # If building with setuptools, CMake will not be performing the install set_target_properties(gmxapi_extension_ensemblepotential PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) -target_link_libraries(gmxapi_extension_ensemblepotential PRIVATE Gromacs::gmxapi) +target_link_libraries(gmxapi_extension_ensemblepotential PUBLIC Gromacs::libgromacs Gromacs::gmxapi) diff --git a/python_packaging/sample_restraint/tests/CMakeLists.txt b/python_packaging/sample_restraint/tests/CMakeLists.txt index 3cc6a2dbad..0952396d33 100644 --- a/python_packaging/sample_restraint/tests/CMakeLists.txt +++ b/python_packaging/sample_restraint/tests/CMakeLists.txt @@ -97,7 +97,7 @@ configure_file(testingconfiguration.in.h testingconfiguration.h) add_executable(gmxapi_extension_library-test test_binding.cpp) add_dependencies(gmxapi_extension_library-test gmxapi_extension_spc2_water_box) target_include_directories(gmxapi_extension_library-test PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(gmxapi_extension_library-test Gromacs::gmxapi GTest::Main) +target_link_libraries(gmxapi_extension_library-test Gromacs::libgromacs Gromacs::gmxapi GTest::Main) gtest_add_tests(TARGET gmxapi_extension_library-test TEST_LIST BasicPlugin) diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index 00eb303152..e99890ac99 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -142,10 +142,8 @@ if (WIN32) endif() list(APPEND libgromacs_object_library_dependencies thread_mpi) -configure_file(version.h.cmakein version.h) if(GMX_INSTALL_LEGACY_API) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/version.h analysisdata.h options.h selection.h @@ -321,6 +319,8 @@ target_link_libraries(libgromacs PUBLIC ${GMX_PUBLIC_LIBRARIES} ) +target_link_libraries(libgromacs PUBLIC legacy_api) + if (GMX_OPENMP) target_link_libraries(libgromacs PUBLIC OpenMP::OpenMP_CXX) endif() @@ -380,6 +380,7 @@ endif() # Only install the library in mdrun-only mode if it is actually necessary # for the binary +# TODO: Stop installing libgromacs. Possibly allow installation during deprecation period with GMX_INSTALL_LEGACY_API. if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS) install(TARGETS libgromacs EXPORT libgromacs @@ -398,8 +399,8 @@ if (NOT GMX_BUILD_MDRUN_ONLY OR BUILD_SHARED_LIBS) if(GMX_INSTALL_LEGACY_API) target_compile_features(libgromacs INTERFACE cxx_std_${CMAKE_CXX_STANDARD}) endif() - add_library(Gromacs::libgromacs ALIAS libgromacs) endif() +add_library(Gromacs::libgromacs ALIAS libgromacs) if (NOT GMX_BUILD_MDRUN_ONLY) include(InstallLibInfo.cmake) diff --git a/src/gromacs/analysisdata/tests/CMakeLists.txt b/src/gromacs/analysisdata/tests/CMakeLists.txt index bcecb7340e..c55d59b055 100644 --- a/src/gromacs/analysisdata/tests/CMakeLists.txt +++ b/src/gromacs/analysisdata/tests/CMakeLists.txt @@ -35,6 +35,7 @@ gmx_add_unit_test_library(analysisdata-test-shared datatest.cpp mock_datamodule.cpp) +target_link_libraries(analysisdata-test-shared PRIVATE legacy_api) gmx_add_unit_test(AnalysisDataUnitTests analysisdata-test CPP_SOURCE_FILES diff --git a/src/gromacs/fileio/CMakeLists.txt b/src/gromacs/fileio/CMakeLists.txt index f0e81bb03c..3738f1d2ad 100644 --- a/src/gromacs/fileio/CMakeLists.txt +++ b/src/gromacs/fileio/CMakeLists.txt @@ -49,17 +49,6 @@ endif() target_sources(libgromacs PRIVATE ${FILEIO_SOURCES}) -if(GMX_INSTALL_LEGACY_API) - install(FILES - oenv.h - confio.h - pdbio.h - tpxio.h - trxio.h - filetypes.h - DESTINATION include/gromacs/fileio) -endif() - if (BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/src/gromacs/fileio/confio.cpp b/src/gromacs/fileio/confio.cpp index 7114d54c6d..3b52aadf1c 100644 --- a/src/gromacs/fileio/confio.cpp +++ b/src/gromacs/fileio/confio.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "confio.h" +#include "gromacs/fileio/confio.h" #include #include diff --git a/src/gromacs/fileio/filetypes.cpp b/src/gromacs/fileio/filetypes.cpp index 6729446ecd..9cc48d08a4 100644 --- a/src/gromacs/fileio/filetypes.cpp +++ b/src/gromacs/fileio/filetypes.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "filetypes.h" +#include "gromacs/fileio/filetypes.h" #include diff --git a/src/gromacs/fileio/oenv.cpp b/src/gromacs/fileio/oenv.cpp index 0c99fa191a..e51c52ccc1 100644 --- a/src/gromacs/fileio/oenv.cpp +++ b/src/gromacs/fileio/oenv.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "oenv.h" +#include "gromacs/fileio/oenv.h" #include "gromacs/utility/enumerationhelpers.h" #include "gromacs/utility/exceptions.h" diff --git a/src/gromacs/fileio/pdbio.cpp b/src/gromacs/fileio/pdbio.cpp index f551dde391..c3f6810bcb 100644 --- a/src/gromacs/fileio/pdbio.cpp +++ b/src/gromacs/fileio/pdbio.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "pdbio.h" +#include "gromacs/fileio/pdbio.h" #include #include diff --git a/src/gromacs/fileio/tests/CMakeLists.txt b/src/gromacs/fileio/tests/CMakeLists.txt index 5017b67f4c..6b91860577 100644 --- a/src/gromacs/fileio/tests/CMakeLists.txt +++ b/src/gromacs/fileio/tests/CMakeLists.txt @@ -48,3 +48,4 @@ gmx_add_unit_test(FileIOTests fileio-test ${tng_sources} xvgio.cpp ) +target_link_libraries(fileio-test PRIVATE legacy_api) diff --git a/src/gromacs/fileio/tpxio.cpp b/src/gromacs/fileio/tpxio.cpp index 9ea2337f86..b72e66cf2a 100644 --- a/src/gromacs/fileio/tpxio.cpp +++ b/src/gromacs/fileio/tpxio.cpp @@ -39,7 +39,7 @@ /* This file is completely threadsafe - keep it that way! */ -#include "tpxio.h" +#include "gromacs/fileio/tpxio.h" #include #include diff --git a/src/gromacs/linearalgebra/CMakeLists.txt b/src/gromacs/linearalgebra/CMakeLists.txt index 4c0ab0c09c..75c7ac1037 100644 --- a/src/gromacs/linearalgebra/CMakeLists.txt +++ b/src/gromacs/linearalgebra/CMakeLists.txt @@ -47,6 +47,10 @@ set(LINEARALGEBRA_SOURCES ${LINEARALGEBRA_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES}) add_library(linearalgebra OBJECT ${LINEARALGEBRA_SOURCES}) +target_include_directories(linearalgebra PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +# TODO: Only expose the module's public headers. +target_include_directories(linearalgebra INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + gmx_target_compile_options(linearalgebra) target_compile_definitions(linearalgebra PRIVATE HAVE_CONFIG_H) # The linearalgebra code is all considered external, and we will @@ -62,5 +66,6 @@ else() # not expect null termination of C strings. gmx_target_warning_suppression(linearalgebra -Wno-stringop-truncation HAS_NO_STRINGOP_TRUNCATION) endif() +target_link_libraries(linearalgebra PRIVATE legacy_api) list(APPEND libgromacs_object_library_dependencies linearalgebra) set(libgromacs_object_library_dependencies ${libgromacs_object_library_dependencies} PARENT_SCOPE) diff --git a/src/gromacs/math/CMakeLists.txt b/src/gromacs/math/CMakeLists.txt index 16d6ccd740..a879d44e2e 100644 --- a/src/gromacs/math/CMakeLists.txt +++ b/src/gromacs/math/CMakeLists.txt @@ -36,25 +36,6 @@ file(GLOB MATH_SOURCES *.cpp) set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${MATH_SOURCES} PARENT_SCOPE) -# TODO: (https://gitlab.com/gromacs/gromacs/-/issues/988) Find a new convention for defining public API. -install(FILES - do_fit.h - functions.h - units.h - utilities.h - vec.h - vectypes.h - DESTINATION include/gromacs/math) - -if(GMX_INSTALL_LEGACY_API) - install(FILES - do_fit.h - units.h - utilities.h - DESTINATION include/gromacs/math) -endif() - - if (BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/src/gromacs/math/do_fit.cpp b/src/gromacs/math/do_fit.cpp index b8be02f06d..d214c9b689 100644 --- a/src/gromacs/math/do_fit.cpp +++ b/src/gromacs/math/do_fit.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "do_fit.h" +#include "gromacs/math/do_fit.h" #include #include diff --git a/src/gromacs/math/functions.cpp b/src/gromacs/math/functions.cpp index 2cd3e3280a..db8b99db42 100644 --- a/src/gromacs/math/functions.cpp +++ b/src/gromacs/math/functions.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015,2016,2019, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2016,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and 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,7 +44,7 @@ #include "gmxpre.h" -#include "functions.h" +#include "gromacs/math/functions.h" #include "config.h" diff --git a/src/gromacs/math/units.cpp b/src/gromacs/math/units.cpp index 6881111e60..883e74d151 100644 --- a/src/gromacs/math/units.cpp +++ b/src/gromacs/math/units.cpp @@ -35,7 +35,7 @@ */ #include "gmxpre.h" -#include "units.h" +#include "gromacs/math/units.h" #include diff --git a/src/gromacs/math/utilities.cpp b/src/gromacs/math/utilities.cpp index 3412f2c472..067cc32b25 100644 --- a/src/gromacs/math/utilities.cpp +++ b/src/gromacs/math/utilities.cpp @@ -37,7 +37,7 @@ */ #include "gmxpre.h" -#include "utilities.h" +#include "gromacs/math/utilities.h" #include "config.h" diff --git a/src/gromacs/mdrunutility/tests/CMakeLists.txt b/src/gromacs/mdrunutility/tests/CMakeLists.txt index e538b8ffed..1a95671662 100644 --- a/src/gromacs/mdrunutility/tests/CMakeLists.txt +++ b/src/gromacs/mdrunutility/tests/CMakeLists.txt @@ -34,6 +34,7 @@ gmx_add_unit_test_library(mdrunutility-test-shared threadaffinitytest.cpp) +target_link_libraries(mdrunutility-test-shared PUBLIC legacy_api) gmx_add_unit_test(MdrunUtilityUnitTests mdrunutility-test CPP_SOURCE_FILES diff --git a/src/gromacs/modularsimulator/CMakeLists.txt b/src/gromacs/modularsimulator/CMakeLists.txt index ac50973e41..30614ffac8 100644 --- a/src/gromacs/modularsimulator/CMakeLists.txt +++ b/src/gromacs/modularsimulator/CMakeLists.txt @@ -40,6 +40,7 @@ gmx_target_compile_options(modularsimulator) target_compile_definitions(modularsimulator PRIVATE HAVE_CONFIG_H) # Should be possible to remove this when resolving #3290 target_include_directories(modularsimulator SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include) +target_link_libraries(modularsimulator PRIVATE legacy_api) if(GMX_OPENMP) # Explicitly set properties for modular simulator module to compile with openmp diff --git a/src/gromacs/restraint/CMakeLists.txt b/src/gromacs/restraint/CMakeLists.txt index 06a082e57f..d1bc6a3e80 100644 --- a/src/gromacs/restraint/CMakeLists.txt +++ b/src/gromacs/restraint/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2017,2018,2019, by the GROMACS development team, led by +# Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and 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,8 +37,6 @@ gmx_add_libgromacs_sources( manager.cpp restraintmdmodule.cpp ) -# TODO this is a hacky way to expose things for the API and needs to be changed to something proper -install(FILES restraintpotential.h DESTINATION include/gromacs/restraint) if (BUILD_TESTING) add_subdirectory(tests) diff --git a/src/gromacs/selection/CMakeLists.txt b/src/gromacs/selection/CMakeLists.txt index e621fa5881..a0c5e11170 100644 --- a/src/gromacs/selection/CMakeLists.txt +++ b/src/gromacs/selection/CMakeLists.txt @@ -56,6 +56,8 @@ else() gmx_target_warning_suppression(scanner -Wno-missing-declarations HAS_NO_MISSING_DECLARATIONS) gmx_target_warning_suppression(scanner -Wno-null-conversion HAS_NO_NULL_CONVERSIONS) endif() +target_link_libraries(scanner PRIVATE legacy_api) + list(APPEND libgromacs_object_library_dependencies scanner) set(libgromacs_object_library_dependencies ${libgromacs_object_library_dependencies} PARENT_SCOPE) diff --git a/src/gromacs/utility/CMakeLists.txt b/src/gromacs/utility/CMakeLists.txt index 93e82808cd..d4d9c0a5e3 100644 --- a/src/gromacs/utility/CMakeLists.txt +++ b/src/gromacs/utility/CMakeLists.txt @@ -39,22 +39,11 @@ if (GMX_GPU_CUDA) endif() set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${UTILITY_SOURCES} PARENT_SCOPE) -# TODO: (https://gitlab.com/gromacs/gromacs/-/issues/988) Find a new convention for defining public API. -install(FILES - basedefinitions.h - current_function.h - gmxassert.h - real.h - DESTINATION include/gromacs/utility) - if(GMX_INSTALL_LEGACY_API) install(FILES - arrayref.h baseversion.h classhelpers.h enumerationhelpers.h - exceptions.h - listoflists.h fileptr.h futil.h flags.h diff --git a/src/gromacs/utility/exceptions.cpp b/src/gromacs/utility/exceptions.cpp index 84e57940a5..784cf34b25 100644 --- a/src/gromacs/utility/exceptions.cpp +++ b/src/gromacs/utility/exceptions.cpp @@ -42,7 +42,7 @@ */ #include "gmxpre.h" -#include "exceptions.h" +#include "gromacs/utility/exceptions.h" #include diff --git a/src/gromacs/utility/gmxassert.cpp b/src/gromacs/utility/gmxassert.cpp index e0d06d56ab..b75f5a81a3 100644 --- a/src/gromacs/utility/gmxassert.cpp +++ b/src/gromacs/utility/gmxassert.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2011,2012,2014,2015,2019, by the GROMACS development team, led by + * Copyright (c) 2011,2012,2014,2015,2019,2020, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and 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,7 +41,7 @@ */ #include "gmxpre.h" -#include "gmxassert.h" +#include "gromacs/utility/gmxassert.h" #include #include diff --git a/src/programs/CMakeLists.txt b/src/programs/CMakeLists.txt index 6a336db5d3..29da4ea35f 100644 --- a/src/programs/CMakeLists.txt +++ b/src/programs/CMakeLists.txt @@ -41,13 +41,14 @@ target_compile_definitions(mdrun_objlib PRIVATE HAVE_CONFIG_H) target_include_directories(mdrun_objlib SYSTEM BEFORE PRIVATE ${PROJECT_SOURCE_DIR}/src/external/thread_mpi/include) # Should be possible to remove this when resolving #3290 target_include_directories(mdrun_objlib SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external) +target_link_libraries(mdrun_objlib PRIVATE legacy_api) if(GMX_FAHCORE) # The lack of a real source file here alongside the object library # may break some generators, according to CMake documentation. If # so, we can consider adding some dummy file to make it work. add_library(fahcore $) - target_link_libraries(fahcore PRIVATE ${GMX_COMMON_LIBRARIES}) + target_link_libraries(fahcore PRIVATE ${GMX_COMMON_LIBRARIES} legacy_api) elseif(GMX_BUILD_MDRUN_ONLY) add_executable(mdrun $ mdrun_main.cpp) gmx_target_compile_options(mdrun) @@ -74,7 +75,9 @@ else() gmx_target_compile_options(view_objlib) target_compile_definitions(view_objlib PRIVATE HAVE_CONFIG_H) target_include_directories(view_objlib SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external) + target_link_libraries(view_objlib PRIVATE legacy_api) add_library(gmx_objlib OBJECT ${GMX_MAIN_SOURCES}) + target_link_libraries(gmx_objlib PRIVATE legacy_api) target_include_directories(gmx_objlib SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external) add_executable(gmx $ @@ -83,9 +86,10 @@ else() add_executable(Gromacs::gmx ALIAS gmx) gmx_target_compile_options(gmx) target_compile_definitions(gmx PRIVATE HAVE_CONFIG_H) - target_link_libraries(gmx libgromacs - ${GMX_COMMON_LIBRARIES} - ${GMX_EXE_LINKER_FLAGS}) + target_link_libraries(gmx PRIVATE + libgromacs + ${GMX_COMMON_LIBRARIES} + ${GMX_EXE_LINKER_FLAGS}) if(GMX_X11) target_link_libraries(gmx ${X11_LIBRARIES}) endif() diff --git a/src/programs/mdrun/tests/CMakeLists.txt b/src/programs/mdrun/tests/CMakeLists.txt index b051068c06..7c0a67a763 100644 --- a/src/programs/mdrun/tests/CMakeLists.txt +++ b/src/programs/mdrun/tests/CMakeLists.txt @@ -47,6 +47,7 @@ gmx_add_unit_test_library(mdrun_test_infrastructure $ ) target_include_directories(mdrun_test_infrastructure SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/external) +target_link_libraries(mdrun_test_infrastructure PUBLIC legacy_api) # To avoid running into test timeouts, some end-to-end tests of mdrun # functionality are split off. This can be rearranged in future as we diff --git a/src/testutils/CMakeLists.txt b/src/testutils/CMakeLists.txt index 5e1c1ad329..3dd632ef55 100644 --- a/src/testutils/CMakeLists.txt +++ b/src/testutils/CMakeLists.txt @@ -81,6 +81,8 @@ if (GMX_GPU_CUDA) else() add_library(testutils STATIC ${UNITTEST_TARGET_OPTIONS} ${TESTUTILS_SOURCES}) endif() +# TODO: Use a non-degenerate interface include directory. +target_include_directories(testutils PUBLIC ${CMAKE_SOURCE_DIR}/src) if (GMX_GPU_SYCL) set_source_files_properties(test_device.cpp -- 2.22.0