Open bangerth opened 1 year ago
I wouldn't expect in a CMake project that the compiler is inferred from any of the dependencies and specifying the compiler explicitly should still work. I am getting
$ cmake -DCMAKE_CXX_COMPILER=clang++ -DDEAL_II_DIR=~/Software/dealii-install/ ..
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is Clang 15.0.7
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /opt/homebrew/Cellar/llvm/15.0.7_1/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the deal.II-9.5.0-pre installation found at /Users/darndt/Software/dealii-install
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_add_test.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_initialize_cached_variables.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_invoke_autopilot.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_pickup_tests.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_query_git_information.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_deal_ii_setup_target.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_shell_escape_option_groups.cmake
-- Include macro /Users/darndt/Software/dealii-install/share/deal.II/macros/macro_target_compile_flags.cmake
-- Include macro /Users/darndt/Software/dealii-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".
#
###
-- Autopilot invoked
###
#
# Project DG_advection_reaction_estimator set up with deal.II-9.5.0-pre found at
# /Users/darndt/Software/dealii-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 sign - to sign the executable with the supplied OSX developer key
#
# $ 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: /Users/darndt/Software/dealii-code-gallery/build
Ah, interesting. Using -DCMAKE_CXX_COMPILER
actually works -- though it's not clear to me because I don't have to do that when configuring the individual code gallery programs, nor when configuring deal.II. It just gets the compiler from $PATH
.
Anyway, the next problem we run into is then this:
CMake Error at /home/fac/g/bangerth/p/deal.II/1/install/share/deal.II/macros/macro_deal_ii_invoke_autopilot.cmake:89 (add_custom_target):
add_custom_target cannot create target "run" because another target with
the same name already exists. The existing target is a custom target
created in source directory
"/home/fac/g/bangerth/p/deal.II/1/code-gallery/advection_reaction_estimator".
See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
NavierStokes_TRBDF2_DG/CMakeLists.txt:54 (DEAL_II_INVOKE_AUTOPILOT)
and many more of the same kind.
Right. This would work better if we were to use a more CMake-native approach again. 🙂 Something like
diff --git a/advection_reaction_estimator/CMakeLists.txt b/advection_reaction_estimator/CMakeLists.txt
index 826f55b..3091738 100644
--- a/advection_reaction_estimator/CMakeLists.txt
+++ b/advection_reaction_estimator/CMakeLists.txt
@@ -23,6 +23,5 @@ IF(NOT ${deal.II_FOUND})
)
ENDIF()
-DEAL_II_INITIALIZE_CACHED_VARIABLES()
-PROJECT(${TARGET})
-DEAL_II_INVOKE_AUTOPILOT()
+ADD_EXECUTABLE(${TARGET} ${TARGET_SRC})
+TARGET_LINK_LIBRARIES(${TARGET} dealii::dealii)
Yes. Once @tamiko has this all in a stable state, that's what we may want to do with the tutorials first, and then also the code gallery...
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:Interestingly, this does not work. When I create a build directory and call
cmake ..
from there, the output is the following: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
: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:How do we make this work? Or is setting up multiple deal.II-based projects at once just not supported?