5
votes

I am a novice to CMake, so I always prefer to use the CMake GUI.

I am actually setting up the Point Cloud Library (PCL). However, it requires a few other dependency libraries, and one among them was FLANN -> Git Link FLANN

What I have done until now is:

  1. Downloaded the souces from the link: Git Link FLANN
  2. Created a build directory
  3. Set CMake SOURCE code path - C:/PCL/flann-master

    Set CMake Build binaries path - C:/PCL/flann-master/build

  4. Checked the Grouped and Advanced options
  5. Configure

enter image description here

It gave the following error:

CMake Warning (dev) at CMakeLists.txt:17 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:21 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.13/Modules/FindPkgConfig.cmake:39 (find_package_handle_standard_args)
  CMakeLists.txt:149 (find_package)

My question is: What do I need to do in order for it to build it?

3

3 Answers

2
votes

I have build FLANN (x64) on windows (with Visual Studio 2015) this way:

in main CMakeLists.txt I have comment out lz4 section like this:

#if( NOT WIN32)
#  find_package(PkgConfig REQUIRED)
#  pkg_search_module(LZ4 REQUIRED liblz4)
#endif()

I have copied lz4.h, lz4hc.h, lz4.c and lz4hc.c to ./src/cpp/flann/util directory

Now I have generated Visual Studio solutions and in flann solution, I have manually added lz4.c and lz4hc.c to sources. (If you want to build bindings and other parts of FLANN library, add the same sources to their solutions as well).

Build projects and it will correctly build.

1
votes

The best way to build FLANN in Visual Studio is to use vcpkg.

Also, if your target is PCL itself, you can re-use information from CI scripts.

The steps are quite straight forward:

  1. Install dependencies using vcpkg - eigen3 flann gtest qhull
  2. Generate VS solution using those dependencies.
0
votes

The important take-away from your error log is this line:

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)

Using PkgConfig with CMake is not a truly cross-platform solution, as Windows does not come with the pkg-config utility installed. (The PCL developers should instead use find_package() in their CMake. Perhaps, this is worth opening up a bug report on their Github.) On Linux, this is an easy fix; you can install pkg-config like this:

sudo apt-get install pkg-config

However, on Windows, the process is more involved. There are several solutions for installing pkg-config on Windows documented here. I'm not sure which most directly applies to your situation, so I suggest reading through some of those. After successfully installing the pkg-config utility on your Windows machine, clear your CMake cache, and re-run. This should remove the error, and allow your build to proceed.