It turns out that CGAL's CGAL_CreateSingleSourceCGALProgram.cmake module handles this nicely:
create_single_source_cgal_program( "src/cdt-docopt.cpp" "src/docopt/docopt.cpp") does the trick. Thanks for your consideration! On Thu, Dec 4, 2014 at 10:54 PM, Adam Getchell <adam.getch...@gmail.com> wrote: > I should note that I'm doing an out of source build, and that for my > project the following line works: > > ┌─[*adam*][Hapkido][*±*][docopt *✓*][~/CDT-plusplus/build] > > └─▪ clang++ --std=c++11 --stdlib=libc++ -I ../src/docopt > ../src/docopt/docopt.cpp ../src/cdt-docopt.cpp -o cdt_docopt > > On Thu, Dec 4, 2014 at 9:30 PM, Adam Getchell <adam.getch...@gmail.com> > wrote: > >> Hello all, >> >> I’m trying to use the docopt.cpp parser for my project[1]: >> >> https://github.com/docopt/docopt.cpp >> >> The usual invocation to build works: >> >> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus/src/docopt] >> └─▪ clang++ --std=c++11 --stdlib=libc++ -I . docopt.cpp >> examples/naval_fate.cpp -o naval_fate >> >> 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. >> >> So far, what I’ve attempted is to add the lines: >> >> include_directories (BEFORE "src/docopt") >> add_library(docopt.cpp "src/docopt/docopt.cpp”) >> >> 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. >> >> The error messages I’m getting correspond to the ones I get when >> docopt.cpp is not included: >> >> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus/src/docopt] >> └─▪ clang++ --std=c++11 --stdlib=libc++ -I . examples/naval_fate.cpp -o >> naval_fate >> Undefined symbols for architecture x86_64: >> "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: >> _main in naval_fate-780283.o >> "docopt::operator<<(std::__1::basic_ostream<char, >> std::__1::char_traits<char> >&, docopt::value const&)", referenced from: >> _main in naval_fate-780283.o >> ld: symbol(s) not found for architecture x86_64 >> clang: error: linker command failed with exit code 1 (use -v to see >> invocation) >> >> Compare to: >> >> ┌─[*adam*][Hapkido][*±*][docopt *✗*][~/CDT-plusplus] >> └─▪ ./build.sh >> -- The C compiler identification is AppleClang 6.0.0.6000054 >> -- The CXX compiler identification is AppleClang 6.0.0.6000054 >> -- Check for working C compiler using: Ninja >> -- Check for working C compiler using: Ninja -- works >> -- Detecting C compiler ABI info >> -- Detecting C compiler ABI info - done >> -- Check for working CXX compiler using: Ninja >> -- Check for working CXX compiler using: Ninja -- works >> -- Detecting CXX compiler ABI info >> -- Detecting CXX compiler ABI info - done >> -- Build type: Release >> -- USING CXXFLAGS = ' -O3 -DNDEBUG' >> -- 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 >> ' >> -- Targetting Ninja >> -- Using /usr/bin/c++ compiler. >> -- DARWIN_VERSION=14 >> -- Mac Leopard detected >> -- Requested component: Core >> -- Requested component: MPFR >> -- Requested component: GMP >> -- Found Eigen3: /usr/local/include/eigen3 (found suitable version >> "3.2.2", minimum required is "3.1.0") >> -- Configuring done >> -- Generating done >> -- Build files have been written to: /Users/adam/CDT-plusplus/build >> [10/13] Linking CXX executable cdt-docopt >> 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 && : >> Undefined symbols for architecture x86_64: >> "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: >> _main in cdt-docopt.cpp.o >> "docopt::operator<<(std::__1::basic_ostream<char, >> std::__1::char_traits<char> >&, docopt::value const&)", referenced from: >> _main in cdt-docopt.cpp.o >> ld: symbol(s) not found for architecture x86_64 >> clang: error: linker command failed with exit code 1 (use -v to see >> invocation) >> [10/13] Building CXX object >> CMakeFiles/unittests.dir/unittests/Triangulated2SphereTest.cpp.o >> ninja: build stopped: subcommand failed. >> >> Any suggestions? >> >> [1] https://github.com/acgetchell/CDT-plusplus/tree/docopt >> [2] https://www.cgal.org >> >> Adam Getchell >> about.me/adamgetchell >> >> > > > -- > Adam Getchell > about.me/adamgetchell > "Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu > -- Adam Getchell about.me/adamgetchell "Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake