@@ -8,123 +8,50 @@ option(GMGPOLAR_USE_MUMPS "Use MUMPS to solve linear systems." OFF)
88set (CMAKE_CXX_STANDARD 20)
99set (CMAKE_CXX_STANDARD_REQUIRED True )
1010
11+ set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake" ${CMAKE_MODULE_PATH} )
12+
1113if (NOT CMAKE_BUILD_TYPE )
1214 set (CMAKE_BUILD_TYPE Release)
1315endif ()
1416
15- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wno-unused" )
16- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -mtune=generic" )
17-
18- # # Mumps: Sparse Matrix Solver
19- # set(MUMPS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/mumps-5.6.2-m4xrhc4mshzrxmgptzbpult3nbf6qrzk")
20- # include_directories(${MUMPS_PREFIX_PATH}/include)
21- # link_directories(${MUMPS_PREFIX_PATH}/lib)
22-
23- # # Metis: Matrix reordering for Mumps
24- # set(METIS_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/metis-5.1.0-bgoncx22w55soviybggl5ydjakvkm34v")
25- # include_directories(${METIS_PREFIX_PATH}/include)
26- # link_directories(${METIS_PREFIX_PATH}/lib)
27-
28- # # Likwid: Performance monitoring
29- # set(LIKWID_PREFIX_PATH "~/spack/opt/spack/linux-ubuntu20.04-icelake/gcc-9.4.0/likwid-5.3.0-6mvx2snsqnamuyhaqspd6gxkfuaso36g")
30- # include_directories(${LIKWID_PREFIX_PATH}/include)
31- # link_directories(${LIKWID_PREFIX_PATH}/lib)
32-
33- # Include directories for the project
34- include_directories (include )
35-
36- # 1. Create a library target for the PolarGrid module
37- file (GLOB_RECURSE POLAR_GRID_SOURCES "src/PolarGrid/*.cpp" )
38- add_library (PolarGrid STATIC ${POLAR_GRID_SOURCES} )
39- target_include_directories (PolarGrid PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /src/PolarGrid )
40-
41- # 2. Create a library target for the InputFunctions module
42- file (GLOB_RECURSE INPUT_FUNCTIONS_SOURCES
43- "src/InputFunctions/DensityProfileCoefficients/*.cpp"
44- "src/InputFunctions/DomainGeometry/*.cpp"
45- "src/InputFunctions/ExactSolution/*.cpp"
46- "src/InputFunctions/BoundaryConditions/*.cpp"
47- "src/InputFunctions/SourceTerms/*.cpp"
48- )
49- add_library (InputFunctions STATIC ${INPUT_FUNCTIONS_SOURCES} )
50- target_include_directories (InputFunctions PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} /src/InputFunctions )
51-
52- # 3. Collect all the common source files for GMGPolar into a library
53- file (GLOB_RECURSE GMG_POLAR_SOURCES "src/GMGPolar/*.cpp" )
54- file (GLOB_RECURSE MULTIGRID_METHODS_SOURCES "src/GMGPolar/MultigridMethods/*.cpp" )
55- file (GLOB_RECURSE LEVEL_SOURCES "src/Level/*.cpp" )
56- file (GLOB_RECURSE STENCIL_SOURCES "src/Stencil/*.cpp" )
57- file (GLOB_RECURSE INTERPOLATION_SOURCES "src/Interpolation/*.cpp" )
58- file (GLOB_RECURSE DIRECT_SOLVER_SOURCES "src/DirectSolver/*.cpp" "src/DirectSolverGive/*.cpp" "src/DirectSolverTake/*.cpp" "src/DirectSolverGiveCustomLU/*.cpp" "src/DirectSolverTakeCustomLU/*.cpp" )
59- file (GLOB_RECURSE RESIDUAL_SOURCES "src/Residual/*.cpp" "src/Residual/ResidualGive/*.cpp" "src/Residual/ResidualTake/*.cpp" )
60- file (GLOB_RECURSE SMOOTHER_SOURCES "src/Smoother/*.cpp" "src/SmootherGive/*.cpp" "src/SmootherTake/*.cpp" )
61- file (GLOB_RECURSE EXTRAPOLATED_SMOOTHER_SOURCES "src/ExtrapolatedSmoother/*.cpp" "src/ExtrapolatedSmoother/ExtrapolatedSmootherGive/*.cpp" "src/ExtrapolatedSmoother/ExtrapolatedSmootherTake/*.cpp" )
62-
63- # 4. Create the GMGPolarLib library and link PolarGrid and InputFunctions
64- add_library (GMGPolarLib STATIC
65- ${GMG_POLAR_SOURCES}
66- ${MULTIGRID_METHODS_SOURCES}
67- ${LEVEL_SOURCES}
68- ${STENCIL_SOURCES}
69- ${INTERPOLATION_SOURCES}
70- ${DIRECT_SOLVER_SOURCES}
71- ${RESIDUAL_SOURCES}
72- ${SMOOTHER_SOURCES}
73- ${EXTRAPOLATED_SMOOTHER_SOURCES}
74- )
75- # Link PolarGrid and InputFunctions to GMGPolarLib
76- target_link_libraries (GMGPolarLib PUBLIC PolarGrid InputFunctions )
77-
78- # Link Likwid to GMGPolarLib
79- if (GMGPOLAR_USE_LIKWID)
80- target_link_libraries (GMGPolarLib PUBLIC likwid )
81- target_compile_definitions (GMGPolarLib PUBLIC "-DLIKWID_PERFMON" )
82- add_compile_definitions (GMGPOLAR_USE_LIKWID )
83- endif ()
84-
85- # Link Mumps to GMGPolarLib
86- if (GMGPOLAR_USE_MUMPS)
87- set (MUMPS_LIBRARIES
88- mumps_common
89- smumps
90- dmumps
91- mpiseq
92- metis
93- )
94- target_link_libraries (GMGPolarLib PUBLIC ${MUMPS_LIBRARIES} )
95- add_compile_definitions (GMGPOLAR_USE_MUMPS )
96- endif ()
97-
98- # Add OpenMP flags if available and link to GMGPolarLib
99- find_package (OpenMP REQUIRED )
100- if (OpenMP_CXX_FOUND)
101- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} " )
102- target_link_libraries (GMGPolarLib PUBLIC OpenMP::OpenMP_CXX )
17+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wno-unused -Wno-psabi" )
18+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -mtune=generic -Wno-psabi" )
19+
20+ # code coverage analysis
21+ # Note: this only works under linux and with make
22+ # Ninja creates different directory names which do not work together with this scrupt
23+ # as STREQUAL is case-sensitive https://github.com/TriBITSPub/TriBITS/issues/131, also allow DEBUG as accepted input
24+ option (GMGPOLAR_TEST_COVERAGE "Enable GCov coverage analysis (adds a 'coverage' target)" OFF )
25+
26+ if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
27+ if (GMGPOLAR_TEST_COVERAGE)
28+ message (STATUS "Coverage enabled" )
29+ include (CodeCoverage )
30+ append_coverage_compiler_flags ()
31+ setup_target_for_coverage_lcov (
32+ NAME coverage
33+ EXECUTABLE tests/gmgpolar_tests
34+ LCOV_ARGS --ignore-errors gcov,mismatch
35+ EXCLUDE "${CMAKE_SOURCE_DIR} /tests*" "${CMAKE_SOURCE_DIR} /src/InputFunctions*" "${CMAKE_BINARY_DIR} /*" "/usr*"
36+ )
37+ endif ()
10338endif ()
10439
105- # 5. Add the main executable target (gmgpolar)
106- set (MAIN_SOURCE "src/main.cpp" )
107- add_executable (gmgpolar ${MAIN_SOURCE} )
108-
109- # 6. Add another executable target (convergence_order)
110- set (CONVERGENCE_ORDER_SOURCE "src/convergence_order.cpp" )
111- add_executable (convergence_order ${CONVERGENCE_ORDER_SOURCE} )
112-
113- set (WEAK_SCALING_SOURCE "src/weak_scaling.cpp" )
114- add_executable (weak_scaling ${WEAK_SCALING_SOURCE} )
40+ include_directories (include )
41+ add_subdirectory (src )
11542
116- set (STRONG_SCALING_SOURCE "src/strong_scaling.cpp" )
117- add_executable (strong_scaling ${STRONG_SCALING_SOURCE} )
43+ add_executable (gmgpolar src/main.cpp )
44+ add_executable (convergence_order src/convergence_order.cpp )
45+ add_executable (weak_scaling src/weak_scaling.cpp )
46+ add_executable (strong_scaling src/strong_scaling.cpp )
11847
119- # 7. Link GMGPolarLib (which now includes PolarGrid and InputFunctions) to both executables
12048target_link_libraries (gmgpolar PRIVATE GMGPolarLib )
12149target_link_libraries (convergence_order PRIVATE GMGPolarLib )
12250target_link_libraries (weak_scaling PRIVATE GMGPolarLib )
12351target_link_libraries (strong_scaling PRIVATE GMGPolarLib )
12452
125- # 9. Enable testing and include other directories
12653if (GMGPOLAR_BUILD_TESTS)
12754 enable_testing ()
12855 add_subdirectory (third-party )
12956 add_subdirectory (tests )
130- endif ()
57+ endif ()
0 commit comments