forked from OPM/opm-upscaling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmbedCases.cmake
60 lines (51 loc) · 2.53 KB
/
EmbedCases.cmake
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
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
macro (opm_pack_file case_dir case_name suffix in_ext out_ext)
# put the output in the same relative path in the output; we then
# get no change if we build in-source
set (rel_file "${case_dir}/${case_name}${suffix}")
set (input_file "${PROJECT_SOURCE_DIR}/${rel_file}${in_ext}")
set (output_file "${PROJECT_BINARY_DIR}/${rel_file}${out_ext}")
# make sure that the output directory exists
get_filename_component (output_dir "${output_file}" PATH)
file (MAKE_DIRECTORY "${output_dir}")
# run the shell script to encode the file
set (pack_script "${PROJECT_SOURCE_DIR}/benchmarks/input/create_hex_data_file.sh")
add_custom_command (
OUTPUT "${output_file}"
COMMAND "${pack_script}"
ARGS "${input_file}" "${output_file}"
DEPENDS "${input_file}" "${pack_script}"
COMMENT "Creating packed binary of ${rel_file}"
)
# cannot add files to targets other than in add_custom_target,
# and that command can only run once, so we must return a list
# of dependencies that is added
list (APPEND ${case_name}_DEPENDS "${output_file}")
endmacro (opm_pack_file)
# each case consists of a .grdecl file and a .data file
macro (opm_pack_case test_exe case_name)
opm_pack_file ("benchmarks/input" "${case_name}" "_grid" ".grdecl" ".grdecl.gz.hex")
opm_pack_file ("benchmarks/input" "${case_name}" "_upscaled_relperm" ".out" ".out.gz.hex")
# we cannot add files directly (sic) but must wrap in a target
add_custom_target (${case_name} DEPENDS ${${case_name}_DEPENDS})
add_dependencies ("${test_exe}" "${case_name}")
list(APPEND OPM_BENCHMARKS ${test_exe})
endmacro (opm_pack_case)
# rel.perm curve is packed separately because it is common for all cases
macro (opm_pack_stone test_exe)
opm_pack_file ("benchmarks/input" "stonefile" "_benchmark" ".txt" ".txt.gz.hex")
add_custom_target (stonefile ALL DEPENDS ${stonefile_DEPENDS})
add_dependencies ("${test_exe}" "stonefile")
endmacro (opm_pack_stone)
# pack these cases which are alternatives in the code
if(Boost_IOSTREAMS_FOUND)
opm_pack_stone (upscale_relperm_benchmark)
opm_pack_case (upscale_relperm_benchmark benchmark20)
if(INSTALL_BENCHMARKS)
add_custom_target(benchmarks ALL DEPENDS upscale_relperm_benchmark)
set_target_properties(upscale_relperm_benchmark PROPERTIES EXCLUDE_FROM_ALL 0)
else()
add_custom_target(benchmarks DEPENDS upscale_relperm_benchmark)
endif()
endif()