diff --git a/example/CMakeProjectSubdir/ALL_test_src.cpp b/example/CMakeProjectSubdir/ALL_test_src.cpp new file mode 120000 index 0000000000000000000000000000000000000000..4ade0dc2b2c72bdc89006407f66ef7965ea88924 --- /dev/null +++ b/example/CMakeProjectSubdir/ALL_test_src.cpp @@ -0,0 +1 @@ +../ALL_test.cpp \ No newline at end of file diff --git a/example/CMakeProjectSubdir/CMakeLists.txt b/example/CMakeProjectSubdir/CMakeLists.txt index a7afacce6aca6f91786b62aab9c81e1a7323a7da..b13887ec09ce4a62bbf8bd97d7243e093dd37772 100644 --- a/example/CMakeProjectSubdir/CMakeLists.txt +++ b/example/CMakeProjectSubdir/CMakeLists.txt @@ -1,6 +1,5 @@ -# REMEMBER TO SET CC AND CXX! CMake is too dumb to find compiler in your path! -# mkdcd build -# CC=gcc CXX=g++ cmake -DALL_DIR=`pwd`/../../jall_bin/lib/cmake/ALL ../ +# REMEMBER TO SET CC AND CXX! +# CC=gcc CXX=g++ cmake -S . -B build -DALL_DIR=`pwd`/../../jall_bin/lib/cmake/ALL cmake_minimum_required(VERSION 3.14) project(ExampleProject) @@ -11,20 +10,42 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# For cleaner code we should also include MPI here, since this project's source +# also needs MPI. Otherwise, we are free to leave it out, since the parts +# required by ALL are automatically included. +find_package(MPI REQUIRED COMPONENTS CXX Fortran) + +# Some variants for testing VTK output and the voronoi method. These are only +# required, so the code used in .this. project has the corresponding features +# enabled and calls the respective functions from the library. This is not +# required for the library itself. Although the library needs to be build with +# the respective features enabled. +add_compile_definitions(TEST_VTK_OUTPUT) +add_compile_definitions(TEST_VORONOI) + set(CM_ALL_FORTRAN ON) #set(CM_ALL_USE_F08 ON) set(CM_ALL_VORONOI ON) -#set(CM_ALL_VTK_OUTPUT ON) +set(CM_ALL_VTK_OUTPUT ON) add_subdirectory(all) -#find_package(MPI REQUIRED COMPONENTS CXX Fortran) +# The target names have Ex prefixed, since these are already taken by the library itself. +add_executable(ExALL_Staggered ALL_Staggered.cpp) +target_link_libraries(ExALL_Staggered PUBLIC ALL) +# This is in this case not .necessary., since it is already inherited from ALL, +# however, for readability and clear intent, we should still link against MPI +# ourselves, since our code also uses MPI directly. +target_link_libraries(ExALL_Staggered PUBLIC ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES}) +target_include_directories(ExALL_Staggered PRIVATE ${MPI_CXX_INCLUDE_PATH}) -add_executable(EALL_Staggered ALL_Staggered.cpp) -target_link_libraries(EALL_Staggered PRIVATE ALL) +add_executable(ExALL_Staggered_f ALL_Staggered_f.F90) +set_property(TARGET ExALL_Staggered_f PROPERTY LINKER_LANGUAGE Fortran) +target_link_libraries(ExALL_Staggered_f PUBLIC ALL_fortran) +target_link_libraries(ExALL_Staggered_f PUBLIC ${MPI_Fortran_LINK_FLAGS} ${MPI_Fortran_LIBRARIES}) +target_include_directories(ExALL_Staggered_f PRIVATE ${MPI_Fortran_INCLUDE_PATH}) -add_executable(EALL_Staggered_f ALL_Staggered_f.F90) -target_link_libraries(EALL_Staggered_f LINK_PRIVATE ALL) -target_link_libraries(EALL_Staggered_f LINK_PRIVATE ALL_fortran) -set_property(TARGET EALL_Staggered_f PROPERTY LINKER_LANGUAGE Fortran) -#todo(s.schulz): link against MPI +add_executable(ExALL_test ALL_test.cpp) +target_link_libraries(ExALL_test PUBLIC ALL) +target_link_libraries(ExALL_test PUBLIC ${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES}) +target_include_directories(ExALL_test PRIVATE ${MPI_CXX_INCLUDE_PATH}) diff --git a/example/CMakeProjectSubdir/build_all.sh b/example/CMakeProjectSubdir/build_all.sh index 960c622ad9954a6f7a94d0518cfcfd5fab210e34..8f8fe629982e72b6c97a0ac61957a08207c2401d 100755 --- a/example/CMakeProjectSubdir/build_all.sh +++ b/example/CMakeProjectSubdir/build_all.sh @@ -1,3 +1,13 @@ #!/bin/bash +export VTK_DIR="`pwd`/vtk_bin/lib/cmake/vtk-7.1" + +prepare_example () { + cat $1 | sed \ + -e 's/ALL_VTK_OUTPUT/TEST_VTK_OUTPUT/'\ + -e 's/ALL_VORONOI_ACTIVE/TEST_VORONOI/'\ + > $2 +} + +prepare_example ALL_test_src.cpp ALL_test.cpp rm -rf build && CC=gcc CXX=g++ cmake -S . -B build && VERBOSE=1 cmake --build build diff --git a/example/CMakeProjectSubdir/vtk_bin_contains_vtk_install_dir b/example/CMakeProjectSubdir/vtk_bin_contains_vtk_install_dir new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391