Using Cmake and find: Configuring incomplete, errors occurred!

Hi, I install igraph by using vcpkg:

  1. I opened my Terminal and type in vcpkg install igraph
  2. After the installation was down, I typed cd “my project” and swifted to my project folder
  3. I ceated CMakeLists.txt file and followed below instructions:
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE="my vcpkg location/vcpkg/scripts/buildsystems/vcpkg.cmake"
  1. It showed
CMake Error at C:/Users/Pei/Desktop/GitHub/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package):
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)
-- Configuring incomplete, errors occurred!
  1. Above steps all went well and the CMakeLists.txt file was written as below:
cmake_minimum_required(VERSION 3.18)
project(igraph_test)

find_package(igraph REQUIRED)

add_executable(igraph_test igraph_test.c)
target_link_libraries(igraph_test PUBLIC igraph::igraph)

Could anyone tells me where I did wrong?

I’m not quite sure what is going wrong.

Can you please:

  • Post the output of vcpkg list igraph
  • Start with an empty build directory for your project (delete ans re-create build)
  • Post a complete terminal transcript, including your commands and all output

Sure! Here’s my steps. I wrote these all in vscode terminal.

My vcpkg list igraph:

PS C:\Users\Pei\Desktop\GitHub\vcpkg>./vcpkg list igraph
igraph:x86-windows 0.10.4 igraph is a C library for network analysis and g…
igraph[graphml]:x86-windows Support for reading GraphML files

My terminal transcript:

PS C:\Users\Pei\OneDrive\文件\CppExercise\Example> mkdir build

Directory: C:\Users\Pei\OneDrive\文件\CppExercise\Example

Mode LastWriteTime Length Name


d----- 2023/6/7 上午 04:18 build

PS C:\Users\Pei\OneDrive\文件\CppExercise\Example> cd build
PS C:\Users\Pei\OneDrive\文件\CppExercise\Example\build> cmake … -DCMAKE_TOOLCHAIN_FILE=“C:\Users\Pei\Desktop\GitHub\vcpkg\scripts\buildsystems\vcpkg.cmake”

– Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
CMake Error at C:/Users/Pei/Desktop/GitHub/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package):
By not providing “Findigraph.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “igraph”, but
CMake did not find one.

Could not find a package configuration file provided by “igraph” with any
of the following names:

igraphConfig.cmake
igraph-config.cmake

Add the installation prefix of “igraph” to CMAKE_PREFIX_PATH or set
“igraph_DIR” to a directory containing one of the above files. If “igraph”
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)

– Configuring incomplete, errors occurred!

Thank you for helping me!

And here is my CMakeLists.txt file:

cmake_minimum_required(VERSION 3.18)

project(${igraph_test})

find_package(igraph REQUIRED)

add_executable( $ {igraph_test} ${main}.cpp)

target_link_libraries(${igraph_test} PUBLIC igraph::igraph)

Why did you add ${...} around several of the names in your CMakeLists.txt? This is why it doesn’t work. Remove those and write the CMakeLists.txt file as in the your top post in this thread.

Yes, thank you. But there’s still a problem in my project.

I deleted these ${ … } and typed in terminal
cmake … -DCMAKE_TOOLCHAIN_FILE=“my vcpkg location\vcpkg\scripts\buildsystems\vcpkg.cmake”

Output:

CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a “project(Project)” command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
cmake_minimum_required() should be called prior to this top-level project()
call. Please see the cmake-commands(7) manual for usage documentation of
both commands.
This warning is for project developers. Use -Wno-dev to suppress it.

– Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
– Configuring done (0.0s)
– Generating done (0.0s)
– Build files have been written to: C:/Users/Pei/OneDrive/文件/CppExercise/Example/build

Then, I continued type cmake --build . in termianl.

Output:

MSBuild version 17.6.3+07e294721 for .NET Framework

Checking Build System
Building Custom Rule C:/Users/Pei/OneDrive/文件/CppExercise/Example/CMakeLists.txt

After these all, I clicked run but the output showed:

tempCodeRunnerFile.cpp:4:20: fatal error: igraph.h: No such file or directory
#include <igraph.h>

compilation terminated

My advice here is to follow the tutorial very carefully, and if you still can’t get it working, then describe precisely and completely what you did.

The CMakeLists.txt contents you indicated in your first post were in fact different from what you were using, and what you showed in your second post. We couldn’t possible have guessed this. Then you removed the project line, even though this is not what I suggested you do.

We cannot help unless we know what you were doing exactly, and how this differs from the tutorial.

FYI I tested the setup described in the top post with vcpkg and I see no errors.

No, I didn’t remove project (project name)in my CMakeLists.txt. All I did was follow your instructions and remove ${…}. So that’s what I’m confused.

To identify what is different on your system, please do the following:

  • Delete any existing build directory from your project
  • Follow the tutorial closely, except that instead of -DCMAKE_PREFIX_PATH=... use -DCMAKE_TOOLCHAIN_FILE=...
  • Share all files within your project. There will be two files, a C source file and a CMakeLists.txt.
  • Use the standard terminal, not the one from VSCode
  • Post a complete, unedited terminal transcript, starting with creating a new build directory. Use a code block for the transcript.

Because I’m new user so that I cannot upload files. I type them here.

CMakeLists.txt

cmake_minimum_required(VERSION 3.18)

project(igraph_test)

find_package(igraph REQUIRED)

add_executable(igraph_test igraph_test.cpp)

target_link_libraries(igraph_test PUBLIC igraph::igraph)

igraph_test.cpp

#include <iostream>
using namespace std;
#include <igraph/igraph.h>


int main(){
    cout<<"Hello World!"<<endl;
}

Terminal command (After I switch back to standard terminal, the old error occurred again.)

PS C:\Users\User\OneDrive\文件\CppExercise\Example> mkdir build
PS C:\Users\User\OneDrive\文件\CppExercise\Example> cd build
PS C:\Users\User\OneDrive\文件\CppExercise\Example\build> cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake"
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- The C compiler identification is MSVC 19.36.32532.0
-- The CXX compiler identification is MSVC 19.36.32532.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting CXX compile features - done
CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package):
  By not providing "Findigraph.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "igraph", but
  CMake did not find one.

  Could not find a package configuration file provided by "igraph" with any
  of the following names:

    igraphConfig.cmake
    igraph-config.cmake

  Add the installation prefix of "igraph" to CMAKE_PREFIX_PATH or set
  "igraph_DIR" to a directory containing one of the above files.  If "igraph"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package)

-- Configuring incomplete, errors occurred!

Sorry, I don’t know what code block means. Hope this will help.

I see that you installed vcpkg to a different location than where you previously had it. Did you install igraph to this new location? The error indicates that you didn’t.

See here on how to delimit code and terminal output: How to use this forum?


At this point I strongly suggest to find someone who is experienced with CMake and can sit with you at your computer and help directly. The problems you are seeing are not related to igraph. They are about basic usage of CMake and vcpkg. It is understandable that it will be overwhelming for a a newcomer to learn to use all these systems all at once, but a frequent back and forth on a forum is not a productive way of doing so.