forked from geospace-code/h5fortran
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
53 lines (40 loc) · 1.9 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
cmake_minimum_required(VERSION 3.11...3.25)
project(h5fortranExample
LANGUAGES C CXX Fortran)
enable_testing()
find_package(h5fortran CONFIG REQUIRED)
# --- Fortran interface for examples
add_library(fortran_interface fortran_interface.f90)
target_link_libraries(fortran_interface PRIVATE h5fortran::h5fortran)
add_executable(ex_fcn ex_fcn.f90)
target_link_libraries(ex_fcn PRIVATE h5fortran::h5fortran)
add_test(NAME Fortran_fcn COMMAND ex_fcn)
add_executable(ex_oo ex_oo.f90)
target_link_libraries(ex_oo PRIVATE h5fortran::h5fortran)
add_test(NAME Fortran_oo COMMAND ex_oo)
add_executable(repeat_char_read char_repeat_read.f90)
target_link_libraries(repeat_char_read PRIVATE h5fortran::h5fortran)
## VTK HDF5 write example
add_executable(vtk_write vtk_write.f90)
target_link_libraries(vtk_write PRIVATE h5fortran::h5fortran)
add_test(NAME VTK COMMAND vtk_write ${CMAKE_CURRENT_BINARY_DIR}/vtk.hdf)
## C, C++ examples
add_executable(c_fcn ex_fcn.c)
target_link_libraries(c_fcn PRIVATE fortran_interface)
target_compile_features(c_fcn PRIVATE c_std_99)
# https://en.cppreference.com/w/c/types/integer
add_test(NAME C_fcn COMMAND c_fcn)
add_executable(cpp_fcn ex_fcn.cpp)
target_link_libraries(cpp_fcn PRIVATE fortran_interface)
target_compile_features(cpp_fcn PRIVATE cxx_std_11)
# https://en.cppreference.com/w/cpp/types/integer
add_test(NAME CPP_fcn COMMAND cpp_fcn)
# properties
get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS)
set_property(TEST ${test_names} PROPERTY TIMEOUT 10)
set_property(TEST ${test_names} PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
set_property(TEST ${test_names} PROPERTY
ENVIRONMENT_MODIFICATION "PATH=path_list_append:${ZLIB_INCLUDE_DIRS}/../bin;PATH=path_list_append:${ZLIB_INCLUDE_DIR}/../bin;PATH=path_list_append:${PROJECT_BINARY_DIR}/bin;PATH=path_list_append:${h5fortran_DIR}/../bin"
)
endif()