Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when blt_add_code_checks calls blt_add_yapf_target #624

Closed
chapman39 opened this issue Mar 6, 2023 · 1 comment · Fixed by #625
Closed

Error when blt_add_code_checks calls blt_add_yapf_target #624

chapman39 opened this issue Mar 6, 2023 · 1 comment · Fixed by #625

Comments

@chapman39
Copy link
Contributor

Having this issue in LiDO where when I call blt_add_code_checks I get the following error:

CMake Error at cmake/blt/cmake/SetupCodeChecks.cmake:873 (message):
  blt_add_yapf_target requires a SRC_FILES parameter
Call Stack (most recent call first):
  cmake/blt/cmake/SetupCodeChecks.cmake:246 (blt_add_yapf_target)
  CMakeLists.txt:187 (blt_add_code_checks)

The SRC_FILES variable is set to _py_sources (retrieved from blt_split_source_list_by_language, see https://github.com/LLNL/blt/blob/develop/cmake/SetupCodeChecks.cmake#L156).

I guess when blt_split_source_list_by_language is called, Python_LIST is empty, which means _py_sources is empty, which means SRC_FILES is "" when it gets down to blt_add_yapf_target.

When I commented out the fatal error I was able to make by LiDO build without issues. Maybe this check is not required?

@white238
Copy link
Member

white238 commented Mar 7, 2023

I see two solutions:

  1. Have the user required to not provide a YAPF config file if you don't provide Python files to add code checks for (this seems less than robust).

  2. Check on each of these if blocks that you are actually providing source files to run checks for:

    if (YAPF_FOUND AND DEFINED arg_YAPF_CFG_FILE)
    set(_check_target_name ${arg_PREFIX}_yapf_check)
    blt_error_if_target_exists(${_check_target_name} ${_error_msg})
    set(_style_target_name ${arg_PREFIX}_yapf_style)
    blt_error_if_target_exists(${_style_target_name} ${_error_msg})
    blt_add_yapf_target( NAME ${_check_target_name}
    MODIFY_FILES FALSE
    CFG_FILE ${arg_YAPF_CFG_FILE}
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    SRC_FILES ${_py_sources} )
    blt_add_yapf_target( NAME ${_style_target_name}
    MODIFY_FILES TRUE
    CFG_FILE ${arg_YAPF_CFG_FILE}
    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    SRC_FILES ${_py_sources} )
    endif()

I would lean towards the second option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants