conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.13k stars 968 forks source link

[bug] Test of cmake lib cannot access include subdirectories #16869

Open ArthurValadares opened 3 weeks ago

ArthurValadares commented 3 weeks ago

Describe the bug

Hello, I would like some guidance on how to proceed with the following problem:

I am creating a library for educational purposes. I chose to use CMake, in order to write the unit tests I chose Catch2. However, it seems that conan, in the process of creating the package, cannot find the header files in subdirectories from the library include in order to run the unit tests. I chose to run conan inside a venv.

When trying to execute the creation of the package, the step that refers to the execution of the tests results in the following error:

======== Testing the package: Building ========
data-structure/0.1.0 (test package): Calling build()
data-structure/0.1.0 (test package): Running CMake.configure()
data-structure/0.1.0 (test package): RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package"
-- Using Conan toolchain: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release/generators/conan_toolchain.cmake
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: C++ Standard 17 with extensions ON
-- The CXX compiler identification is GNU 14.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Target declared 'data-structure::data-structure'
-- Conan: Component target declared 'Catch2::Catch2'
-- Conan: Component target declared 'Catch2::Catch2WithMain'
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release

data-structure/0.1.0 (test package): Running CMake.build()
data-structure/0.1.0 (test package): RUN: cmake --build "/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release" -- -j8
[ 75%] Building CXX object CMakeFiles/test.dir/CMakeFiles/3.28.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
[ 75%] Building CXX object CMakeFiles/test.dir/src/main.cpp.o
[ 75%] Building CXX object CMakeFiles/test.dir/src/common/node/DoublyLinkedNodeTest.cpp.o
/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/src/common/node/DoublyLinkedNodeTest.cpp:6:10: fatal error: common/Common.h: Arquivo ou diretório inexistente
    6 | #include "common/Common.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/test.dir/build.make:90: CMakeFiles/test.dir/src/common/node/DoublyLinkedNodeTest.cpp.o] Error 1
gmake[2]: ** Esperando que outros processos terminem.
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

ERROR: data-structure/0.1.0 (test package): Error in build() method, line 20
    cmake.build()
    ConanException: Error 2 while executing

My setup: version: 2.6.0 conan_path: /home/arthur/Documentos/Programacao/Cpp/data_structure/.venv/bin/conan python version: 3.12.4 sys_version: 3.12.4 (main, Jun 7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] sys_executable: /home/arthur/Documentos/Programacao/Cpp/data_structure/.venv/bin/python is_frozen: False architecture: x86_64 system version: #1 SMP PREEMPT_DYNAMIC Wed Aug 14 15:49:44 UTC 2024 platform: Linux-6.10.5-200.fc40.x86_64-x86_64-with-glibc2.39 system: Linux release: 6.10.5-200.fc40.x86_64 cpu:

Fedora 40 - x86_64

cmake version 3.28.2

gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1)

The repository: https://github.com/ArthurValadares/data_structure

How to reproduce it

Clone the project, create a virtual enviroment, install the requirements, install dependencies and run conan create . on the root of project.

memsharded commented 3 weeks ago

Hi @ArthurValadares

Thanks for your report.

First thing, an important note: The test_package is not intended to run unit tests or the functional test suite of a package. Its purpose is to test the integrity of the package, if the headers and libraries have been correctly packaged. Please read: https://docs.conan.io/2/tutorial/creating_packages/test_conan_packages.html

What you are seeing is kind of expected:

So the location common/Common.h doesn't exist in the final package, so it fails.

Side note: I tried first to compile it in windows with latest msvc, got compile error:

  ArrayQueue.cpp
C:\Users\memsharded\.conan2\p\b\data-392edb6804760\b\src\heap\MinHeap.cpp(9,24): error C2244: 'MinHeap<T>::from': unable to match function definition to an existi ng declaration [C:\Users\memsharded\.conan2\p\b\data-392edb6804760\b\build\data-structure.vcxproj]

Please let me know if this clarifies it.

ArthurValadares commented 2 weeks ago

Hi, @memsharded

Thank you so much for your response! It was really quick, too.

I must have overlooked the part about the test_package folder being different from unit or integration tests. I'm sorry for the confusion! After doing a little more research, I found some helpful guidance in the documentation on how to create a test directory. Here's a link to it: https://docs.conan.io/2/tutorial/creating_packages/build_packages.html

I followed the instructions as carefully as I could, but I ran into another little hiccup. By adding the test subdirectory inclusion line in CMakeLists.txt, in the root of the project, and running the conan create . --build=missing -tf="", I got the following error:

