I am new to CMake and having trouble understanding how to use it.
I have a cross-platform c++ project. It builds using CMake and my CMakeLists.txt lives in a folder called MyProject along with the project. I checked out a pugixml git submodule and it now lives under MyProject/pugixml, with its sources being under MyProject/pugixml/src. It however has its own CMake file: MyProject/pugixml/CMakeLists.txt.
How do I modify my CMakeLists.txt to also build and use pugixml? I tried something like
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${GENERATED_HEADER_OUTPUT_DIRECTORY} pugixml/src)
and
add_library(PugiXML deps/pugixml/src/pugiconfig.hpp deps/pugixml/src/pugixml.cpp deps/pugixml/src/pugixml.hpp)
and
add_subdirectory(pugixml) in different combinations (these are examples I found on Github), but it doesn't work - I get unresolved external symbol errors, so I assume the cpp never got compiled.
I get "unresolved external symbol" errors- This means you need to link with a library.add_subdirectory(pugixml)just builds external library, but linking with it should be performed explicitely with target_link_libraries.target_include_directoriesinstead of the oldinclude_directories.