<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 5 juin 2019 à 12:00, Mathieu Malaterre <<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.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">Hi there,<br>
<br>
I am trying to use NuGet generator for GDCM project. Typically my<br>
install rules are as follow:<br>
<br>
add_library(foo SHARED foo.c)<br>
install(TARGETS foo<br>
  EXPORT ${MY_TARGETS_NAME}<br>
  RUNTIME DESTINATION ${MY_INSTALL_BIN_DIR} COMPONENT Applications<br>
  LIBRARY DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT Libraries<br>
  INCLUDES DESTINATION ${MY_INSTALL_INCLUDE_DIR}<br>
  ARCHIVE DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT DebugDevel<br>
)<br>
<br>
where:<br>
<br>
MY_INSTALL_BIN_DIR='bin'<br>
MY_INSTALL_LIB_DIR='lib'<br>
MY_INSTALL_INCLUDE_DIR='include'<br>
<br>
this works quite nicely for basic 'make install', as well as binary<br>
zip or NSIS installer.<br>
However this directory layout does not seems to be compatible with<br>
Windows RIDs[*]. For example my native *.dll files would need to be<br>
moved from the 'bin' directory to something like 'lib/win7-x64'.<br>
<br>
How can I handle conditional install() rules based on CPack generator<br>
(NuGet in my case) ?<br></blockquote><div><br></div><div>I'm not sure you can.</div><div>install() rules are processed when CMake runs and generate all cmake_install.cmake files.</div><div>then when CPack runs it triggers the install using the files generated at CMake time.</div><div><br></div><div>So while you can achieve some conditional actions when CPack runs using CPack project config file</div><div><a href="https://cmake.org/cmake/help/v3.14/module/CPack.html#variable:CPACK_PROJECT_CONFIG_FILE">https://cmake.org/cmake/help/v3.14/module/CPack.html#variable:CPACK_PROJECT_CONFIG_FILE</a><br></div><div> </div><div>AFAIK you cannot (re)write install rule because they have already been processed.</div><div><br></div><div>What you could do (as a workaround) in your CMakeLists.txt is to define both WinXX specific CPack components</div><div>and your "generic" CPack components that can be used as a default.</div><div>install(TARGETS foo<br>  EXPORT ${MY_TARGETS_NAME}<br>  RUNTIME DESTINATION ${MY_INSTALL_BIN_DIR} COMPONENT Applications<br>  LIBRARY DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT Libraries<br>  INCLUDES DESTINATION ${MY_INSTALL_INCLUDE_DIR}<br>  ARCHIVE DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT DebugDevel<br>)<br></div><div>install(TARGETS foo<br>  EXPORT ${MY_TARGETS_NAME}<br>  RUNTIME DESTINATION ${MY_WINXX_INSTALL_BIN_DIR} COMPONENT Applications-Winxx<br>  LIBRARY DESTINATION ${MY_WINXX_INSTALL_LIB_DIR} COMPONENT Libraries-Winxx</div><div>  INCLUDES DESTINATION ${MY_WINXX_INSTALL_INCLUDE_DIR}</div><div>  ARCHIVE DESTINATION ${MY_WINXX_INSTALL_LIB_DIR} COMPONENT DebugDevel-Winxx</div><div>)<br></div><div><br></div><div>i.e. install the same thing twice in two places.</div><div>and then at CPack time (when CPack runs) code some logic in your CPack Config file in order</div><div>to set  CPACK_COMPONENTS_ALL to appropriate value depending on the value of <a href="https://cmake.org/cmake/help/v3.14/module/CPack.html#variable:CPACK_GENERATOR">https://cmake.org/cmake/help/v3.14/module/CPack.html#variable:CPACK_GENERATOR</a></div><div><br></div><div>something like</div><div>if ("${CPACK_GENERATOR}" STREQUAL "NuGet")<br></div><div>   set(CPACK_COMPONENTS_ALL "Applications-Winxx;Libraries-Winxx;DebugDevel-Winxx")</div><div>else()</div><div>    set(CPACK_COMPONENTS_ALL "Applications;Libraries;DebugDevel")</div><div>endif()</div><div><br></div><div>that way CPack depending on the generator will ship either "WinXX" component or "generic" ones.</div><div><br></div><div>I think (not tested) it should work but this is clearly a workaround.</div><div><br></div><div><br></div><div>Eric</div><div><br></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">
<br>
Thanks,<br>
<br>
[*] <a href="https://docs.microsoft.com/en-us/dotnet/core/rid-catalog" rel="noreferrer" target="_blank">https://docs.microsoft.com/en-us/dotnet/core/rid-catalog</a><br>
<br>
-- <br>
Mathieu<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br clear="all"><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>