-
-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Labels
questionQuestionQuestion
Description
As far as I am aware cmake find_package thing attempting search packages in CMAKE_INSTALL_PREFIX directory or <package_name>_DIR defined in environment variables.
But option with <package_name>_DIR is failing on my system for a some reason.
System Info
- OS: Ubuntu 24.04.3 LTS x86_64
- cmake version 3.28.3
Steps to reproduce:
- Download, unpack cpptrace https://github.com/jeremy-rifkin/cpptrace/releases/tag/v1.0.4
- Cd to cpptrace source dir and configure cpptrace cmake project with all defaults, except CMAKE_INSTALL_PREFIX="<cpptrace_location>", <cpptrace_location> = /home/xxx/Projects/CMakePackages/cpptrace-1.0.4 in my case
cmake -S . -B out -DCMAKE_INSTALL_PREFIX="<cpptrace_location>"- Build and install cpptrace
cmake --build out
cmake --install out- Create 'Sandbox' project
#CMakeLists.txt
cmake_minimum_required(VERSION 3.26)
project(Sandbox CXX)
find_package(zstd)
find_package(cpptrace)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC cpptrace::cpptrace)//main.cpp
#include <stdio.h>
#include <cpptrace/cpptrace.hpp>
void trace() {
cpptrace::generate_trace().print();
}
int main(int argc, const char** argv)
{
trace();
printf("hello, world\n");
}
- Set environment variable cpptrace_DIR="<cpptrace_location>" and for nested zstd
export cpptrace_DIR="<cpptrace_location>"
export zstd_DIR="<cpptrace_location>"- cd to 'Sandbox' project and run cmake configuration
cmake -S . -B outCmake gives configuration error
-- The CXX compiler identification is GNU 13.3.0
-- 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
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
CMake Warning at CMakeLists.txt:6 (find_package):
Found package configuration file:
<cpptrace_location>/lib/cmake/cpptrace/cpptrace-config.cmake
but it set cpptrace_FOUND to FALSE so package "cpptrace" is considered to
be NOT FOUND. Reason given by package:
cpptrace could not be found because dependency zstd could not be found.
-- Configuring done (0.3s)
CMake Error at CMakeLists.txt:9 (target_link_libraries):
Target "Sandbox" links to:
cpptrace::cpptrace
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Expected
Configuration without errors(?)
I am missing something in Sandbox project/system configuration?
If I do configuration of Sandbox project with CMAKE_INSTALL_PREFIX. Both configuration and build will be succeed.
cmake -S . -B out -DCMAKE_INSTALL_PREFIX="<cpptrace_location>"-- Found zstd: <cpptrace_location>/lib/libzstd.a
-- Found Zstd: <cpptrace_location>/lib/libzstd.a
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.3")
-- Found zstd: <cpptrace_location>lib/libzstd.a (found version "1.5.7")
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: <home>/Sandbox/out
Metadata
Metadata
Assignees
Labels
questionQuestionQuestion