Skip to content

Can't seem to set up a top level CMakeLists.txt for the entire code gallery #133

@bangerth

Description

@bangerth

This might need @tamiko 's input:

I've gotten tired of configuring and compiling each code gallery program individually, so I tried to set up this CMakeLists.txt file in the top level of the code gallery:

cmake_minimum_required(VERSION 3.13.4)
project(code-gallery)

add_subdirectory(advection_reaction_estimator)

Interestingly, this does not work. When I create a build directory and call cmake .. from there, the output is the following:

-- The CXX compiler identification is GNU 4.8.5
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - broken
CMake Error at /raid/bangerth/bin/share/cmake-3.20/Modules/CMakeTestCXXCompiler.cmake:59 (message):
  The C++ compiler

    "/usr/bin/c++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/fac/g/bangerth/p/deal.II/1/code-gallery/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_f0d54/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_f0d54.dir/build.make CMakeFiles/cmTC_f0d54.dir/build
    gmake[1]: Entering directory `/raid/bangerth/p/deal.II/1/code-gallery/build/CMakeFiles/CMakeTmp'
    gmake[1]: Warning: File `CMakeFiles/cmTC_f0d54.dir/progress.make' has modification time 0.0017 s in the future
    Building CXX object CMakeFiles/cmTC_f0d54.dir/testCXXCompiler.cxx.o
    /usr/bin/c++   -std=c++20  -o CMakeFiles/cmTC_f0d54.dir/testCXXCompiler.cxx.o -c /home/fac/g/bangerth/p/deal.II/1/code-gallery/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    c++: error: unrecognized command line option ‘-std=c++20’
    gmake[1]: *** [CMakeFiles/cmTC_f0d54.dir/testCXXCompiler.cxx.o] Error 1
    gmake[1]: Leaving directory `/raid/bangerth/p/deal.II/1/code-gallery/build/CMakeFiles/CMakeTmp'
    gmake: *** [cmTC_f0d54/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:8 (project)


-- Configuring incomplete, errors occurred!

That is, it errors out while trying to identify a C++ compiler, which it takes from /usr/bin, but this is not the one I want it to use nor the one it should find via my $PATH:

 which c++
/scratch/local/gcc-11.2.0/bin/c++

It is also not the one it should inherit from the deal.II configuration system. (The specific error you see above is because I do `export CXXFLAGS=-std=c++20 which the system compiler predictably does not understand, it being GCC 4.8.)

Curiously, if I call cmake from the subdirectory into which I asked cmake to recurse (namely, advection_reaction_estimator), then this all works:

code-gallery/build> cd ../advection_reaction_estimator/
reaction_estimator> cmake .
-- The CXX compiler identification is GNU 11.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /scratch/local/gcc-11.2.0/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the deal.II-9.5.0-pre installation found at /home/fac/g/bangerth/p/deal.II/1/install
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_add_test.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_initialize_cached_variables.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_invoke_autopilot.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_pickup_tests.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_query_git_information.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_setup_target.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_shell_escape_option_groups.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_target_compile_flags.cmake
-- Include macro /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_target_link_flags.cmake
###
#
#  WARNING:
#
#  CMAKE_BUILD_TYPE "" unsupported by current installation!
#  deal.II was configured with "DebugRelease".
#
#  CMAKE_BUILD_TYPE was forced to "Debug".
#
###
-- The C compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /scratch/local/gcc-11.2.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Autopilot invoked
###
#
#  Project  DG_advection_reaction_estimator  set up with  deal.II-9.5.0-pre  found at
#      /home/fac/g/bangerth/p/deal.II/1/install
#
#  CMAKE_BUILD_TYPE:          Debug
#
#  You can now run
#       $ make                - to compile and link the program
#       $ make run            - to (compile, link and) run the program
#
#       $ make debug          - to switch the build type to 'Debug'
#       $ make release        - to switch the build type to 'Release'
#
#       $ make edit_cache     - to change (cached) configuration variables
#                               and rerun the configure and generate phases of CMake
#
#       $ make strip_comments - to strip the source files in this
#                               directory off their comments; this is irreversible
#       $ make clean          - to remove the generated executable as well as
#                               all intermediate compilation files
#       $ make runclean       - to remove all output generated by the program
#       $ make distclean      - to clean the directory from _all_ generated
#                               files (includes clean, runclean and the removal
#                               of the generated build system)
#       $ make info           - to view this message again
#
#  Have a nice day!
#
###
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fac/g/bangerth/p/deal.II/1/code-gallery/advection_reaction_estimator

How do we make this work? Or is setting up multiple deal.II-based projects at once just not supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions