I have a small project that uses boost::program_options
. I want to add this (only this) library to my project as a git submodule
and build my executable using its sources.
I have already done the git submodule
part (git submodule add https://github.com/boostorg/program_options.git
), and I have done a small experiment in which I build an example application using only the sources in the mentioned submodule (to double check that there are not extra dependencies).
Now I want to add these sources to my project. What I do in my CMakeLists.txt
file is:
set(BOOST_PROGRAM_OPTIONS_SOURCES
boost/program_options/src/split.cpp
boost/program_options/src/positional_options.cpp
boost/program_options/src/parsers.cpp
boost/program_options/src/options_description.cpp
boost/program_options/src/convert.cpp
boost/program_options/src/config_file.cpp
boost/program_options/src/cmdline.cpp
boost/program_options/src/winmain.cpp
boost/program_options/src/variables_map.cpp
boost/program_options/src/value_semantic.cpp
boost/program_options/src/utf8_codecvt_facet.cpp
)
and
add_executable(
...
src/main.cpp
${BOOST_PROGRAM_OPTIONS_SOURCES}
)
but I obtain the following error:
CMake Error at CMakeLists.txt:69 (add_executable):
The target name "boost/program_options/src/split.cpp" is reserved or not
valid for certain CMake features, such as generator expressions, and may
result in undefined behavior.
CMake Error at CMakeLists.txt:86 (target_link_libraries):
Cannot specify link libraries for target "..." which is not built
by this project.
What is the right way to do what I want>