1

I am trying to compile this project: https://github.com/computationalpathologygroup/ASAP.git from source. Pugixml is a dependency

I have built pugixml from source and set PugiXML_DIR and PUGIXML_INCLUDE_DIR And it still gives me error: "CMake Error: The following variables are used in this project, but they are set to NOTFOUND."

Things I have tried:

  • I am doing this on windows, using cmake 3.14 and visual studio 2017.
  • I have successfully built pugixml from source and included the .lib file as well
  • I have tried including and excluding combinations of PUGIXML_INCLUDE_DIR, PUGIXML_LIBRARY, PugiXML_DIR.

This is the error I get:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
cpp/ASAP/annotation/PUGIXML_INCLUDE_DIR
   used as include directory in directory 
/cpp/ASAP/annotation
cpp/ASAP/multiresolutionimageinterface/PUGIXML_INCLUDE_DIR
   used as include directory in directory cpp/ASAP/multiresolutionimageinterface

Other information: setting PugiXML_DIR is mandatory, and the cmake looks for a file named "pugixml-config.cmake" in that directory. And the config cmake file is supposed to point to compiled lib file. But when it wasn't able to find, I simply copied the lib file I compiled to the location pugixml-config.cmake was pointing.

aditya sista
  • 131
  • 1
  • 12
  • Have you set `PugiXML_DIR` to the folder that you built `pugixml` in? This should be whatever you set the ***Where to build the binaries*** box in `CMake-Gui` when you generated the project for `pugixml` – drescherjm May 02 '19 at 16:22
  • While the first line of the error message is quite usual, there are things which looks very strange: 1. Such kind of the error message is normally when `find_package()` misses the *REQUIRED* keyword. But ASAP project **has** it: [CMakeLists.txt#L56](https://github.com/computationalpathologygroup/ASAP/blob/develop/CMakeLists.txt#L56). 2. In the error message, the line `cpp/ASAP/annotation/PUGIXML_INCLUDE_DIR` should be `PUGIXML_INCLUDE_DIR` - the **exact name** of the missed variable. Please, show other part of configuration log, which describes searching of `pugixml` package. – Tsyvarev May 02 '19 at 17:34
  • 1
    BTW, the name of the `pugixml` config file is [pugixmlConfig.cmake](https://github.com/joselusl/pugixml/blob/master/cmake/pugixmlConfig.cmake.in) (not a `pugixml-config.cmake` as you write). And "I simply copied the lib file I compiled to the location pugixml-config.cmake was pointing." is no-no: All **installed** files, including library, headers, `*Config.cmake` should NOT be moved. – Tsyvarev May 02 '19 at 17:37
  • @drescherjm: No, PugiXML_DIR should contain a file named pugixml-config.cmake, cmake looks for that file in PugiXML_DIR. This file is generated when I build pugixml, and it is this directory: \cpp\pugixml-1.8\pugixml-1.8\CMakeFiles\Export\lib\cmake\pugixml. (the binaries you mentioned contains only lib file, I believe the config is supposed to automatically point the lib file...and it does, but at a wrong location...which is why I had to copy the compiled lib file) – aditya sista May 03 '19 at 04:17
  • @Tsyvarev: where is that log? The cmake output log doesn't have any error related to pugixml. For some reason it has this error "error C1083: Cannot open include file: 'pthread.h': No such file or directory" before BUILD FAILED. – aditya sista May 03 '19 at 04:32
  • @Tsyvarev: the cmake build of pugixml generated following files: pugixml-config.cmake, pugixml-config-debug.cmake, pugixml-config-release.cmake and thats all. These are present in CMakeFiles/export/lib/cmake/pugixml/. I could not find pugixmlConfig.cmake anywhere. Are you sure its not changed in one of recent releases? (Also I remember the error message when I did not include PugiXML_DIR, it said "PugiXML_DIR" should contain one of the following pugixml-config.cmake or pugixmlConfig.cmake – aditya sista May 03 '19 at 04:35
  • ***Cannot open include file: 'pthread.h'*** Do you have the pthreads libraray? Visual Studio won't have that by default. There may be a way to deactivate that when building. – drescherjm May 03 '19 at 10:08
  • I have used CMake at work since 2008. What I have told you works for every single CMake based package I have used (which is several hundred). I am not saying this is the only way because a project can export these files to a different location via an INSTALL target but the builtin CMake behavior should still work. – drescherjm May 03 '19 at 10:23
  • 1
    Sorry, the name of the config file is actually `pugixml-config.cmake`: I was checking the wrong repo, the correct (official) one is https://github.com/zeux/pugixml/tree/v1.8. But path `\cpp\pugixml-1.8\pugixml-1.8\CMakeFiles\Export\lib\cmake\pugixml` points to the **build directory**, which is unsuitable for using `pugixml`. You need to **install** `pugyxml`, and make `PugiXML_DIR` variable to point to the **installed** location of the file. "where is that log?" - the configuration log contains "CMake Error" message which you provide. Aside the error, it also contains other useful messages. – Tsyvarev May 03 '19 at 18:33
  • @Tsyvarev: as you asked I installed it, there was a cmake install script that simply copied stuff to program files (exactly the way I copied...) ...and I pointed PugiXML_DIR to that directory. No change, it still gives that same error. – aditya sista May 03 '19 at 21:16
  • Well, then show the part of CMake configuration log about finding `pugixml`, as I described before. – Tsyvarev May 03 '19 at 22:02
  • @Tsyvarev: I couldn't find anything that says cmake configuration log. I have checked the contents of cmake output log as well as cmake error log, but couldn't find anything related to pugixml. Where can I find the log that you have mentioned? – aditya sista May 06 '19 at 07:05
  • The error message you got (`CMake Error: The following variables are used in this project, but they are set to NOTFOUND.`) is part of the configuration log. Before that message it could be some messages (not errors!) about pugixml. The log isn't stored into any file, so you need to run `cmake` again to see it. – Tsyvarev May 06 '19 at 08:32
  • 1
    Well, I think I got the root of your problems. In previous ASAP versions they play dirty games with `pugixml` include directories. In newer versions they added `FindPugiXML.cmake` script which handle this in a natural manner. Update ASAP sources (with `git pull`), clean build directory and run `cmake` again. If it will complain about not finding `PugiXML_INCLUDE_DIR` variable, then you may set this variable to the pugixml include directory (which contains `pugixml.hpp` file). – Tsyvarev May 06 '19 at 08:54
  • @Tsyvarev: Thank you very much. That worked. I wasn't aware that they had made a new commit for this. Please submit that as the answer and I will mark it. – aditya sista May 06 '19 at 09:47

1 Answers1

2

In ASAP versions before 4.04.2019 they play dirty games with extracting include directory from the IMPORTED target. annotation/CMakeLists.txt:30:

get_target_property(PUGIXML_INCLUDE_DIR pugixml INTERFACE_INCLUDE_DIRECTORIES)

In some cases this results in setting PUGIXML_INCLUDE_DIR variable to "-NOTFOUND", thus you got corresponded error message from CMake.

In commit 36d8bd75 they add FindPugiXML.cmake script, which handle find_package(PugiXML) call instead of configuration script shipped with PugiXML. In that find script they obtain include directory with find_path, which looks more natually:

find_path(PugiXML_INCLUDE_DIR pugixml.hpp)

Because in newer ASAP versions the configuration script (pugixml-config.cmake), shipped with PugiXML, is no longer used, one cannot hint about PugiXML location with PugiXML_DIR or PugiXML_ROOT. In case PugiXML is installed into non-system-default location, one may simply set PugiXML_INCLUDE_DIR variable to the PugiXML include directory.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153