<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 6 mars 2019 à 21:33, Stewart, Robert <<a href="mailto:Robert.Stewart@sig.com">Robert.Stewart@sig.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We've recently upgraded CMake from 2.8+ to 3.5+ (different versions on different platforms). In so doing, our CMake invocation of CPack to create RPMs now fails and I'm hoping someone can help. I have a spec file and I want to run rpmbuild -bb, but I can't figure out how to do it.<br>
<br>
We have been using a custom spec file all along, but I found information indicating that doing so is (now?) considered a hack and that everything should be possible merely by setting CPACK_* variables. Unfortunately, that's not the case. </blockquote><div><br></div><div>Which CPACK_xxx variables did you use?</div><div>CPACK_RPM_SPEC_MORE_DEFINE ?<br></div><div>CPACK_RPM_USER_FILELIST ?<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> With the following %files entries, CPackRPM.cmake chokes:<br>
<br>
%defattr(-, %{user}, %{group}, 0755)<br>
%dir %{destination}<br>
%dir %{versioned}<br>
%dir %{foo}<br>
%{foo}/*.sh<br>
%attr(555, %{user}, %{group}) %{foo}/a<br>
%dir %{bar}<br>
%attr(544, %{user}, %{group}) %{bar}/b<br>
%attr(444, %{user}, %{group}) %{bar}/*common<br>
%{bar}/lib<br>
<br>
The result is that my attempt to port to the all-variable approach failed, so I'm setting CPACK_RPM_USER_BINARY_SPECFILE to refer to my spec file as before. Unfortunately, when I do so, CPackRPM.cmake doesn't set RPMBUILD_FLAGS, and that leads to rpmbuild doing nothing useful. The issue is in the following code:<br>
<br>
# We should generate a USER spec file template:<br>
# - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE<br>
# - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE<br>
if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE)<br>
set(RPMBUILD_FLAGS "-bb")<br>
<br>
I tried just setting RPMBUILD_FLAGS to -bb in my CMakeLists.txt, where I include CPack, but that isn't propagated to CPackRPM.cmake. I tried adding a custom target that invoked "${CMAKE_CPACK_COMMAND} -D RPMBUILD_FLAGS=-bb", but that didn't work either.<br></blockquote><div><br></div><div>You cannot add flags meant to be used at CPack time in your CMakeLists.txt because CMakeLists.txt is read when *cmake* runs not when *cpack* runs.</div><div>See: <a href="https://github.com/dev-cafe/cmake-cookbook/tree/master/figures/cmake-times">https://github.com/dev-cafe/cmake-cookbook/tree/master/figures/cmake-times</a> for the description of various times</div><div><br></div><div>However you can use <a href="https://cmake.org/cmake/help/v3.12/module/CPack.html#variable:CPACK_PROJECT_CONFIG_FILE">https://cmake.org/cmake/help/v3.12/module/CPack.html#variable:CPACK_PROJECT_CONFIG_FILE</a> for that purpose.</div><div>If you specify (in your CMakeLists.txt) the name of a file as set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_BINARY}/mycpack_config.cmake)</div><div>then the 'mycpack_config.cmake' will be processed by CPack when it runs.</div><div>You can find an example usage here: <a href="http://git.savannah.nongnu.org/cgit/certi.git/tree/CMakeLists.txt#n621">http://git.savannah.nongnu.org/cgit/certi.git/tree/CMakeLists.txt#n621</a></div><div>in this case the <a href="http://CERTICPackOptions.cmake.in">CERTICPackOptions.cmake.in</a> (in the source tree) is first configure to CERTICPackOptions.cmake (in the build tree)</div><div>then </div><div>SET(CPACK_PROJECT_CONFIG_FILE "${CERTI_BINARY_DIR}/CERTICPackOptions.cmake")<br></div><div><br></div><div>indicate that CPack should use it at "CPack-time".</div><div><br></div><div>The process describing how "CPACK_PROJECT_CONFIG_FILE" is used is described at the beginning of : <a href="https://cmake.org/cmake/help/v3.12/module/CPack.html">https://cmake.org/cmake/help/v3.12/module/CPack.html</a></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
If the regex processing of the %files content were more robust, I wouldn't trip over the RPMBUILD_FLAGS issue, </blockquote><div><br></div><div>Then may be you can file a patch for making those more robust?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">but either CPACK_RPM_USER_BINARY_SPECFILE is supported or it isn't, and since it is currently, it should be possible for me to set RPMBUILD_FLAGS.<br>
<br>
Ideas?</blockquote><div><br></div><div>1) Use CPACK_RPM_USER_BINARY_SPECFILE and CPACK_PROJECT_CONFIG_FILE.</div></div><div>2) propose a patch for </div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Eric<br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>