-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (84 loc) · 3.43 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
cmake_minimum_required(VERSION 3.16.3)
project(GMGPolar VERSION 1.0.0)
option(GMGPOLAR_BUILD_TESTS "Build GMGPolar unit tests." ON)
option(GMGPOLAR_USE_MUMPS "Use MUMPS to compute matrix factorizations." OFF)
option(GMGPOLAR_USE_LIKWID "Use LIKWID to measure code (regions)." OFF)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS "")
set(CMAKE_LINKER_FLAGS "")
add_subdirectory(src)
# code coverage analysis
# Note: this only works under linux and with make
# Ninja creates different directory names which do not work together with this scrupt
# as STREQUAL is case-sensitive https://github.com/TriBITSPub/TriBITS/issues/131, also allow DEBUG as accepted input
option(GMGPOLAR_TEST_COVERAGE "Enable GCov coverage analysis (adds a 'coverage' target)" OFF)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if(GMGPOLAR_TEST_COVERAGE)
message(STATUS "Coverage enabled")
include(CodeCoverage)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
NAME coverage
EXECUTABLE tests/gmgpolar_tests
EXCLUDE "${CMAKE_SOURCE_DIR}/tests*" "${CMAKE_SOURCE_DIR}/src/test_cases*" "${CMAKE_BINARY_DIR}/*" "/usr*"
)
endif()
endif()
add_library(GMGPolar ${SOURCES_SRC})
add_executable(gmgpolar_simulation ./src/main.cpp)
configure_file(${CMAKE_SOURCE_DIR}/include/config_internal.h.in ${CMAKE_SOURCE_DIR}/include/config_internal.h)
target_include_directories(gmgpolar_simulation PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/test_cases )
target_include_directories(GMGPolar PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/test_cases )
if(GMGPOLAR_USE_LIKWID)
find_package(LIKWID REQUIRED)
target_include_directories(GMGPolar PUBLIC ${LIKWID_INCLUDE_DIRS})
target_link_libraries(GMGPolar PUBLIC ${LIKWID_LIBRARIES})
target_compile_definitions(GMGPolar PUBLIC "-DLIKWID_PERFMON")
endif()
if(GMGPOLAR_USE_MUMPS)
set(INC_DIRS
/home/kueh_mj/.spack/rev.23.05/install/linux-rocky8-zen2/gcc-10.4.0/mumps-5.4.1-fftqkl/include
/sw/rev/23.05/linux-rocky8-zen2/gcc-10.4.0/metis-5.1.0-akhgsf/include
)
set(LIB_DIRS
/home/kueh_mj/.spack/rev.23.05/install/linux-rocky8-zen2/gcc-10.4.0/mumps-5.4.1-fftqkl/lib
/sw/rev/23.05/linux-rocky8-zen2/gcc-10.4.0/metis-5.1.0-akhgsf/lib
)
include_directories(
${INC_DIRS}
)
target_link_directories(
GMGPolar
PUBLIC
${LIB_DIRS}
)
set(LIBS
mpiseq
dmumps
mumps_common
metis
)
target_link_libraries(
GMGPolar
PUBLIC
${LIBS}
)
endif()
find_package(OpenMP)
#currently works on GNU compiler
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7))
string(APPEND CMAKE_CXX_FLAGS " -O2 -Wall -MMD -MP -Wwrite-strings")
string(APPEND CMAKE_LINKER_FLAGS " -O2 -Wall -MMD -MP -Wwrite-strings")
if(OPENMP_FOUND)
string(APPEND CMAKE_CXX_FLAGS " -fopenmp")
string(APPEND CMAKE_LINKER_FLAGS " -fopenmp")
else()
message(FATAL_ERROR "OpenMP needed")
endif()
else()
message(FATAL_ERROR "Please use GNU compiler or change CMakeLists manually")
endif()
target_link_libraries(gmgpolar_simulation PRIVATE GMGPolar)
include(thirdparty/CMakeLists.txt)
add_subdirectory(tests)