I tries to add a new library at vcpkg, so I have wrote a CONTROL file and portfile.cmake file. When I run the installation, it's successful:
./vcpkg.exe install gf:x64-windows
Computing installation plan...
The following packages will be built and installed:
gf[core]:x64-windows
Starting package 1/1: gf:x64-windows
Building package gf[core]:x64-windows...
-- SOURCE_PATH: C:/path/to/vcpkg/buildtrees/gf/src/v0.15.0
-- Dynamic build
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
-- Installing: C:/path/to/vcpkg/packages/gf_x64-windows/share/gf/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package gf[core]:x64-windows... done
Installing package gf[core]:x64-windows...
Installing package gf[core]:x64-windows... done
Elapsed time for package gf:x64-windows: 52.05 s
Total elapsed time: 52.1 s
The package gf:x64-windows provides CMake targets:
find_package(gf CONFIG REQUIRED)
target_link_libraries(main PRIVATE gf::gf0)
find_package(gfcore CONFIG REQUIRED)
target_link_libraries(main PRIVATE gf::gfcore0)
find_package(gfnet CONFIG REQUIRED)
target_link_libraries(main PRIVATE gf::gfnet0)
But when I want use this library into another project, I have this error:
cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake ..
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- CMAKE_MODULE_PATH: C:/path/to/project/pax_et_mors/modules
CMake Error at C:/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake:405 (_find_package):
By not providing "Findgf.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "gf", but CMake did
not find one.
Could not find a package configuration file provided by "gf" with any of
the following names:
gfConfig.cmake
gf-config.cmake
Add the installation prefix of "gf" to CMAKE_PREFIX_PATH or set "gf_DIR" to
a directory containing one of the above files. If "gf" provides a separate
development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/path/to/project/pax_et_mors/build/CMakeFiles/CMakeOutput.log".
Where is my error?
The library can be found here: https://github.com/GamedevFramework/gf
The project here: https://github.com/Hatunruna/ggj2020
This is the CONTROL file for gf:
Source: gf
Version: 0.15
Description: Gamedev Framework (gf) is a framework to build 2D games in C++14.
And the portfile.cmake:
find_program(GIT git)
set(GIT_URL "https://github.com/GamedevFramework/gf")
set(GIT_TAG "loading_thread")
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/${GIT_TAG})
message(STATUS "SOURCE_PATH: ${SOURCE_PATH}")
if(NOT EXISTS "${SOURCE_PATH}/.git")
message(STATUS "Cloning and fetching submodules")
vcpkg_execute_required_process(
COMMAND ${GIT} clone -b ${GIT_TAG} --recurse-submodules ${GIT_URL} ${SOURCE_PATH}
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME clone
)
message(STATUS "Checkout tag ${GIT_TAG}")
vcpkg_execute_required_process(
COMMAND ${GIT} checkout ${GIT_TAG}
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME checkout
)
endif()
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
if(${BUILD_SHARED})
message(STATUS "Dynamic build")
set(BUILD_SHARED_OPTION "ON")
else()
message(STATUS "Static build")
set(BUILD_SHARED_OPTION "OFF")
endif()
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS -DGF_BUILD_GAMES=OFF -DGF_BUILD_TOOLS=OFF -DGF_BUILD_EXAMPLES=OFF -DGF_BUILD_TESTS=OFF -DGF_BUILD_DOCUMENTATION=OFF -DGF_SINGLE_COMPILTATION_UNIT=ON -DGF_SHARED=${BUILD_SHARED_OPTION}
OPTIONS_RELEASE -DGF_DEBUG=OFF
OPTIONS_DEBUG -DGF_DEBUG=ON
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake)
vcpkg_copy_pdbs()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/share/doc"
)
file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/gf RENAME copyright)
Finally, I found the problem. vcpkg needs to have a separated folder for each targets.
So I have change the portfile.cmake:
find_program(GIT git)
# Same as previous...
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake TARGET_PATH "share/gf_tmp")
vcpkg_copy_pdbs()
file(RENAME "${CURRENT_PACKAGES_DIR}/share/gf_tmp/gfcore" "${CURRENT_PACKAGES_DIR}/share/gfcore")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/gf_tmp/gf" "${CURRENT_PACKAGES_DIR}/share/gf")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/gf_tmp/gfnet" "${CURRENT_PACKAGES_DIR}/share/gfnet")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/share/doc"
"${CURRENT_PACKAGES_DIR}/share/gf_tmp"
)
file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/gf RENAME copyright)
Related
I have been trying to build, and correctly set up Cmake with SFML using find_package + SFMLConfig.cmake.
Cmake correctly finds a configuration file (along with ConfigDependencies, ConfigVersion, ConfigSharedTargets) at default linux install location per the SFML compilation instructions:
/usr/local/lib/cmake/sfml
However at that path there is no shared library files (.so).
all of them (audio, graphics, network, system and window) are all the way up at:
/usr/local/lib
So i believe i have correctly built and "installed" SFML with make.
I get this error message (for all four components):
CMake Error at /usr/local/lib/cmake/SFML/SFMLConfig.cmake:150 (message):
Found SFML but requested component 'audio' is missing in the config defined in /usr/local/lib/cmake/SFML.
Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)
CMake Error at CMakeLists.txt:17 (find_package): Found package configuration file:
/usr/local/lib/cmake/SFML/SFMLConfig.cmake
but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT FOUND.
I have tried to set the SFML_DIR variable in my CMakeLists.txt to many different places, both where i store SFML source (where i git cloned), where i built in to SFML-build. and where it is installed.
Why are the components missing? Should i copy the .so files into where the SFMLConfig.cmake file is? Should i move the SFMLConfig.cmake and update CMAKE_MODULE_PATH to a new path?
Looking into the SFMLConfig.cmake i see that the last if and elseif Statements in the code below is the one that fails. Meaning
TARGET SFML::${component} evaluates false. But I'm not sure what that means.
#SFMLConfig.cmake
foreach(component ${SFML_FIND_COMPONENTS})
string(TOUPPER "${component}" UPPER_COMPONENT)
list(APPEND FIND_SFML_ADDITIONAL_COMPONENTS ${FIND_SFML_${UPPER_COMPONENT}_DEPENDENCIES})
endforeach()
list(APPEND SFML_FIND_COMPONENTS ${FIND_SFML_ADDITIONAL_COMPONENTS})
list(REMOVE_DUPLICATES SFML_FIND_COMPONENTS)
[...]
foreach (component ${SFML_FIND_COMPONENTS})
string(TOUPPER "${component}" UPPER_COMPONENT)
set(SFML_${UPPER_COMPONENT}_FOUND FALSE)
if (TARGET SFML::${component})
set(SFML_${UPPER_COMPONENT}_FOUND TRUE)
elseif(SFML_FIND_REQUIRED_${component})
set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the config defined in ${SFML_DIR}.")
set(SFML_FOUND FALSE)
endif()
endforeach()
This is my top CMakeLists.txt file:
set(CMAKE_MODULE_PATH "/usr/local/lib/cmake/SFML") # tell cmake where to find find.cmake and config.cmake files
set(SFML_DIR "/usr/local/lib")
find_package(SFML COMPONENTS graphics window system audio REQUIRED) # Look for SFML
I try to add a library ( PCL ) to my cmake, but it throws following error when trying to build:
C/C++ debug|armeabi-v7a : CMake Error at C:\Users\xxx\ndktest\app\src\main\cpp\CMakeLists.txt:48 (find_package):
By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "PCL", but
CMake did not find one.
Could not find a package configuration file provided by "PCL" (requested
version 1.3) with any of the following names:
PCLConfig.cmake
pcl-config.cmake
Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR"
to a directory containing one of the above files. If "PCL" provides a
separate development package or SDK, be sure it has been installed.
Here is how my cmake looks like (I tried setting PLC_DIR already and still have same error message):
cmake_minimum_required(VERSION 3.4.1)
add_library( native-lib SHARED native-lib.cpp )
find_library(log-lib log )
target_link_libraries(native-lib ${log-lib} )
set(PCL_DIR "C:\\Program Files\\PCL 1.6.0\\cmake\\PCLConfig.cmake")
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})
Im running windows 10, and trying to include PCL into a Android project
Any suggestions why its not finding pcl library?
EDIT: I used vcpkg to install the library PCL, and I noticed i was pointing to wrong PCL library. Now I am pointing to the PCL library installed with vcpkg and my CMAKE looks like this now:
cmake_minimum_required(VERSION 3.4.1)
add_library( native-lib SHARED native-lib.cpp )
find_library(log-lib log )
target_link_libraries(native-lib ${log-lib} )
set(PCL_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\packages\\pcl_x86-windows\\share\\pcl")
find_package(PCL 1.3 REQUIRED COMPONENTS)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_LIBRARIES})
When I run this, the error message changes (guess it found PCL but not being able to find a required library (Eigen) for pcl):
C:\Users\xxx\ndktest\app\src\main\cpp\CMakeLists.txt : C/C++ debug|armeabi-v7a : CMake Error at C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:56 (message):
common is required but eigen was not found
Call Stack (most recent call first):
C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:356 (pcl_report_not_found)
C:/Users/xxx/Desktop/pclndk/vcpkg/packages/pcl_x86-windows/share/pcl/PCLConfig.cmake:524 (find_external_library)
CMakeLists.txt:10 (find_package)
I've tried adding set(EIGEN_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\eigen3")
or set(EIGEN_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\eigen3"), but it will still show same error message common is required but eigen was not found. Any ideas?
EDIT2: setting PCL_DIR to set(PCL_DIR "C:\\Users\\xxx\\Desktop\\pclndk\\vcpkg\\installed\\x86-windows\\share\\pcl") also wields same result
I'm trying to link SDL2_net (SDL_net 2.0) to my project via CMake, but after searching around I've yet to find a solution. My CMakeLists.txt currently looks like this:
1 cmake_minimum_required (VERSION 3.7)
2 project (SDL_net_test)
3 include (FindPkgConfig)
4 include (FindSDL_net)
5
6 pkg_search_module (SDL2 REQUIRED sdl2)
7 pkg_search_module (SDL_NET REQUIRED sdl2_net)
8
9 include_directories (${SDL2_INCLUDE_DIRS} ${SDL_NET_INCLUDE_DIRS})
10
11 add_executable (SDL_net_test main.cpp)
12 target_link_libraries (SDL_net_test ${SDL2_LIBRARIES} ${SDL_NET_LIBRARIES})
However, when I attempt to run CMake it gives me the following error(s):
-- Could NOT find SDL_net (missing: SDL_NET_LIBRARIES SDL_NET_INCLUDE_DIRS)
-- Checking for one of the modules 'sdl2_net'
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:659 (message):
None of the required 'sdl2_net' found
Call Stack (most recent call first):
CMakeLists.txt:7 (pkg_search_module)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
SDL_NET_INCLUDE_DIR (ADVANCED)
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
used as include directory in directory /home/neboula/Programming/sandbox/sdl2_net
SDL_NET_LIBRARY (ADVANCED)
linked by target "SDL_net_test" in directory /home/neboula/Programming/sandbox/sdl2_net
-- Configuring incomplete, errors occurred!
See also "/home/neboula/Programming/sandbox/sdl2_net/build/CMakeFiles/CMakeOutput.log".
I have installed the SDL2_net-devel package from my package manager (dnf on Fedora 29), and I've successfully linked SDL2 and SDL2_image previously basing it on this answer, which worked brilliantly. I also found this, but I'm not entirely sure how to use it. How should I go about this?
Since the person who provided an answer only posted a comment about it, I'll put it down here myself.
The solution was seemingly very simple: I had written pkg_search_module (SDL_NET REQUIRED sdl2_net), while it was supposed to be pkg_search_module (SDL_NET REQUIRED SDL2_net).
To easily integrate the SDL2 library and other related libraries (SDL2_net, SDL2_mixer, ...), I developed modern cross-platform CMake modules that can be used as follows:
Clone SDL2 CMake modules inside our project:
git clone https://github.com/aminosbh/sdl2-cmake-modules cmake/sdl2
Add the following lines in your main CMakeLists.txt
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
find_package(SDL2 REQUIRED)
find_package(SDL2_net REQUIRED)
target_link_libraries(${PROJECT_NAME} SDL2::Main SDL2:Net)
You can even specify a custom path to find the SDL2, SDL2_net, ... useful specially on Windows.
cmake .. -DSDL2_PATH="/path/to/sdl2" -DSDL2_NET_PATH="/path/to/sdl2-net"
For sure, you should not forgot to install the specific packages:
# Fedora/RPM
sudo yum install SDL2-devel SDL2_net-devel
# Debian/Ubuntu
sudo apt install libsdl2-dev libsdl2-net-dev
I have this problem.
CMake Error at CMakeLists.txt:14 (find_package): By not providing
"FindTBB.cmake" in CMAKE_MODULE_PATH this project has asked CMake to
find a package configuration file provided by "TBB", but CMake did
not find one.
I could not find a package configuration file provided by "TBB" with any of the following names:
TBBConfig.cmake
tbb-config.cmake
Add the installation prefix of "TBB" to CMAKE_PREFIX_PATH or set
"TBB_DIR" to a directory containing one of the above files. If
"TBB" provides a separate development package or SDK, be sure it has
been installed.
how can i fix this?
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
project(deneme)
set(CMAKE_CXX_STANDARD 11)
include("C:/yunus/Git/inteltbb/tbb/cmake/TBBBuild.cmake")
tbb_build(TBB_ROOT "C:/yunus/Git/inteltbb/tbb" CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
add_executable(deneme main.cpp ToDo.cpp ToDo.h)
TBB does not come by default with a FindTBB.cmake module so the guidelines in the error message are a bit misleading.
If your project provides the corresponding FindTBB.cmake module you need to add the path to it and the path to the TBB installation to your CMake call, i.e.
cmake . -G "<your generator here>" -DTBB_DIR=<path to TBB installation> -DCMAKE_PREFIX_PATH=<path to FindTBB.cmake>
Otherwise you need to download a suitable FindTBB.cmake module e.g. https://github.com/schuhschuh/cmake-basis-modules/blob/develop/FindTBB.cmake
This one uses TBB_ROOT instead of TBB_DIR.
Edit:
Try the binary package integration of TBB first.
Comment the include(...) and the tbb_build(...) command and add
target_link_libraries(deneme ${TBB_IMPORTED_TARGETS})
to your CMakeLists.txt after the add_executable call. Then call
cmake . -G "<your generator here>" -DCMAKE_PREFIX_PATH=<path to your TBB installation>
I am trying to specify the Crypto++ library in my CMakeLists file but I always get an error.
Here is my CMakeLists file:
cmake_minimum_required(VERSION 2.8)
project( Recognition )
find_package( OpenCV REQUIRED )
find_package ( CURL REQUIRED )
find_package ( CRYPTOPP REQUIRED )
add_executable( Recognition Recognition.cpp )
target_link_libraries( Recognition ${OpenCV_LIBS} ${CURL_LIBRARY} ${CRYPTOPP_LIBRARY})
And here is the errors I get:
By not providing "FindCRYPTOPP.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CRYPTOPP",
but CMake did not find one.
Could not find a package configuration file provided by "CRYPTOPP" with any
of the following names:
CRYPTOPPConfig.cmake
cryptopp-config.cmake
Add the installation prefix of "CRYPTOPP" to CMAKE_PREFIX_PATH or set
"CRYPTOPP_DIR" to a directory containing one of the above files. If
"CRYPTOPP" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
Thank you for your help!
CMake doesn't have a module for the Crypto++ library in the package so you have to provide your own. You can try the following(I've used it once) or google for the "Find CryptoPP cmake".
When you are done with the file, place it somewhere and point CMake to search for the file in that location. Suppose you have placed it under your sources directory in contrib/cmake subfolder, then CMake code will be:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/contrib/cmake")
So you set the path for the modules search now you need to use find_package, note, however, that you should provide the package name in the same fashion your .cmake file is named. For example, if you have CryptoPP.cmake, then you should put the following:
find_package ( CryptoPP REQUIRED )