Witam. Mam problem z podłączeniem bibliotek "na stałe" w systemie Windows używając CMake i Visual Studio 2019. Używam Windowsa i Linux'a i bardzo często się pomiędzy nimi przełączam. Jestem także w trakcie pisania własnego projektu i chciałbym żeby bez większego wysiłku móc kontynuować jego pisanie na obu systemach .
Przykładowo korzystam z tej biblioteki :
https://github.com/palacaze/sigslot
Instalacja i wstrzykiwanie tej biblioteki na Linuksie sprowadziła się tylko do
cmake .. oraz
cmake --build . --target install
Po czym pliki( .a , .hpp ) tej biblioteki zostały umieszczone w usr/local/include oraz .../lib . Na Linuksie używam QtCreatora , jednak buduję z CMake. W tym przypadku w dowolnym pliku CMakeLists.txt wystarczy dodać :
find_package(PalSigslot)
target_link_libraries(target PRIVATE Pal::Sigslot)
I mogę normalnie w plikach należących do targetu użyć dyrektywy :
#include "sigslot/signal.hpp"
To tyle jeśli chodzi o Linuksa .
Jeżeli chodzi o Windowsa to korzystam tam z Visual Studio 2019 i też buduję z CMake . Mam również zainstalowany CMake . Odpaliłem konsolę VS2019 w celu zainstalowania i wpisałem następujące polecenia:
cmake .. -DSIGSLOT_REDUCE_COMPILE_TIME=ON -DCMAKE_INSTALL_PREFIX=~/local
cmake --build . --target install
W konsoli wygląda to następująco :
C:\Users\***\sigslot>mkdir build
C:\Users\***\sigslot>cd build
C:\Users\***\sigslot\build>cmake .. -DSIGSLOT_REDUCE_COMPILE_TIME=ON -DCMAKE_INSTALL_PREFIX=~/local
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.18363.
-- The CXX compiler identification is MSVC 19.26.28806.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/***/sigslot/build
C:\Users\***\sigslot\build>cmake --build . --target install
Microsoft (R) Build Engine 16.6.0+5ff7b0c9e dla platformy .NET Framework
Copyright (C) Microsoft Corporation. Wszelkie prawa zastrzeżone.
Checking Build System
Building Custom Rule C:/Users/***/sigslot/CMakeLists.txt
-- Install configuration: "Debug"
-- Up-to-date: C:/Users/**/local/include
-- Up-to-date: C:/Users/**/local/include/sigslot
-- Up-to-date: C:/Users/**/local/include/sigslot/adapter
-- Installing: C:/Users/**/local/include/sigslot/adapter/boost.hpp
-- Installing: C:/Users/**/local/include/sigslot/adapter/qt.hpp
-- Installing: C:/Users/**/local/include/sigslot/signal.hpp
-- Installing: C:/Users/**/local/lib/cmake/PalSigslot/PalSigslotTargets.cmake
-- Installing: C:/Users/**/local/lib/cmake/PalSigslot/PalSigslotConfig.cmake
-- Installing: C:/Users/**/local/lib/cmake/PalSigslot/PalSigslotConfigVersion.cmake
C:\Users\***\sigslot\build>
Jednak ,gdy próbuję podpiąć bibliotekę do CMake w taki sposób:
find_package(PalSigslot)
target_link_libraries(target PRIVATE Pal::Sigslot)
lub
find_package(PalSigslot)
add_executable(MyExe main.cpp)
target_link_libraries(target Pal::Sigslot)
To zostaję zasypany takimi komunikatami :
1> [CMake] By not providing "FindPalSigslot.cmake" in CMAKE_MODULE_PATH this project
1> [CMake] has asked CMake to find a package configuration file provided by
1> [CMake] "PalSigslot", but CMake did not find one.
1> [CMake]
1> [CMake] Could not find a package configuration file provided by "PalSigslot" with
1> [CMake] any of the following names:
1> [CMake]
1> [CMake] PalSigslotConfig.cmake
1> [CMake] palsigslot-config.cmake
1> [CMake]
1> [CMake] Add the installation prefix of "PalSigslot" to CMAKE_PREFIX_PATH or set
1> [CMake] "PalSigslot_DIR" to a directory containing one of the above files. If
1> [CMake] "PalSigslot" provides a separate development package or SDK, be sure it has
1> [CMake] been installed.
1> [CMake]
1> [CMake]
1> [CMake] -- Configuring done
1> [CMake] CMake Error at C:\Users\PROJECT\CMakeLists.txt:40 (add_executable):
1> [CMake] Target "scorpion" links to target "Pal::Sigslot" but the target was not
1> [CMake] found. Perhaps a find_package() call is missing for an IMPORTED target, or
1> [CMake] an ALIAS target is missing?
1> [CMake]
1> [CMake]
1> [CMake] -- Generating done
1> [CMake] CMake Generate step failed. Build files cannot be regenerated correctly.
Z góry dziękuję za pomoc, jeżeli zachodzą niejasności , to proszę walić śmiało :D