Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/add_fctest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cmake_policy( SET CMP0064 NEW ) # Recognize ``TEST`` as operator for the ``if()`

set( options )
set( single_value_args TARGET )
set( multi_value_args )
set( multi_value_args INCLUDEDIRS )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with ecbuild_add_test we should use INCLUDES, and they should already be part of the signature of add_fctest which just extends ecbuild_add_test.


cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )

Expand All @@ -55,7 +55,7 @@ cmake_policy( SET CMP0064 NEW ) # Recognize ``TEST`` as operator for the ``if()`
get_filename_component( base ${TESTSUITE} NAME_WE )

### Preprocess files with extension ".fypp.F90"
fckit_target_preprocess_fypp( ${_PAR_TARGET} )
fckit_target_preprocess_fypp( ${_PAR_TARGET} INCLUDEDIRS ${_PAR_INCLUDEDIRS} )

### Remove TESTSUITE from target
get_target_property( test_sources ${_PAR_TARGET} SOURCES )
Expand Down
2 changes: 1 addition & 1 deletion cmake/fckit-import.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else()
elseif( @HAVE_FCKIT_VENV@ )
set( _fckit_eval_script ${fckit_BASE_DIR}/libexec/fckit-eval.sh )
set( FCKIT_VENV_EXE ${fckit_BASE_DIR}/@rel_venv_exe_path@ )
set( FYPP ${_fckit_eval_script} ${FCKIT_VENV_EXE} -m fypp )
set( FYPP ${FCKIT_VENV_EXE} -m fypp )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fckit_eval_script is necessary, because it allowed to exclude some arguments:
#23

Copy link
Copy Markdown
Contributor

@awnawab awnawab Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which downstream app was the eval script causing a problem for? I solved a similar problem for FIELD_API in the past, so I might be able to help.

else()
set( FYPP ${fckit_BASE_DIR}/libexec/fckit-eval.sh
${fckit_BASE_DIR}/libexec/fckit-fypp.py )
Expand Down
1 change: 1 addition & 0 deletions cmake/fckit_install_venv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ macro( fckit_install_venv )

# Make the virtualenv portable by automatically deducing the VIRTUAL_ENV path from
# the 'activate' script's location in the filesystem
set (ENV{VIRTUAL_ENV} "${VENV_PATH}")
execute_process(
COMMAND
sed -i "s/^VIRTUAL_ENV=\".*\"$/VIRTUAL_ENV=\"$(cd \"$(dirname \"$(dirname \"\${BASH_SOURCE[0]}\" )\")\" \\&\\& pwd)\"/" "${VENV_PATH}/bin/activate"
Expand Down
27 changes: 5 additions & 22 deletions cmake/fckit_preprocess_fypp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,6 @@ function( fckit_target_append_fypp_args output target )
set( valid_target FALSE )
endif()
endif()
if( valid_target )
if( CMAKE_VERSION VERSION_LESS 3.12 ) # Hopefully we can remove this soon
foreach( include_property INCLUDE_DIRECTORIES;INTERFACE_INCLUDE_DIRECTORIES )
set( prop "$<TARGET_PROPERTY:${target},${include_property}>" )
list( APPEND _args "$<$<BOOL:${prop}>:-I $<JOIN:${prop}, -I >>" )
endforeach()
foreach( definitions_property COMPILE_DEFINITIONS;INTERFACE_COMPILE_DEFINITIONS )
set( prop "$<TARGET_PROPERTY:${target},${definitions_property}>" )
list( APPEND _args "$<$<BOOL:${prop}>:-D $<JOIN:${prop}, -D >>" )
endforeach()
else()
foreach( include_property INCLUDE_DIRECTORIES;INTERFACE_INCLUDE_DIRECTORIES )
set( prop "$<$<TARGET_EXISTS:${target}>:$<TARGET_PROPERTY:${target},${include_property}>>" )
list( APPEND _args "$<$<BOOL:${prop}>:-I $<JOIN:${prop}, -I >>" )
endforeach()
foreach( definitions_property COMPILE_DEFINITIONS;INTERFACE_COMPILE_DEFINITIONS )
set( prop "$<$<TARGET_EXISTS:${target}>:$<TARGET_PROPERTY:${target},${definitions_property}>>" )
list( APPEND _args "$<$<BOOL:${prop}>:-D $<JOIN:${prop}, -D >>" )
endforeach()
endif()
endif()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is required to automatically give the fypp preprocessor access to the target compile definitions and target include directories.
What is the issue w.r.t. robustness here?

# Append to output and set in parent scope
if( _args )
set(${output} ${${output}} ${_args} PARENT_SCOPE)
Expand Down Expand Up @@ -192,7 +171,7 @@ function( fckit_target_preprocess_fypp _PAR_TARGET )

set( options NO_LINE_NUMBERING )
set( single_value_args "" )
set( multi_value_args FYPP_ARGS FYPP_ARGS_EXCLUDE DEPENDS )
set( multi_value_args FYPP_ARGS FYPP_ARGS_EXCLUDE DEPENDS INCLUDEDIRS )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with ecbuild_add_executable we can name this INCLUDES and also add DEFINITIONS

                        [ INCLUDES <path1> [<path2> ...] ]
                        [ DEFINITIONS <definition1> [<definition2> ...] ]

cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )

if( TARGET ${_PAR_TARGET} )
Expand Down Expand Up @@ -245,6 +224,10 @@ function( fckit_target_preprocess_fypp _PAR_TARGET )
set( _NO_LINE_NUMBERING NO_LINE_NUMBERING )
endif()

foreach( dir ${_PAR_INCLUDEDIRS} )
list( APPEND args -I ${dir} )
endforeach()

fckit_preprocess_fypp_sources( preprocessed_sources
SOURCES ${sources_to_be_preprocessed}
${_NO_LINE_NUMBERING}
Expand Down