<div dir="ltr">It turns out that CGAL's CGAL_CreateSingleSourceCGALProgram.cmake module handles this nicely:<div><br></div><div>create_single_source_cgal_program( "src/cdt-docopt.cpp" "src/docopt/docopt.cpp")</div><div><br></div><div>does the trick.</div><div><br></div><div>Thanks for your consideration!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 10:54 PM, Adam Getchell <span dir="ltr"><<a href="mailto:adam.getchell@gmail.com" target="_blank">adam.getchell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I should note that I'm doing an out of source build, and that for my project the following line works:<div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,187,199)"><span style="color:rgb(0,0,0)">┌─[</span><span style="color:rgb(52,189,38)"><b>adam</b></span><span style="color:rgb(0,0,0)">][</span><span style="color:rgb(52,189,38)">Hapkido</span><span style="color:rgb(0,0,0)">][</span><span style="color:rgb(52,189,38)"><b>±</b></span><span style="color:rgb(0,0,0)">][docopt </span><span style="color:rgb(52,189,38)"><b>✓</b></span><span style="color:rgb(0,0,0)">][</span>~/CDT-plusplus/build<span style="color:rgb(0,0,0)">]</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">└─▪ clang++ --std=c++11 --stdlib=libc++ -I ../src/docopt ../src/docopt/docopt.cpp ../src/cdt-docopt.cpp -o cdt_docopt</p></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 9:30 PM, Adam Getchell <span dir="ltr"><<a href="mailto:adam.getchell@gmail.com" target="_blank">adam.getchell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hello all,</div><div><br></div><div>I’m trying to use the docopt.cpp parser for my project[1]:</div><div><br></div><div><a href="https://github.com/docopt/docopt.cpp" target="_blank">https://github.com/docopt/docopt.cpp</a></div><div><br></div><div>The usual invocation to build works:</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,187,199)"><span style="color:#000000">┌─[</span><span style="color:#34bd26"><b>adam</b></span><span style="color:#000000">][</span><span style="color:#34bd26">Hapkido</span><span style="color:#000000">][</span><span style="color:#34bd26"><b>±</b></span><span style="color:#000000">][docopt </span><span style="color:#c33720"><b>✗</b></span><span style="color:#000000">][</span>~/CDT-plusplus/src/docopt<span style="color:#000000">]</span></div><div style="margin:0px;font-size:11px;font-family:Menlo">└─▪ clang++ --std=c++11 --stdlib=libc++ -I . docopt.cpp examples/naval_fate.cpp -o naval_fate</div></div><div><br></div><div>So, I want to add docopt.cpp and have the compiler look for header files in the same directory, and add that to my executable.</div><div><br></div><div>So far, what I’ve attempted is to add the lines:</div><div><br></div><div><div>include_directories (BEFORE "src/docopt")</div><div>add_library(docopt.cpp "src/docopt/docopt.cpp”)</div></div><div><br></div><div>My program uses CGAL[2], and all of those library headers are incorporated using the create_single_source_cgal_program function in the CGAL_CreateSingleSourceCGALProgram.cmake module.</div><div><br></div><div>The error messages I’m getting correspond to the ones I get when docopt.cpp is not included:</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(52,187,199)"><span style="color:#000000">┌─[</span><span style="color:#34bd26"><b>adam</b></span><span style="color:#000000">][</span><span style="color:#34bd26">Hapkido</span><span style="color:#000000">][</span><span style="color:#34bd26"><b>±</b></span><span style="color:#000000">][docopt </span><span style="color:#c33720"><b>✗</b></span><span style="color:#000000">][</span>~/CDT-plusplus/src/docopt<span style="color:#000000">]</span></div><div style="margin:0px;font-size:11px;font-family:Menlo">└─▪ clang++ --std=c++11 --stdlib=libc++ -I . examples/naval_fate.cpp -o naval_fate</div><div style="margin:0px;font-size:11px;font-family:Menlo">Undefined symbols for architecture x86_64:</div><div style="margin:0px;font-size:11px;font-family:Menlo">  "docopt::docopt(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:</div><div style="margin:0px;font-size:11px;font-family:Menlo">      _main in naval_fate-780283.o</div><div style="margin:0px;font-size:11px;font-family:Menlo">  "docopt::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, docopt::value const&)", referenced from:</div><div style="margin:0px;font-size:11px;font-family:Menlo">      _main in naval_fate-780283.o</div><div style="margin:0px;font-size:11px;font-family:Menlo">ld: symbol(s) not found for architecture x86_64</div><div style="margin:0px;font-size:11px;font-family:Menlo">clang: error: linker command failed with exit code 1 (use -v to see invocation)</div></div><br><div>Compare to:</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">┌─[<span style="color:#34bd26"><b>adam</b></span>][<span style="color:#34bd26">Hapkido</span>][<span style="color:#34bd26"><b>±</b></span>][docopt <span style="color:#c33720"><b>✗</b></span>][<span style="color:#34bbc7">~/CDT-plusplus</span>]</div><div style="margin:0px;font-size:11px;font-family:Menlo">└─▪ ./build.sh </div><div style="margin:0px;font-size:11px;font-family:Menlo">-- The C compiler identification is AppleClang 6.0.0.6000054</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- The CXX compiler identification is AppleClang 6.0.0.6000054</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Check for working C compiler using: Ninja</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Check for working C compiler using: Ninja -- works</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Detecting C compiler ABI info</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Detecting C compiler ABI info - done</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Check for working CXX compiler using: Ninja</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Check for working CXX compiler using: Ninja -- works</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Detecting CXX compiler ABI info</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Detecting CXX compiler ABI info - done</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Build type: Release</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- USING CXXFLAGS = ' -O3 -DNDEBUG'</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- USING EXEFLAGS = '  -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib '</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Targetting Ninja</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Using /usr/bin/c++ compiler.</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- DARWIN_VERSION=14</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Mac Leopard detected</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Requested component: Core</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Requested component: MPFR</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Requested component: GMP</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Found Eigen3: /usr/local/include/eigen3 (found suitable version "3.2.2", minimum required is "3.1.0") </div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Configuring done</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Generating done</div><div style="margin:0px;font-size:11px;font-family:Menlo">-- Build files have been written to: /Users/adam/CDT-plusplus/build</div><div style="margin:0px;font-size:11px;font-family:Menlo">[10/13] Linking CXX executable cdt-docopt</div><div style="margin:0px;font-size:11px;font-family:Menlo">FAILED: : && /usr/bin/c++   -O3 -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib CMakeFiles/cdt-docopt.dir/src/cdt-docopt.cpp.o  -o cdt-docopt -L/Users/adam/gmock-1.7.0/lib/.libs  -L/Users/adam/gmock-1.7.0/gtest/lib/.libs /usr/local/lib/libmpfr.dylib /usr/local/lib/libgmp.dylib /usr/local/lib/libCGAL_Core.dylib /usr/local/lib/libCGAL.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/libboost_system-mt.dylib /usr/local/lib/libCGAL_Core.dylib /usr/local/lib/libCGAL.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/libboost_system-mt.dylib -Wl,-rpath,/Users/adam/gmock-1.7.0/lib/.libs -Wl,-rpath,/Users/adam/gmock-1.7.0/gtest/lib/.libs && :</div><div style="margin:0px;font-size:11px;font-family:Menlo">Undefined symbols for architecture x86_64:</div><div style="margin:0px;font-size:11px;font-family:Menlo">  "docopt::docopt(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:</div><div style="margin:0px;font-size:11px;font-family:Menlo">      _main in cdt-docopt.cpp.o</div><div style="margin:0px;font-size:11px;font-family:Menlo">  "docopt::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, docopt::value const&)", referenced from:</div><div style="margin:0px;font-size:11px;font-family:Menlo">      _main in cdt-docopt.cpp.o</div><div style="margin:0px;font-size:11px;font-family:Menlo">ld: symbol(s) not found for architecture x86_64</div><div style="margin:0px;font-size:11px;font-family:Menlo">clang: error: linker command failed with exit code 1 (use -v to see invocation)</div><div style="margin:0px;font-size:11px;font-family:Menlo">[10/13] Building CXX object CMakeFiles/unittests.dir/unittests/Triangulated2SphereTest.cpp.o</div><div style="margin:0px;font-size:11px;font-family:Menlo">ninja: build stopped: subcommand failed.</div></div><div><br></div><div>Any suggestions?</div><div><br></div><div>[1] <a href="https://github.com/acgetchell/CDT-plusplus/tree/docopt" target="_blank">https://github.com/acgetchell/CDT-plusplus/tree/docopt</a></div><div>[2] <a href="https://www.cgal.org" target="_blank">https://www.cgal.org</a></div><span><font color="#888888"><div><br></div><div>
<div>Adam Getchell<br><a href="http://about.me/adamgetchell" target="_blank">about.me/adamgetchell</a></div>

</div>
<br></font></span></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr"><div>Adam Getchell</div><div><a href="http://about.me/adamgetchell" target="_blank">about.me/adamgetchell</a></div>"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu</div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Adam Getchell</div><div><a href="http://about.me/adamgetchell" target="_blank">about.me/adamgetchell</a></div>"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu</div></div>
</div>