22# Licensed under the BSD-2-Clause Plus Patent license.
33# SPDX-License-Identifier: BSD-2-Clause-Patent
44
5- list ( APPEND CMAKE_MESSAGE_CONTEXT CoarrayFypp )
5+ cmake_minimum_required ( VERSION 3.22...3.31 )
66
7- add_library (fortuno_example_coarray_fypp_mylib)
8- set_target_properties (
9- fortuno_example_coarray_fypp_mylib PROPERTIES
10- OUTPUT_NAME mylib
7+ project (coarray-fypp-example
8+ LANGUAGES Fortran
119)
10+
11+ find_package (Fortuno CONFIG REQUIRED)
12+
13+ find_program (FYPP fypp)
14+
15+ # TODO: decouple this from config.cmake setup
16+ # TODO: Do not hardcode the path dependence
17+ # Get the absolute path of the Fortuno repo
18+ cmake_path(SET Fortuno_Source_Dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR} /../../.." )
19+ include (${Fortuno_Source_Dir} /config.cmake)
20+ include (${Fortuno_Source_Dir} /cmake/FortunoHelpers.cmake)
21+
22+ add_library (mylib)
1223target_sources (
13- fortuno_example_coarray_fypp_mylib PRIVATE
24+ mylib PRIVATE
1425 mylib.f90
1526)
16- target_compile_options (fortuno_example_coarray_fypp_mylib PRIVATE ${FORTUNO_FFLAGS_COARRAY} )
17- target_link_options (fortuno_example_coarray_fypp_mylib PRIVATE ${FORTUNO_LDFLAGS_COARRAY} )
27+ target_compile_options (mylib PRIVATE ${FORTUNO_FFLAGS_COARRAY} )
28+ target_link_options (mylib PRIVATE ${FORTUNO_LDFLAGS_COARRAY} )
1829
19- add_executable (fortuno_example_coarray_fypp_testapp)
20- set_target_properties (
21- fortuno_example_coarray_fypp_testapp PROPERTIES
22- OUTPUT_NAME testapp
23- )
30+ add_executable (testapp)
2431
2532set (
2633 fypp-sources
@@ -33,20 +40,25 @@ get_target_property(
3340 INTERFACE_INCLUDE_DIRECTORIES
3441)
3542fortuno_preprocess(
36- ${FYPP} "-I${_fortuno_incdir} ;--file-var-root=${CMAKE_SOURCE_DIR } "
43+ ${FYPP} "-I${_fortuno_incdir} ;--file-var-root=${Fortuno_Source_Dir } "
3744 .fypp .f90
3845 "${fypp-sources}" fypp-f90-sources
3946)
4047
4148target_sources (
42- fortuno_example_coarray_fypp_testapp PRIVATE
49+ testapp PRIVATE
4350 ${fypp-f90-sources }
4451 testapp.f90
4552)
4653target_link_libraries (
47- fortuno_example_coarray_fypp_testapp
54+ testapp
4855 PRIVATE
49- fortuno_example_coarray_fypp_mylib Fortuno::fortuno_coarray
56+ mylib Fortuno::fortuno_coarray
57+ )
58+ target_compile_options (testapp PRIVATE ${FORTUNO_FFLAGS_COARRAY} )
59+ target_link_options (testapp PRIVATE ${FORTUNO_LDFLAGS_COARRAY} )
60+
61+ enable_testing ()
62+ add_test (NAME fortuno_test
63+ COMMAND testapp
5064)
51- target_compile_options (fortuno_example_coarray_fypp_testapp PRIVATE ${FORTUNO_FFLAGS_COARRAY} )
52- target_link_options (fortuno_example_coarray_fypp_testapp PRIVATE ${FORTUNO_LDFLAGS_COARRAY} )
0 commit comments