(.venv) ~/Documentos/Programacao/Cpp/data_structure git:[main]
conan create . --build=missing -tf=""

======== Exporting recipe to the cache ========
data-structure/0.1.0: Exporting package recipe: /home/arthur/Documentos/Programacao/Cpp/data_structure/conanfile.py
data-structure/0.1.0: Copied 1 '.py' file: conanfile.py
data-structure/0.1.0: Copied 1 '.txt' file: CMakeLists.txt
data-structure/0.1.0: Copied 18 '.cpp' files
data-structure/0.1.0: Copied 53 '.h' files
data-structure/0.1.0: Exported to cache folder: /home/arthur/.conan2/p/data-9cf5ed7a4fa28/e
data-structure/0.1.0: Exported: data-structure/0.1.0#e28dcbb53bede8cfdbe533e8dddeab97 (2024-08-24 12:19:05 UTC)

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=14
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=14
os=Linux

======== Computing dependency graph ========
Graph root
    cli
Requirements
    data-structure/0.1.0#e28dcbb53bede8cfdbe533e8dddeab97 - Cache
Test requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8 - Cache

======== Computing necessary packages ========
data-structure/0.1.0: Compatible package ID ae31f4f7984f94788aa6945a68ab71ea3440d27f equal to the default package ID: Skipping it.
data-structure/0.1.0: Checking 11 compatible configurations
data-structure/0.1.0: Compatible configurations not found in cache, checking servers
data-structure/0.1.0: '19e76c591e0db138ea6a504bf67f4ebac49a744f': compiler.cppstd=98
data-structure/0.1.0: 'b589aed704ed6fa9927e74a7d1ecadb4756dbe6f': compiler.cppstd=gnu98
data-structure/0.1.0: 'a9393aaaca90c6112c92fdb5bd5dfed3f6a14b4c': compiler.cppstd=11
data-structure/0.1.0: '40c40f17d630c16c0798b5b711b9a188938b8915': compiler.cppstd=gnu11
data-structure/0.1.0: '3d165ad845ba89e735e36221245f95300061dd8c': compiler.cppstd=14
data-structure/0.1.0: '9918002422d4c780d6421bbafbbd8a46f059b9a8': compiler.cppstd=gnu14
data-structure/0.1.0: 'ac886dcc03ead73fafeab42f13152217513c8be1': compiler.cppstd=17
data-structure/0.1.0: 'd1737f1ec9a769c4e540e98a71b868c81aca8fc0': compiler.cppstd=20
data-structure/0.1.0: '31e4214aa9580550ed7f61478cd63bf8eccc0352': compiler.cppstd=gnu20
data-structure/0.1.0: '60d979b0a7d7272ce4719856e16fef14b991f4c9': compiler.cppstd=23
data-structure/0.1.0: '490742199b5120b03b892ab128fdb9921780212b': compiler.cppstd=gnu23
Requirements
    data-structure/0.1.0#e28dcbb53bede8cfdbe533e8dddeab97:ae31f4f7984f94788aa6945a68ab71ea3440d27f - Build
Test requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8:6d28918eef0b37f733e5487a1bab5e6762052759#29a57c5d633cb60921049764a13795f2 - Cache

======== Installing packages ========
catch2/3.7.0: Already installed! (1 of 2)

-------- Installing package data-structure/0.1.0 (2 of 2) --------
data-structure/0.1.0: Building from source
data-structure/0.1.0: Package data-structure/0.1.0:ae31f4f7984f94788aa6945a68ab71ea3440d27f
data-structure/0.1.0: Copying sources to build folder
data-structure/0.1.0: Building your package in /home/arthur/.conan2/p/b/data-6555a9a70d783/b
data-structure/0.1.0: Calling generate()
data-structure/0.1.0: Generators folder: /home/arthur/.conan2/p/b/data-6555a9a70d783/b/build/Release/generators
data-structure/0.1.0: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
    find_package(Catch2)
    target_link_libraries(... Catch2::Catch2WithMain)
data-structure/0.1.0: CMakeToolchain generated: conan_toolchain.cmake
data-structure/0.1.0: CMakeToolchain generated: /home/arthur/.conan2/p/b/data-6555a9a70d783/b/build/Release/generators/CMakePresets.json
data-structure/0.1.0: CMakeToolchain generated: /home/arthur/.conan2/p/b/data-6555a9a70d783/b/CMakeUserPresets.json
data-structure/0.1.0: Generating aggregated env files
data-structure/0.1.0: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
data-structure/0.1.0: Calling build()
data-structure/0.1.0: Running CMake.configure()
data-structure/0.1.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/arthur/.conan2/p/b/data-6555a9a70d783/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/arthur/.conan2/p/b/data-6555a9a70d783/b"
-- Using Conan toolchain: /home/arthur/.conan2/p/b/data-6555a9a70d783/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: C++ Standard 17 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is GNU 14.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:19 (add_subdirectory):
  add_subdirectory given source "tests" which is not an existing directory.

