Open Risto97 opened 2 months ago
I tried to use it in copy_rtl_files.cmake
like so, but for some reason it doesn't work and returns always empty strings (I'm doing something wrong for sure).
set(__CMD ${Python3_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/copy_rtl_files.py
$<$<BOOL:${ARG_TOP_MODULE}>:--top-module ${ARG_TOP_MODULE}>
$<$<BOOL:${ARG_SKIPLIST_FILE}>:--skiplist ${ARG_SKIPLIST_FILE}>
$<$<BOOL:${ARG_SYNTHESIS}>:--synthesis>
--deps_dir ${FETCHCONTENT_BASE_DIR}
${INCDIR_ARG}
$<IF:$<BOOL:${ARG_OUTDIR}>,--outdir ${ARG_OUTDIR},--outdir ${CMAKE_BINARY_DIR}/ip_sources>
${RTL_SOURCES}
)
Hello @mksoc
I was playing a bit more with the generator expressions, the issue seems to be having whitespaces in the generator expressions. It is explained here: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#whitespace-and-quoting
To summarise for your example, you need to:
Your command would look like this:
set(__CMD ${Python3_EXECUTABLE} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/copy_rtl_files.py
"$<$<BOOL:${ARG_TOP_MODULE}>:--top-module\;${ARG_TOP_MODULE}>"
"$<$<BOOL:${ARG_SKIPLIST_FILE}>:--skiplist\;${ARG_SKIPLIST_FILE}>"
"$<$<BOOL:${ARG_SYNTHESIS}>:--synthesis>"
--deps_dir ${FETCHCONTENT_BASE_DIR}
${INCDIR_ARG}
"$<IF:$<BOOL:${ARG_OUTDIR}>,--outdir\;${ARG_OUTDIR},--outdir\;${CMAKE_BINARY_DIR}/ip_sources>"
${RTL_SOURCES}
)
Also keep in mind that the the generator expressions are evaluated at the generate phase, after the configure phase.
This means that if you use it for OUTDIR variable, and later if you build a file path using that variable (file generated by a command), in the
You can decide if you think its worth using them for simple CLI options, I am not sure at this point its better than having an if() clause.
P.S. for OUTDIR, I will most certainly add a macro that will deal with that so it reduces a bit the code in backend functions, as OUTDIR will always be set the same way
Generator expressions can be used to simplify some of the backend functions.
For example if a function has following optional arguments:
Instead of doing
We can do this:
These expressions can be more complex generator expressions