I have made a call to qt4_wrap_cpp(moc_outfiles ${moc_header}) and I want the results of that call (moc_outfiles) to be placed in a folder called GeneratedFiles/Debug.
So far what I tried to make my own custom method that failed due to parsing error Parse error. Expected "(", got quoted argument with text "${it}".
FOREACH (it ${moc_headers})
QT_MOC_EXECUTABLE ${it} -o ./GeneratedFiles/Debug/moc_"${it}"
ENDFOREACH(it)
It looks like you need the execute_process command. Also, you probably don't want the quotes round ${it} in your output filename:
FOREACH(it ${moc_headers})
EXECUTE_PROCESS(COMMAND ${QT_MOC_EXECUTABLE} ${it} -o ./GeneratedFiles/Debug/moc_${it})
ENDFOREACH(it)
You may need to add the WORKING_DIRECTORY argument too - I'm unfamiliar with Qt's moc exe.
Instead of using qt4_wrap_cpp you could use the qt4_generate_moc macro, which takes a single file to be moced and an output path. With this macro you can construct something similar to what qt4_wrap_cpp does.
#qt4_wrap_cpp( moc_outfiles ${moc_headers} )
foreach(moc_hdr ${moc_headers})
GET_FILENAME_COMPONENT(moc_name ${moc_hdr} NAME_WE)
SET (moc_out ${PROJECT_SOURCE_DIR}/GeneratedFiles/moc_${moc_name}.cxx)
QT4_GENERATE_MOC( ${moc_in} ${moc_out} )
LIST (APPEND MOC_SOURCES ${moc_out})
endforeach(moc_hdr)
Related
I have an iPython notebook and I can specify cython macros fine with something like
# distutils: define_macros=NAME=VALUE
but now I want to pass VALUE as a string "VALUE"
# distutils: define_macros=NAME="VALUE"
It IS passing a string, but it's passing "__Pyx_L1_".
I tried '"VALUE"' and \"VALUE\" but they give compile errors because ' is for a character and \ becomes a "stray".
It looks like a bug to me, so probably for the time being one should use the following work around, using extra_compile_args-option of cython-magic:
%%cython -c=-DNAME="VALUE"
# here code
adding -DNAME="VALUE" to command line of the compiler and thus defining NAME.
I need to achieve the below using Robotframework script:
c:\>runbatch "C:\Program Files (x86)\tool\bin\test.exe" C:\tool\get.ini
where runbatch is a MS DOS Batch and "C:\Program Files (x86)\tool\bin\test.exe" and C:\tool\get.ini are parameters to the batch file. The first argument contains path of a tool that has "(" and ")" in its path.
So in my Robot script I have a variable like below:
${tool_path} "C:\\Program Files (x86)\\tool\\bin\\test.exe"
${tool_ini} "C:\tool"
And invoke like below:
${RC}= Run Process ${CURDIR}/../scripts/runbatch.bat ${tool_path} ${tool_ini}\\get.ini
The execution fails but note when I run it via the same param thru the command line as standalone batch it works fine.
In the batch I added comments to just log the arguments and I found that they are completely distorted, the tool_path value is completely distorted ("\"C:\Program) and second argument becomes (Files ) - how can I fix the issue in robot script such that when a path is passed having braces are not modified?
You need to also escape the backslashes in ${tool_ini} - make its value c:\\tool; that's not the culprit thought, just something else to change.
Remove the double quotes in the arguments' values - Run Process does not need them in the way you are calling it, with a keyword argument per script argument. E.g.:
${tool_path} C:\\Program Files (x86)\\tool\\bin\\test.exe
${tool_ini} C:\\tool
${RC}= Run Process ${CURDIR}/../scripts/runbatch.bat ${tool_path} ${tool_ini}\\get.ini
The way you've put them, they have become a part of the value itself.
Alternatively, keeping the double quotes there, you can call the script with all arguments in the call line:
${tool_path} "C:\\Program Files (x86)\\tool\\bin\\test.exe"
${tool_ini} C:\\tool
${RC}= Run Process ${CURDIR}/../scripts/runbatch.bat ${tool_path} "${tool_ini}\\get.ini"
(the second one doesn't really need quotes, but I've added them for consistency)
By the way, not really an issue, yet - the script path uses slashes (/), which is a bit unorthodox for Windows. Contrary to the popular believe, the OS does support this path delimiter pretty much the same way as it supports backslashes (\), it's just not widely used and looks a bit out of place.
I want to use something like pdfs=$(echo *.pdf) and drop the error message that comes in case of no files present. But the docs have only examples where both outputs are redirected combined.
Standard error is file descriptor 2, if you are actually running a command you expect to produce output to standard error.
pdfs=$(echo *.pdf 2> /dev/null)
However, don't write code like in your example. A flat string cannot usefully store an arbitrary list of file names, because you can't distinguish between filename delimiters and valid characters in a filename. Instead, use an array which doesn't require any separate commands (and thus any need to redirect standard error):
pdfs=( *.pdf(N) ) # You can drop the (N) if you already have NULL_GLOB enabled
I'm having this CMakeLists.txt in directory with translation files (*.ts):
SET(TRANSLATIONS
lang_de.ts
lang_en.ts
)
FIND_PACKAGE(Qt5LinguistTools)
QT5_ADD_TRANSLATION(QM_FILES ${TRANSLATIONS})
SET(QM_FILES ${QM_FILES} PARENT_SCOPE)
ADD_CUSTOM_TARGET (translations ALL DEPENDS ${QM_FILES})
It builds *.qm files from specified *.ts.
But I want to improve this and get two custom targets, which won't built automatically.
One for appending new strings from sources into ts files, and one for refreshing ts. The last one would update ts from sources and remove obsolete strings from ts.
I've tried to add this after lines above:
ADD_CUSTOM_TARGET (
ts_append
COMMAND QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_SOURCE_DIR}/src/app ${TRANSLATIONS} OPTIONS -I ${CMAKE_SOURCE_DIR}/src)
)
ADD_CUSTOM_TARGET (
ts_refresh
COMMAND QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_SOURCE_DIR}/src/app ${TRANSLATIONS} OPTIONS -no-obsolete -I ${CMAKE_SOURCE_DIR}/src)
)
but it seems I can't use QT5_CREATE_TRANSLATION macro inside custom target, isn't it?
Maybe I'm on wrong way, how would you solve this problem: easy updating of ts and don't lose them after make clean?
To solve the make clean problem, add a sub directory (ADD_SUBDIRECTORY(translations)) and add SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM 1) to the contained CMakeLists.txt.
See here for an example of that.
For the second part of your question there are two possible ways to do it. Either use FILE(WRITE <filename> "QT5_CREATE_TRANSLATION(QM_FILES ${SOURCE_DIR}/src/app ${TRANSLATIONS} OPTIONS -I ${SOURCE_DIR}/src)") and then use COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DTRANSLATIONS=${TRANSLATIONS} <filename> in add_custom_target. I doubt there's a good way of retrieving the contents of QM_FILES though.
The second option is creating two additional sub directories, each with a QT5_CREATE_TRANSLATIONS and a ADD_CUSTOM_TARGET call.
I have some problems to call a command line program called molconvert from R using system() in Windows. molconvert is located in "C:\Program Files\ChemAxon\MarvinBeans\bin"
I would then like to invoke system() or shell() to mimick what I would achieve by typing
molconvert pdb "C:\molecule conversions\cembrene A.mol"
at the command prompt and collect the resulting output back to R as in
out=system(...,intern=T)
I seem to have trouble though with the backslashes and the spaces in the paths.
I tried with
dirmolconvert="C:\\Program Files\\ChemAxon\\MarvinBeans\\bin"
shell(shQuote(paste(dirmolconvert,"\\molconvert pdb "C:\\cembrene A.mol",sep="")))
but that gives me "Error: unexpected symbol in ..." and escaping the " also doesn't help. Any thoughts on how I should resolve this?
or
system(paste(dirmolconvert,"\\molconvert pdb \"C:\\cembrene A.mol\"",sep=""), intern=T)
but that gives me
'C:\Program' not found
Any thoughts?
Edit:
Based on the answer below the right way to do this apparently is
inputdir="C:/Users/Ento/Documents/GCMS/molconvert test"
molconvertdir="C:/Program Files/ChemAxon/MarvinBeans/bin"
molecule="cembrene A.mol"
out=system(paste(shQuote(file.path(molconvertdir, "molconvert.bat")),
"pdb",
shQuote(file.path(inputdir,molecule))),intern=T)
You want to use shQuote to quote the path to the executable, not the entire command line. Depending on what your molconvert program expects, you may also want to quote paths that are arguments to it.
system(paste(shQuote(file.path(dirmolconvert, "molconvert.exe")),
"pdb",
shQuote("C:\\molecule conversions\\cembrene A.mol"))
the easiest way to fix this is to use short paths:
for %%a in ("C:\molecule conversions\cembrene A.mol") set "sh_path=%%~dpfnxsa"
or
for %%a in ("C:\Program Files\ChemAxon\MarvinBeans\bin") do set "pf_sh_path=%%~dpfnxsa"
and then to pass %sh_path% and %pf_sh_path% as parameter.