-- Configuring incomplete, errors occurred!

data-structure/0.1.0: ERROR: 
Package 'ae31f4f7984f94788aa6945a68ab71ea3440d27f' build failed
data-structure/0.1.0: WARN: Build folder /home/arthur/.conan2/p/b/data-6555a9a70d783/b/build/Release
ERROR: data-structure/0.1.0: Error in build() method, line 48
        cmake.configure()
        ConanException: Error 1 while executing

Please forgive me if I'm going off on a bit of a tangent here. If you'd rather I didn't, I'll start a new thread on the subject. The latest amendments have now been incorporated into the repository.

memsharded commented 2 weeks ago

The main issue is that you are not exporting the tests folder.

See the line exports_sources = "CMakeLists.txt", "src/*", "include/*" in the conanfile.py (see for example https://docs.conan.io/2/tutorial/creating_packages/create_your_first_package.html). You should add there the tests/* folder too.

Then a couple of extra things:

ArthurValadares commented 2 weeks ago

I followed the instructions to the letter, both here and in the link you provided, but I ended up running into another little hiccup. When I ran the command conan create . in the root of the project, I got the following error:

Once more, changes are synced with the repository. Thanks so much for your time and attention!

(.venv) ~/Documentos/Programacao/Cpp/data_structure git:[main]
conan create .

======== Exporting recipe to the cache ========
data-structure/0.1.0: Exporting package recipe: /home/arthur/Documentos/Programacao/Cpp/data_structure/conanfile.py
data-structure/0.1.0: Copied 1 '.py' file: conanfile.py
data-structure/0.1.0: Copied 2 '.txt' files: CMakeLists.txt, CMakeLists.txt
data-structure/0.1.0: Copied 19 '.cpp' files
data-structure/0.1.0: Copied 53 '.h' files
data-structure/0.1.0: Exported to cache folder: /home/arthur/.conan2/p/data-3532eb419d05d/e
data-structure/0.1.0: Exported: data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd (2024-08-25 12:29:41 UTC)

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=14
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=14
os=Linux

======== Computing dependency graph ========
Graph root
    cli
Requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8 - Cache
    data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd - Cache

======== Computing necessary packages ========
data-structure/0.1.0: Forced build from source
Requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8:6d28918eef0b37f733e5487a1bab5e6762052759#29a57c5d633cb60921049764a13795f2 - Cache
    data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd:b120af5e431ebb6a7977363087a3b0d5941cf244 - Build

======== Installing packages ========
catch2/3.7.0: Already installed! (1 of 2)

-------- Installing package data-structure/0.1.0 (2 of 2) --------
data-structure/0.1.0: Building from source
data-structure/0.1.0: Package data-structure/0.1.0:b120af5e431ebb6a7977363087a3b0d5941cf244
data-structure/0.1.0: Copying sources to build folder
data-structure/0.1.0: Building your package in /home/arthur/.conan2/p/b/data-ba14d805af838/b
data-structure/0.1.0: Calling generate()
data-structure/0.1.0: Generators folder: /home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release/generators
data-structure/0.1.0: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
    find_package(Catch2)
    target_link_libraries(... Catch2::Catch2WithMain)
data-structure/0.1.0: CMakeToolchain generated: conan_toolchain.cmake
data-structure/0.1.0: CMakeToolchain generated: /home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release/generators/CMakePresets.json
data-structure/0.1.0: CMakeToolchain generated: /home/arthur/.conan2/p/b/data-ba14d805af838/b/CMakeUserPresets.json
data-structure/0.1.0: Generating aggregated env files
data-structure/0.1.0: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
data-structure/0.1.0: Calling build()
data-structure/0.1.0: Running CMake.configure()
data-structure/0.1.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/arthur/.conan2/p/b/data-ba14d805af838/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/arthur/.conan2/p/b/data-ba14d805af838/b"
-- Using Conan toolchain: /home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: C++ Standard 17 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is GNU 14.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Component target declared 'Catch2::Catch2'
-- Conan: Component target declared 'Catch2::Catch2WithMain'
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release

data-structure/0.1.0: Running CMake.build()
data-structure/0.1.0: RUN: cmake --build "/home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release" -- -j8
[  4%] Building CXX object CMakeFiles/data-structure.dir/src/common/node/DoublyLinkedNode.cpp.o
[  9%] Building CXX object CMakeFiles/data-structure.dir/src/hash/LinkedHashTable.cpp.o
[ 14%] Building CXX object CMakeFiles/data-structure.dir/src/common/node/SinglyLinkedNode.cpp.o
[ 19%] Building CXX object CMakeFiles/data-structure.dir/src/hash/OpenAddressHashTable.cpp.o
[ 23%] Building CXX object CMakeFiles/data-structure.dir/src/heap/MaxHeap.cpp.o
[ 33%] Building CXX object CMakeFiles/data-structure.dir/src/heap/AbstractHeap.cpp.o
[ 33%] Building CXX object CMakeFiles/data-structure.dir/src/heap/MinHeap.cpp.o
[ 38%] Building CXX object CMakeFiles/data-structure.dir/src/heap/Tournament.cpp.o
[ 42%] Building CXX object CMakeFiles/data-structure.dir/src/list/DoublyLinkedList.cpp.o
[ 47%] Building CXX object CMakeFiles/data-structure.dir/src/list/SinglyLinkedList.cpp.o
[ 52%] Building CXX object CMakeFiles/data-structure.dir/src/queue/ArrayQueue.cpp.o
[ 57%] Building CXX object CMakeFiles/data-structure.dir/src/queue/LinkedQueue.cpp.o
[ 61%] Building CXX object CMakeFiles/data-structure.dir/src/stack/ArrayStack.cpp.o
[ 66%] Building CXX object CMakeFiles/data-structure.dir/src/stack/LinkedStack.cpp.o
[ 71%] Building CXX object CMakeFiles/data-structure.dir/src/tree/binary_search_tree/BinarySearchTree.cpp.o
[ 76%] Building CXX object CMakeFiles/data-structure.dir/src/tree/binary_search_tree/DoublyLinkedBinarySearchTree.cpp.o
[ 80%] Building CXX object CMakeFiles/data-structure.dir/src/tree/common/node/DoublyLinkedBinaryTreeNode.cpp.o
[ 85%] Building CXX object CMakeFiles/data-structure.dir/src/tree/common/node/SinglyLinkedBinaryTreeNode.cpp.o
[ 90%] Linking CXX static library libdata-structure.a
[ 90%] Built target data-structure
[ 95%] Building CXX object tests/CMakeFiles/test_data_structure.dir/src/tests.cpp.o
[100%] Linking CXX executable test_data_structure
[100%] Built target test_data_structure

data-structure/0.1.0: Package 'b120af5e431ebb6a7977363087a3b0d5941cf244' built
data-structure/0.1.0: Build folder /home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release
data-structure/0.1.0: Generating the package
data-structure/0.1.0: Packaging in folder /home/arthur/.conan2/p/b/data-ba14d805af838/p
data-structure/0.1.0: Calling package()
data-structure/0.1.0: RUN: cmake --build "/home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release" --target test_data_structure -- -j8
[ 90%] Built target data-structure
[100%] Built target test_data_structure

data-structure/0.1.0: Running CMake.install()
data-structure/0.1.0: RUN: cmake --install "/home/arthur/.conan2/p/b/data-ba14d805af838/b/build/Release" --prefix "/home/arthur/.conan2/p/b/data-ba14d805af838/p"
-- Install configuration: "Release"
-- Installing: /home/arthur/.conan2/p/b/data-ba14d805af838/p/lib/libdata-structure.a

data-structure/0.1.0: package(): Packaged 1 '.a' file: libdata-structure.a
data-structure/0.1.0: Created package revision c56c1b63de25a257003da1ed29e6a1d4
data-structure/0.1.0: Package 'b120af5e431ebb6a7977363087a3b0d5941cf244' created
data-structure/0.1.0: Full package reference: data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd:b120af5e431ebb6a7977363087a3b0d5941cf244#c56c1b63de25a257003da1ed29e6a1d4
data-structure/0.1.0: Package folder /home/arthur/.conan2/p/b/data-ba14d805af838/p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.filenames' used in: catch2/3.7.0
WARN: deprecated:     'cpp_info.names' used in: catch2/3.7.0
WARN: deprecated:     'cpp_info.build_modules' used in: catch2/3.7.0

======== Launching test_package ========

======== Computing dependency graph ========
Graph root
    data-structure/0.1.0 (test package): /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/conanfile.py
Requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8 - Cache
    data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd - Cache

======== Computing necessary packages ========
Requirements
    catch2/3.7.0#70905dd442f2f2104ed34dab241b87a8:6d28918eef0b37f733e5487a1bab5e6762052759#29a57c5d633cb60921049764a13795f2 - Cache
    data-structure/0.1.0#15a7803280a5e5ae93a5411822b0cbcd:b120af5e431ebb6a7977363087a3b0d5941cf244#c56c1b63de25a257003da1ed29e6a1d4 - Cache

======== Installing packages ========
catch2/3.7.0: Already installed! (1 of 2)
data-structure/0.1.0: Already installed! (2 of 2)
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.filenames' used in: catch2/3.7.0
WARN: deprecated:     'cpp_info.names' used in: catch2/3.7.0
WARN: deprecated:     'cpp_info.build_modules' used in: catch2/3.7.0

======== Testing the package ========
Removing previously existing 'test_package' build folder: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release
data-structure/0.1.0 (test package): Test package build: build/gcc-14-x86_64-gnu17-release
data-structure/0.1.0 (test package): Test package build folder: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release
data-structure/0.1.0 (test package): Writing generators to /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release/generators
data-structure/0.1.0 (test package): Generator 'CMakeDeps' calling 'generate()'
data-structure/0.1.0 (test package): CMakeDeps necessary find_package() and targets for your CMakeLists.txt
    find_package(data-structure)
    target_link_libraries(... data-structure::data-structure)
data-structure/0.1.0 (test package): Generator 'CMakeToolchain' calling 'generate()'
data-structure/0.1.0 (test package): CMakeToolchain generated: conan_toolchain.cmake
data-structure/0.1.0 (test package): CMakeToolchain generated: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release/generators/CMakePresets.json
data-structure/0.1.0 (test package): CMakeToolchain generated: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/CMakeUserPresets.json
data-structure/0.1.0 (test package): Generating aggregated env files
data-structure/0.1.0 (test package): Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']

======== Testing the package: Building ========
data-structure/0.1.0 (test package): Calling build()
data-structure/0.1.0 (test package): Running CMake.configure()
data-structure/0.1.0 (test package): RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/arthur/Documentos/Programacao/Cpp/data_structure/test_package"
-- Using Conan toolchain: /home/arthur/Documentos/Programacao/Cpp/data_structure/test_package/build/gcc-14-x86_64-gnu17-release/generators/conan_toolchain.cmake
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: C++ Standard 17 with extensions ON
-- The CXX compiler identification is GNU 14.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Target declared 'data-structure::data-structure'
-- Conan: Component target declared 'Catch2::Catch2'
-- Conan: Component target declared 'Catch2::Catch2WithMain'
-- Configuring done (0.4s)
CMake Error in CMakeLists.txt:
  Imported target "data-structure::data-structure" includes non-existent path

    "/home/arthur/.conan2/p/b/data-ba14d805af838/p/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

ERROR: data-structure/0.1.0 (test package): Error in build() method, line 17
        cmake.configure()
        ConanException: Error 1 while executing
memsharded commented 2 weeks ago

Hi again @ArthurValadares

This seems something missing in your CMakeLists.txt, if you read the output log you can see:

-- Install configuration: "Release"
-- Installing: /home/diegor/.conan2/p/b/data-f166233358b43/p/lib/libdata-structure.a

data-structure/0.1.0: package(): Packaged 1 '.a' file: libdata-structure.a

That means, the headers from your library are not being packaged. This is because your CMakeLists.txt didn't provide the right instructions to install the headers. You can also inspect the package folder with

$ conan cache path data-structure/0.1.0:b120af5e431ebb6a7977363087a3b0d5941cf244

and inspect the final package folder.

You can fix it for example with:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd13202..ad76fd7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,3 +20,4 @@ if (NOT BUILD_TESTING STREQUAL OFF)
 endif()

 install(TARGETS ${LIB_NAME})
+install(DIRECTORY ${INCLUDE_DIR} DESTINATION .)
diff --git a/conanfile.py b/conanfile.py
index d66e62c..85bc5d5 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -22,7 +22,7 @@ class DataStructureRecipe(ConanFile):
     # Sources are located in the same place as this recipe, copy them to the recipe
     exports_sources = "CMakeLists.txt", "src/*", "include/*", "tests/*"

-    requires = "catch2/3.7.0"
+    test_requires = "catch2/3.7.0"

     def config_options(self):
         if self.settings.os == "Windows":

Note that I have also defined catch2 again as a test_requires, which is the recommended configuration