geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
223 stars 235 forks source link

Disentangle CMakeLists.txt. #5781

Closed bangerth closed 4 months ago

bangerth commented 4 months ago

The cmake script has become a bit of a mess. This patch disentangles it in a substantial way, first finding and dealing with external dependencies, then configuring our own targets, then dealing with how external dependencies impact our own targets, and finally documentation. This is going to be difficult to review -- but almost all of it is really just moving things around.

For me, the cmake output now looks like this, less convoluted:

-- ====================================================
-- ============ Configuring ASPECT ====================
-- ====================================================
-- Setting up ASPECT for DebugRelease mode.
-- 
-- ===== Configuring external libraries ===============
-- Found deal.II version 9.6.0-pre at '/home/bangerth/p/deal.II/1/install/lib/cmake/deal.II'
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Using ASPECT_WITH_ZLIB = 'OFF'
-- Using ASPECT_WITH_LIBDAP = 'OFF'
-- Using ASPECT_WITH_FASTSCAPE = 'OFF'
CMake Warning at CMakeLists.txt:203 (find_package):
  By not providing "FindNETCDF.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "NETCDF", but
  CMake did not find one.

  Could not find a package configuration file provided by "NETCDF" with any
  of the following names:

    NETCDFConfig.cmake
    netcdf-config.cmake

  Add the installation prefix of "NETCDF" to CMAKE_PREFIX_PATH or set
  "NETCDF_DIR" to a directory containing one of the above files.  If "NETCDF"
  provides a separate development package or SDK, be sure it has been
  installed.

-- NetCDF not found. Disabling ASPECT_WITH_NETCDF. You can specify a hint to your installation directory with NETCDF_DIR.
-- Using ASPECT_WITH_WORLD_BUILDER = 'ON'
-- World Builder not found. Using internal version.
-- Found Git: /usr/bin/git (found version "2.34.1")
-- Using World Builder version 0.6.0 found at /home/bangerth/p/deal.II/1/projects/aspect/contrib/world_builder.
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 
-- ===== Setting up Geodynamic World Builder version 0.6.0 in Debug mode
-- Looking for feenableexcept
-- Looking for feenableexcept - found
-- Looking for feclearexcept
-- Looking for feclearexcept - found
-- Using Floating Point Exceptions if in Debug mode.
-- Looking for Fortran support.
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - /usr/bin/f95
-- The Fortran compiler identification is GNU 11.4.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/f95 - skipped
-- Found Fortran support. Enabling Fortran wrapper and tests.
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) 
-- SWIG was not found, disabling python wrapper compilation.
-- Found MPI_C: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so (found version "3.1")
-- Found MPI_CXX: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so (found version "3.1")
-- Found MPI_Fortran: /usr/lib/x86_64-linux-gnu/libmpi_usempif08.so (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
-- MPI found.
-- Using MPI.
-- Found Python: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter Development Development.Module Development.Embed
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Enabling the use of ZLIB.
-- Combining source files into unity build.
-- Performing Test SUGGEST_OVERWRITE_CXX_COMPILE_FLAG
-- Performing Test SUGGEST_OVERWRITE_CXX_COMPILE_FLAG - Success
-- Performing Test NO_PLACEMENT_NEW_CXX_COMPILE_FLAG
-- Performing Test NO_PLACEMENT_NEW_CXX_COMPILE_FLAG - Success
-- Found /usr/bin/numdiff to test the difference between files.
-- 
-- ===== Setting up Geodynamic World Builder version 0.6.0 in Release mode
-- Using Floating Point Exceptions if in Debug mode.
-- Looking for Fortran support.
-- Found Fortran support. Enabling Fortran wrapper and tests.
-- Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) 
-- SWIG was not found, disabling python wrapper compilation.
-- MPI found.
-- Using MPI.
-- Python was disabled by cmake options.
-- Enabling the use of ZLIB.
-- Combining source files into unity build.
-- 
-- ===== Configuring ASPECT build targets =============
-- Query git repository information.
CMake Deprecation Warning at CMakeLists.txt:439 (cmake_policy):
  The OLD behavior for policy CMP0037 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- Setting up test project, see tests/setup_tests.log for details.
     Found 1 tests.
-- Performing Test HAVE_DLOPEN
-- Performing Test HAVE_DLOPEN - Success
-- Enabling dynamic loading of plugins from the input file
-- Looking for C++ include link.h
-- Looking for C++ include link.h - found
-- Enabling checking of compatible deal.II library when loading plugins
-- Linking ASPECT against WorldBuilder
-- Linking ASPECT against dlopen
-- Performing Test HAVE_FP_EXCEPTIONS
-- Performing Test HAVE_FP_EXCEPTIONS - Success
-- Runtime floating point checks enabled.
-- Precompiling common header files.
-- Disabling unity build.
-- Writing configuration details into detailed.log...
-- 
-- ===== Configuring ASPECT documentation =============
-- Found Perl: /usr/bin/perl (found version "5.34.0")
-- Finding .prm files
-- Finding image files
-- Setting up build information
-- Parameter GUI not found: install and provide a hint using -D PARAMETER_GUI_DIR or set -D PARAMETER_GUI_EXECUTABLE directly.
-- 
-- ===== Writing final configuration =============
###
#
#  Project aspect set up with  deal.II-9.6.0-pre  found at
#      /home/bangerth/p/deal.II/1/install
#
#  CMAKE_BUILD_TYPE:          DebugRelease
#
#  You can now run
#      $ ninja                - to compile and link aspect
#      $ ninja debug          - to switch the build type to 'Debug'
#      $ ninja release        - to switch the build type to 'Release'
#      $ ninja debugrelease   - to switch the build type to compile both
#      $ ninja clean          - to remove the generated executable as well as
#                               all intermediate compilation files
#      $ ninja distclean      - to clean the directory from all generated
#                               files (includes clean, runclean and the removal
#                               of the generated build system)
#      $ ninja setup_tests    - enable all tests and re-run test detection
#      $ ninja indent         - fix indentation of all source files
#      $ ninja info           - to view this message again

-- Configuring done (33.0s)
-- Generating done (0.1s)
-- Build files have been written to: /home/bangerth/p/deal.II/1/projects/build

There are areas that remain in need of clean-up, in particular our own targets. Also, the NETCDF configuration throws an error. But this is a step forward.

tjhei commented 4 months ago
-- Found deal.II version 9.5.1 at '/opt/deal.II-v9.5.1/lib/cmake/deal.II'
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_FIND_LIBRARY_PREFIXES
bangerth commented 4 months ago

OK, this seems to work now. Would appreciate merge.

bangerth commented 4 months ago

Tests cleanly now.