Hi Chris, <br><br>Try to change the order of the ADD_DUBDIRECTORY.<br><br><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">add_subdirectory(</span><span style="font-family: &quot;Courier New&quot;;">FeatureViewer</span><span style="font-family: &quot;Courier New&quot;;">)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">add_subdirectory(</span><span style="font-family: &quot;Courier New&quot;;"></span><span style="font-family: &quot;Courier New&quot;;">TestDriver</span><span style="font-family: &quot;Courier New&quot;;">)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;"><br></span></p><div class="gmail_quote">instead of <br><br><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">add_subdirectory(TestDriver)</span></p>

<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">add_subdirectory(FeatureViewer)</span></p>
<br>As mentioned in the <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:add_subdirectory">doc</a>: &quot;<i>The CMakeLists.txt file in the specified source directory will be 
processed immediately by CMake before processing in the current input 
file continues beyond this command.</i>&quot;<br><br>Changing the order of subdirectory will ensure that FeatureViewer dll is built before TestDriver ...<br><br>Jc<br><br>On Tue, Mar 22, 2011 at 10:16 AM, Chris Volpe ARA/SED <span dir="ltr">&lt;<a href="mailto:cvolpe@ara.com">cvolpe@ara.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal">I posted this question in the VTK Users mailing list originally, but have since determined that it is more of a CMake issue than a VTK issue, and the involvement of VTK is only tangential. </p>
<p class="MsoNormal"> </p><p class="MsoNormal">I am trying to set up a source tree which will allow CMake to create a MSVC++ .sln file that contains the following two projects:</p><p><span>1.<span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span>A DLL (called “FeatureViewer”) containing a vanilla C++ class that links against several VTK kits (Graphics, Rendering, and Hybrid).</p>
<p><span>2.<span style="font: 7pt &quot;Times New Roman&quot;;">       </span></span>An EXE (called “TestDriver”) that links against the aforementioned library containing the vanilla C++ class.</p><p class="MsoNormal"> </p>
<p class="MsoNormal">I want to deliver the DLL, LIB, and class header file from (1) above (as well as the dependent VTK DLLs) to a co-worker who has his own application and wants to use the functionality I’m encapsulating, but he doesn’t want to “vtk-ify” his build process. The EXE in (2) above is simply my test driver for (1).</p>
<p class="MsoNormal"> </p><p class="MsoNormal">My problem is that the EXE won’t build because the generated project is spuriously looking for vtk libraries (e.g. vtkGraphics.lib et. al.) at link time that it doesn’t directly reference, and it doesn’t know where to find them. The EXE shouldn’t need to know about them because their use is strictly within the FeatureViewer library. If I go into the EXE project properties and manually delete the references to vtkGraphics.lib et. al. from the linker-&gt;input-&gt;additional-dependencies list, it works. </p>
<p class="MsoNormal"> </p><p class="MsoNormal">At first, I thought I was just doing something wrong in my CMakeLists.txt files, but page 25 of the CMake User’s Guide suggests that this behavior is by design. </p><p class="MsoNormal">
The example given is:</p><p class="MsoNormal"> </p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Lucida Console&quot;;">add_library(foo foo.cxx)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Lucida Console&quot;;">target_link_libraries(foo bar)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Lucida Console&quot;;"> </span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Lucida Console&quot;;">add_executable(foobar foobar.cxx)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Lucida Console&quot;;">target_link_libraries(foobar foo)</span></p>
<p class="MsoNormal"> </p><p class="MsoNormal">The text below the example states, <b>“This will link the libraries foo and bar into the executable foobar even [sic], although only foo was explicitly linked into foobar. With shared or DLL builds this linking is not always needed, but the extra linkage is harmless.”</b></p>
<p class="MsoNormal"> </p><p class="MsoNormal">It seems to me that this extra linkage is not harmless: I don’t want clients of FeatureViewer to have to know about vtkGraphics.lib et. al., but CMake is creating a spurious reference.</p>
<p class="MsoNormal"> </p><p class="MsoNormal">Can someone provide a work-around?</p><p class="MsoNormal"><span style="color: rgb(31, 73, 125);"> </span></p><p class="MsoNormal">My CMakeLists.txt files look like this:</p>
<p class="MsoNormal"> </p><p class="MsoNormal">Top Level:</p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">CMAKE_MINIMUM_REQUIRED(VERSION 2.4)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;">IF(COMMAND CMAKE_POLICY)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">  CMAKE_POLICY(SET CMP0003 NEW)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">ENDIF(COMMAND CMAKE_POLICY)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">PROJECT(FeatureViewer)</span></p><p class="MsoNormal"><span style="font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;">add_subdirectory(TestDriver)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">add_subdirectory(FeatureViewer)</span></p>
<p class="MsoNormal"> </p><p class="MsoNormal">FeatureViewer:</p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">SET (FeatureViewer_SRCS</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;">  FeatureViewer.cxx</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">IF(NOT VTK_BINARY_DIR)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;">FIND_PACKAGE(VTK REQUIRED)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">IF(NOT VTK_USE_RENDERING)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">  MESSAGE(FATAL_ERROR &quot;Example ${PROJECT_NAME} requires VTK_USE_RENDERING.&quot;)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;">ENDIF(NOT VTK_USE_RENDERING)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">INCLUDE(${VTK_USE_FILE})</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">ENDIF(NOT VTK_BINARY_DIR)</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;"> </span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">ADD_LIBRARY(FeatureViewer SHARED ${FeatureViewer_SRCS})</span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">TARGET_LINK_LIBRARIES(FeatureViewer vtkGraphics vtkRendering vtkHybrid)</span></p>
<p class="MsoNormal"> </p><p class="MsoNormal">TestDriver:</p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">ADD_EXECUTABLE(TestDriver TestDriver.cxx)</span></p><p class="MsoNormal" style="margin-left: 0.5in;">
<span style="font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">TARGET_LINK_LIBRARIES(TestDriver FeatureViewer)</span></p>
<p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;"> </span></p><p class="MsoNormal" style="margin-left: 0.5in;"><span style="font-family: &quot;Courier New&quot;;">INCLUDE_DIRECTORIES(${FeatureViewer_SOURCE_DIR}/FeatureViewer)</span></p>
<p class="MsoNormal"> </p><p class="MsoNormal">Thanks in advance!!</p><p class="MsoNormal"><span style="font-size: 24pt; font-family: &quot;Monotype Corsiva&quot;;">Chris</span><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">--<br>Christopher R. Volpe, Ph.D.                                                           </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;" lang="FR">Email: <a href="mailto:cvolpe@ara.com" target="_blank">cvolpe@ara.com</a> </span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;" lang="FR">Senior Scientist, Information Exploitation Systems             Main Desk: 919-582-3300</span></p><p class="MsoNormal">
<span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><a href="http://www.ara.com/" target="_blank">Applied Research Associates, Inc</a>                                                     Direct: 919-582-3380</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;" lang="FR">8537 Six Forks Rd., Suite 6000                                                            Fax : 919-582-3301</span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;" lang="FR">Raleigh, NC 27615                                         Web: </span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;"><a href="http://www.ara.com/offices/NC.htm" title="http://www.ara.com/offices/NC.htm" target="_blank">http://www.ara.com/offices/NC.htm</a></span><span style="font-size: 10pt; font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;" lang="FR"></span></p>
<p class="MsoNormal"> <span style="font-size: 12pt;"></span></p><p class="MsoNormal"> </p></div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><br>-- <br>+1 919 869 8849<br><br>