tinyxml2: CMake error: Could not find a package configuration file provided by "TinyXML2" with any of the following names: TinyXML2Config.cmake tinyxml2-config.cmake
I am trying to build a CMake package which requires tinyxml2, but am unable to get it to work. Error:
CMake Error at CMakeLists.txt:9 (find_package):
By not providing "FindTinyXML2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "TinyXML2",
but CMake did not find one.
Could not find a package configuration file provided by "TinyXML2" with any
of the following names:
TinyXML2Config.cmake
tinyxml2-config.cmake
Add the installation prefix of "TinyXML2" to CMAKE_PREFIX_PATH or set
"TinyXML2_DIR" to a directory containing one of the above files. If
"TinyXML2" provides a separate development package or SDK, be sure it has
been installed.
The package I am building is host-rospack
, built via Buildroot.
I have tried installing TinyXML2 in 3 ways, none of which work to make Cmake find it!:
- Via apt on ubuntu 22.04:
sudo apt update sudo apt install libtinyxml2-dev sudo apt install libtinyxml-dev
- Via make
git clone https://github.com/leethomason/tinyxml2.git cd tinyxml2/ make sudo make install
- Via vcpkg, as described here:
git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install tinyxml2
How do I install tinyxml2 in such a way that my CMake package which requires it (rospack in my case) can find it?
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 17 (4 by maintainers)
I had taken advice from gpt4.0.
As the developer of the CMake integration for this library, I can say absolutely that GPT’s suggestion is wrong. No library should be linked to that way, at least not since CMake 2.8.10, almost a decade ago. Libraries that make you do that are ill-behaved. Don’t listen to LLMs. LLMs are misleading and provide an absolutely false sense of confidence about bad code.
If you post clear steps to reproduce the issue, I will be happy to help you debug.
@alexreinking
Thanks for the suggestion! I think my bit of example code works now (for my future reference if nothing else). I didn’t know about FetchContent before, this is way better than using submodules imo.
For those that want a bit of starter code to integrate tinyxml2 into an existing project: https://github.com/stefanaerospace/tinyxml2-quickstart