Skip to content

Fix MLModule post-build copy path for MSVC generators#802

Merged
Andrey1994 merged 2 commits into
brainflow-dev:masterfrom
baris-talar:fix-dll-copy-mingw
Apr 26, 2026
Merged

Fix MLModule post-build copy path for MSVC generators#802
Andrey1994 merged 2 commits into
brainflow-dev:masterfrom
baris-talar:fix-dll-copy-mingw

Conversation

@baris-talar
Copy link
Copy Markdown
Contributor

Fixes an inconsistency in src/ml/build.cmake where MSVC POST_BUILD steps assume a config subdirectory (compiled/$<CONFIG>/...) while output is set to compiled/.

Replaces hardcoded source paths with target-based generator expressions:

  • $<TARGET_FILE:${ML_MODULE_NAME}>
  • $<TARGET_LINKER_FILE:${ML_MODULE_NAME}>

This improves compatibility with single-config generators (e.g. Ninja in CLion) where artifacts may not be placed in config-specific subdirectories.

Related to #255 and #604.

@Andrey1994
Copy link
Copy Markdown
Member

looks good to me, but I believe board controller and data handler use the same pattern and should be updated the same way

@baris-talar
Copy link
Copy Markdown
Contributor Author

Thanks!

Before I update those, could you clarify the expected scope so I don’t over-apply the change:

  • Should I apply the same $&lt;TARGET_FILE&gt; / $&lt;TARGET_LINKER_FILE> replacement to all MSVC POST_BUILD copy commands in board_controller and data_handler?
  • Or only to targets where output directories are set to a non-config-specific path like compiled?

If possible, I’d really appreciate as much detail as you can provide (e.g. specific files, targets, or patterns to update), so I can apply the fix correctly and keep the patch consistent.

@Andrey1994
Copy link
Copy Markdown
Member

Andrey1994 commented Apr 17, 2026

I think everything what uses pattern like ${CMAKE_CURRENT_SOURCE_DIR}/compiled/$<CONFIG>/NAME_HERE can be replaced with it.

Also with this is there a real need for:

if (msvc)
....
else

The idea to add this if else was to handle $CONFIG and different paths as a result for different OSes

@Andrey1994
Copy link
Copy Markdown
Member

if (UNIX AND NOT ANDROID)
    add_custom_command (TARGET ${ML_MODULE_NAME} POST_BUILD
        COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${ML_MODULE_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/nodejs_package/brainflow/lib/${ML_MODULE_COMPILED_NAME}"
        COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${ML_MODULE_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/python_package/brainflow/lib/${ML_MODULE_COMPILED_NAME}"
        COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/compiled/${ML_MODULE_COMPILED_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/julia_package/brainflow/lib/${ML_MODULE_COMPILED_NAME}"

In the file you have changed this part probably can be removed now? Just make sure we dont copy it for ANDROID

@baris-talar
Copy link
Copy Markdown
Contributor Author

Thanks, I’ve updated the same pattern in ml, board controller, and data handler, while keeping Android logic and external dependency copies unchanged.

@Andrey1994
Copy link
Copy Markdown
Member

@codex

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Andrey1994 Andrey1994 merged commit 2befe44 into brainflow-dev:master Apr 26, 2026
11 checks passed
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 this pull request may close these issues.

2 participants