-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
151 lines (120 loc) · 4.91 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#
# ____ _____ _______
# | _ \ /\ | __ \__ __|
# | |_) | / \ | |__) | | |
# | _ < / /\ \ | _ / | |
# | |_) / ____ \| | \ \ | |
# |____/_/ \_\_| \_\ |_|
#
# Bay Area Radiation Transport
#
# CMakeLists derived from dealii example CMakeFiles
#
# Author: J.S. Rehak <[email protected]>
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(bart)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 20)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
### DEPENDENCIES #####################################################
# Check that DEAL II is installed
FIND_PACKAGE(deal.II 8.4 QUIET
HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
)
IF(NOT ${deal.II_FOUND})
MESSAGE(FATAL_ERROR "\n"
"*** Could not locate a (sufficiently recent) version of deal.II. ***\n\n"
"You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
"or set an environment variable \"DEAL_II_DIR\" that contains this path."
)
ENDIF()
#
# Are all dependencies fulfilled?
#
IF(NOT (DEAL_II_WITH_PETSC OR DEAL_II_WITH_TRILINOS) OR NOT DEAL_II_WITH_P4EST)
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_PETSC = ON
DEAL_II_WITH_P4EST = ON
or
DEAL_II_WITH_TRILINOS = ON
DEAL_II_WITH_P4EST = ON
One or both of these combinations are OFF in your installation but at least one is required for this tutorial step."
)
ENDIF()
### GTEST/GMOCK ######################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
set(GTEST_ROOT "/usr")
find_package(GTest REQUIRED 1.8.0)
find_package(GMock REQUIRED)
### PROTOCOL BUFFERS #################################################
#include(FindProtobuf)
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS
"${CMAKE_SOURCE_DIR}/protobuf/material.proto")
get_filename_component(PROTO_INC_DIR ${PROTO_HDRS} DIRECTORY)
### COMPILE AND LINKER FLAGS #########################################
SET(DEAL_II_CXX_FLAGS_DEBUG "${DEAL_II_CXX_FLAGS_DEBUG} -g -O0 --coverage")
SET(DEAL_II_LINKER_FLAGS_DEBUG "${DEAL_II_LINKER_FLAGS_DEBUG} --coverage")
### OTHER DEPENDENCIES ###############################################
find_package(fmt)
######################################################################
DEAL_II_INITIALIZE_CACHED_VARIABLES()
SET(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd
*.d2 *.vtu *.pvtu)
ENABLE_TESTING()
### EXECUTABLES AND SOURCES ##########################################
# Recursively find source files
file(GLOB_RECURSE sources "src/[a-zA-Z]*.cpp" "src/[a-zA-Z]*.cc")
list(APPEND sources ${PROTO_SRCS} ${PROTO_HDRS})
set(testing_sources ${sources})
list(FILTER sources EXCLUDE REGEX ".*/tests/.*")
list(FILTER sources EXCLUDE REGEX ".*/test_helpers/.*")
list(FILTER sources EXCLUDE REGEX ".*/test_main.cc$")
list(FILTER testing_sources EXCLUDE REGEX ".*/main.cc$")
# Include directories
include_directories(${GTEST_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/inc
${CMAKE_SOURCE_DIR}/src
${PROTO_INC_DIR})
# Add BART executables
ADD_EXECUTABLE(bart ${sources})
ADD_EXECUTABLE(bart_test ${testing_sources})
# Add testing definition and library to bart_test
target_compile_definitions(bart_test PUBLIC -DTEST)
target_link_libraries(bart ${Protobuf_LIBRARIES} -lfftw3 fmt::fmt)
target_link_libraries(bart_test ${GTEST_BOTH_LIBRARIES}
${GMOCK_BOTH_LIBRARIES} ${Protobuf_LIBRARIES} -lfftw3 fmt::fmt)
DEAL_II_SETUP_TARGET(bart)
DEAL_II_SETUP_TARGET(bart_test)
### TEST FILES ##################################################
# Create copies of .gold files in the BART/src directory for gtest
add_custom_target(copy_gtest_files ALL)
add_custom_command(TARGET copy_gtest_files PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory test_data)
file(GLOB_RECURSE gtest_files "src/*.gold" "src/*.test_material_mapping")
foreach(test_file ${gtest_files})
get_filename_component(file_name ${test_file} NAME)
add_custom_command(
TARGET copy_gtest_files PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${test_file}
${CMAKE_CURRENT_BINARY_DIR}/test_data/${file_name})
endforeach()
add_dependencies(bart_test copy_gtest_files)
# Creates copies of .output files in the BART/test directory for CTEST
add_custom_target(copy_ctest_output_files ALL)
file(GLOB_RECURSE ctest_files "tests/*.output")
foreach(test_file ${ctest_files})
string(REGEX REPLACE ".*BART/tests" "${CMAKE_CURRENT_BINARY_DIR}/tests"
file_name ${test_file})
add_custom_command(
TARGET copy_ctest_output_files PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${test_file} ${file_name})
endforeach()
add_dependencies(bart_test copy_ctest_output_files)
# Create copies of material protocol buffer data
add_custom_target(copy_protoc_files ALL)
file(COPY "src/data/material/tests/data/" DESTINATION "./test_data/material")
add_dependencies(bart_test copy_protoc_files)