Open Timmmm opened 1 year ago
Actually my description was a bit off - linking with libfoo.so
is fine, the issue is if you generate a .sv
file. In our case I could simply move that generation to configure time too. It's not ideal but it does work:
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/input_file.foo")
execute_process(
COMMAND "my_generator" -i "${CMAKE_CURRENT_SOURCE_DIR}/input_file.foo" -o "output_file.sv"
COMMAND_ERROR_IS_FATAL ANY
)
...
@codelec for thoughts.
looks similar to the issue here https://stackoverflow.com/questions/44499435/how-can-i-run-cmake-from-within-cmake
I think the best way to fix this would be to add a single-output-file mode to Verilator (which would be quite nice anyway!). That way you don't need to actually run Verilator to know what the input files to the output binary target are.
However in my case generating the SV code at configure time is actually a reasonable solution so it's less of an issue for me than I thought. Feel free to close this if you like!
Single file will not scale to reasonable sized designs, so I'd prefer not to go that way.
hey, I have a similar usecase, I am generating multiple source files from a different script, what would be the recommended way to implement this in cmake so it is built properly ?
The CMake support you've added is great but unfortunately I think it is done in a way that makes it basically impossible to use with any generated code (which is very common in my experience).
For example, suppose you would normally do this:
Seems pretty reasonable, but it's more or less impossible with the current CMake support because the
g++
command will run at build time, and theverilator
command will run at configure time (beforelibfoo.so
exists).Fundamentally, the
verilator
command should run at build time instead usingadd_custom_command()
.I had a look at the code and actually it looks like it does do that, but then there's also some other code that calls
execute_process()
too which is what causes the problem.I would guess this is a dynamic dependency issue.