<div dir="ltr">Hi Lars,<div><br></div><div>I see...Why don't you set the working directory then to lib1 and lib2, and use the full path to App to call App? Not sure it will work, but maybe.</div><div><br></div><div>Cheers!</div><div>Angeliki</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 19, 2014 at 7:19 PM, Lars <span dir="ltr"><<a href="mailto:laasunde@hotmail.com" target="_blank">laasunde@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">Hi Angeliki,<div><br></div><div>Thank you for the suggestions.<br><div><br></div><div>I suspect your first example wont work because lib1 and lib2 are not in executable_output_path<span style="font-family:arial,sans-serif">. So when the add_custom_command executes "App" it wont be able to resolve the dependencies to lib1 and lib2. If I only had one dependency I could possibly set the working_directory to the path of lib1 and use the absolute path of the "App" for the command. That would probably work but not with multiple dependencies.</span></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Your second example might do the job but wont be accepted as a solution in our company.</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">regards, Lars<br></font><div class="hm HOEnZb"><br></div><div><div class="hm HOEnZb"><hr>Date: Wed, 19 Nov 2014 14:10:07 +0100<br>Subject: Re: [CMake] ADD_CUSTOM_COMMAND Application dependency<br>From: <a href="mailto:angeliki.chrysochou@gmail.com" target="_blank">angeliki.chrysochou@gmail.com</a><br>To: <a href="mailto:laasunde@hotmail.com" target="_blank">laasunde@hotmail.com</a><br>CC: <a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a></div><div><div class="h5"><br><br><div dir="ltr">Hi Lars,<div><br></div><div>What if you provide the working directory to <span style="font-family:arial,sans-serif;font-size:13px">ADD_CUSTOM_COMMAND like this:</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><div><font face="arial, sans-serif">    add_custom_command(</font></div><div><font face="arial, sans-serif">    OUTPUT <output></font></div><div><font face="arial, sans-serif">    COMMAND command_to_be_executed <arg_1> <arg_2></font></div><div><font face="arial, sans-serif">    DEPENDS ${lib1} ${lib2}</font></div><div><font face="arial, sans-serif">    WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}</font></div><div><font face="arial, sans-serif">    VERBATIM)</font></div></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Would it work?</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Otherwise a trick (more like a hack) like the following might be useful:</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div>    add_custom_command(</div><div>    OUTPUT <output></div><div>    COMMAND PATH=$ENV{PATH}:<more_paths> ENVIRONMENT_VAR=<some_other_value> && command_to_be_executed <arg_1> <arg_2></div><div>    DEPENDS <dependency_1> <dependency_2></div><div>    WORKING_DIRECTORY <working_dir></div><div>    VERBATIM)</div><div><br></div><div>This sets the PATH temporarily during the execution of the command, where you could possibly add the paths to the libraries you need. You can set more environment variables as well.</div><div><br></div><div>Cheers!</div><div>Angeliki</div></font></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div><br><div>On Wed, Nov 19, 2014 at 11:14 AM, Lars <span dir="ltr"><<a href="mailto:laasunde@hotmail.com" target="_blank">laasunde@hotmail.com</a>></span> wrote:<br><blockquote style="border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">


<div dir="ltr"> The below example build "App" and copies it to EXECUTABLE_OUTPUT_PATH.<br>ADD_EXECUTABLE(App ${source})<br>TARGET_LINK_LIBRARIES(App ${lib1} ${lib2})<br>INSTALL(TARGETS App ..)</div><div dir="ltr"><br>The top level CMakeLists.txt has install directives for lib1 and lib2<br>INSTALL(FILES ${lib1}/bin/lib1.dll DESTINATION ...)<br>INSTALL(FILES ${lib2}/bin/lib2.dll DESTINATION ...)<br></div><div dir="ltr">Later in the build process we would like to use "App"<br>ADD_CUSTOM_COMMAND(OUTPUT "${src} COMMAND App ...)</div><div dir="ltr"><br>The ADD_CUSTOM_COMMAND command currently fails because lib1 and lib2 are not present in EXECUTABLE_OUTPUT_PATH.</div><div dir="ltr"><br>The following solutions work but are not desirable approaches:<br> - Copying the necessary files to EXECUTABLE_OUTPUT_PATH via ADD_CUSTOM_COMMAND. This would be repeating top level install directives at target level.<br> - Update "path" environment variable to include paths to lib1 and lib2 libraries.<br></div><div dir="ltr">What other options are available using CMake? Does ADD_CUSTOM_COMMAND have a way to update path environment prior to executing a command?<br> <br></div>
                                          </div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" 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" 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" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" 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" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div></div></div></div></div></div>                                        </div></div>
</blockquote></div><br></div>