I'm struggling to build this github repo: https://github.com/thorbenk/saliencyfilters. Running the suggested build line doesn't work. Running cmake .. from the build/ dir, I get the following error:
CMake Error at CMakeLists.txt:6 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Yet I do provide "FindOpenCV.cmake" in the CMAKE_MODULE_PATH -- here it is in the CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project(saliency)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
find_package( OpenCV REQUIRED )
find_package( TBB )
find_package( PythonLibs REQUIRED )
find_package( Boost COMPONENTS python REQUIRED )
find_package( VIGRA REQUIRED )
add_definitions( -std=c++11 )
add_subdirectory (src)
Note the author specifically requested not to be bothered with install issues, so I'm requesting help here :)
Related
My CMakeLists.txt file for my old libigl testing project contains the piece below:
project(libigl)
set(LIBIGL_HOME $ENV{HOME}/apps/libigl)
set(CMAKE_PREFIX_PATH ${LIBIGL_HOME})
set(CMAKE_MODULE_PATH ${LIBIGL_HOME}/cmake)
find_package(${PROJECT_NAME} CONFIGS libigl.cmake REQUIRED)
if(${PROJECT_NAME}_FOUND)
message("-- Found ${PROJECT_NAME}")
else()
message(FATAL_ERROR "${PROJECT_NAME} is not found")
endif()
I tried to build this project with the new version 2.4.0 of the libigl library and got this message:
CMake Error at /home/hekto/apps/libigl/cmake/libigl.cmake:5 (message):
You included libigl.cmake directly from your own project. This behavior is
not supported anymore. Please add libigl to your project via
add_subdirectory(<path_to_libigl>). See the libigl example project for
more information: https://github.com/libigl/libigl-example-project/
Call Stack (most recent call first):
CMakeLists.txt:43 (find_package)
So, they recommend to use the add_subdirectory command for client projects. I looked at the CMakeLists.txt file from the recommended GitHub example project and couldn't find the add_subdirectory command:
cmake_minimum_required(VERSION 3.16)
project(example)
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Libigl
include(libigl)
# Enable the target igl::glfw
igl_include(glfw)
# Add your project files
file(GLOB SRC_FILES *.cpp)
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC igl::glfw)
How should I build with the new version 2.4.0 of the libigl?
OS: Ubuntu 20.04.5 LTS
Compiler: g++ (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
I am trying to build a c++ project with Netbeans in Windows but during the pre-built process an error relating to the CMakeLists I used comes out. Here is the error output:
cd 'E:\Yifan\Hiwi-FSD\FluCo1\Sourcecode\branch_HighLevelUmstrukturierung\High-Level\FCU-Interface\build-dev'
C:/msys64/mingw64/bin/cmake.exe -G Unix Makefiles -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/nbproject/private/tools/localhost/MinGW_1/gcc.exe -DCMAKE_CXX_COMPILER=E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/nbproject/private/tools/localhost/MinGW_1/g++.exe -DCMAKE_C_FLAGS_DEBUG=-g3 -gdwarf-2 -DCMAKE_CXX_FLAGS_DEBUG=-g3 -gdwarf-2 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPROJECT_SUFFIX=-dev -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=TRUE -DCMAKE_PREFIX_PATH=E:\Yifan\Hiwi-FSD\FluCo1\Libraries\fsd-libs\trunk\build-dev\install ..
-- SVN Revision Number is
-- FCU-Interface-dev PROJECT_SOURCE_DIR = E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface
-- FCU-Interface-dev Build directory = E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/build-dev
-- Checking for module 'fsd-io-dev'
-- Package 'fsd-io-dev', required by 'virtual:world', not found
CMake Error at C:/msys64/mingw64/share/cmake-3.20/Modules/FindPkgConfig.cmake:561 (message):
A required package was not found
Call Stack (most recent call first):
C:/msys64/mingw64/share/cmake-3.20/Modules/FindPkgConfig.cmake:783 (_pkg_check_modules_internal)
CMakeLists.txt:17 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
See also "E:/Yifan/Hiwi-FSD/FluCo1/Sourcecode/branch_HighLevelUmstrukturierung/High-Level/FCU-Interface/build-dev/CMakeFiles/CMakeOutput.log".
PRE-BUILD FAILED (exit value 1, total time: 5s)
And the CMakelists file is shown below:
cmake_minimum_required(VERSION 3.12)
SET(FSD_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../Libraries)
include("${FSD_LIB_DIR}/CMakeSuffixBase.cmake")
project("FCU-Interface${PROJECT_SUFFIX}" VERSION 0.1)
SET(ENV{PKG_CONFIG_PATH} ${FSD_LIB_DIR}/fsd-libs/trunk/build${PROJECT_SUFFIX}/install/lib/pkgconfig)
include("${FSD_LIB_DIR}/CMakeBase.cmake")
include(FindPkgConfig)
Subversion_GET_REVISION(${CMAKE_SOURCE_DIR} SVN_REV)
message(STATUS "SVN Revision Number is ${SVN_REV}")
message(STATUS "${PROJECT_NAME} PROJECT_SOURCE_DIR = ${PROJECT_SOURCE_DIR}")
message(STATUS "${PROJECT_NAME} Build directory = ${CMAKE_BINARY_DIR}")
find_package(PkgConfig REQUIRED)
pkg_check_modules(FSD_IO REQUIRED IMPORTED_TARGET fsd-io${PROJECT_SUFFIX})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION "${PROJECT_VERSION}+${SVN_REV}"
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../Framework_Seitz>
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Threads::Threads
PkgConfig::FSD_IO)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
The PROJECT_SUFFIX is -dev. I reckon that the problem is, the file "fsd-io-dev.pc" cannot be found. But I already have it under the directory "E:\Yifan\Hiwi-FSD\FluCo1\Libraries\fsd-libs\trunk\build-dev\install\lib\pkgconfig". What should I do to let it be found? Thanks in advance!!!
I'm operating under a new learning curve here with c++ and using CMake in Visual Studio. Here is the partial code up until the point where I receive the error:
project(libfranka
VERSION 0.8.0
LANGUAGES CXX
)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(MSVC)
add_compile_options(/W0)
else()
add_compile_options(-Wall -Wextra)
endif()
set(THIRDPARTY_SOURCES_DIR "${CMAKE_SOURCE_DIR}/3rdparty" CACHE PATH
"Directory for third-party sources")
## Dependencies
find_package(Poco REQUIRED COMPONENTS Net Foundation)
find_package(Eigen3 REQUIRED)
Once it hits the first find_package is where I encounter the error:
Here is the code within FindPoco.cmake.
find_package(Poco COMPONENTS ${Poco_FIND_COMPONENTS} CONFIG QUIET)
if(Poco_FOUND)
return()
endif()
find_path(Poco_INCLUDE_DIR Poco/Poco.h)
mark_as_advanced(FORCE Poco_INCLUDE_DIR)
foreach(component ${Poco_FIND_COMPONENTS})
set(component_var "Poco_${component}_LIBRARY")
find_library(${component_var} Poco${component})
mark_as_advanced(FORCE ${component_var})
if(${component_var})
set(Poco_${component}_FOUND TRUE)
list(APPEND Poco_LIBRARIES ${component})
if(NOT TARGET Poco::${component})
add_library(Poco::${component} SHARED IMPORTED)
set_target_properties(Poco::${component} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${Poco_INCLUDE_DIR}
IMPORTED_LOCATION ${${component_var}}
)
endif()
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Poco
FOUND_VAR Poco_FOUND
REQUIRED_VARS Poco_INCLUDE_DIR Poco_LIBRARIES
VERSION_VAR Poco_VERSION
HANDLE_COMPONENTS
)
I installed poco using vcpkg in a directory titled vcpkg. Within the vcpkg directory is the libfranka directory, which houses the CMakeLists.txt file that I compile in Visual Studio. Here is an image of that directory:
Finally, here is the tutorial that I am using: https://frankaemika.github.io/docs/installation_windows.html#building-from-source
EDIT:
Per the link I followed the instructions for solving the build dependencies and here is an image of that:
Then I ran the CMakeLists.txt again and in the CMake Settings this is what I see:
Note also that I ran through the install of poco again and I noticed this and am unsure if it could be the source of the problem or if it means nothing (again, this was the out put after running vcpkg install poco):
After this I still receive the same error.
Does anyone see what it is that I am doing incorrectly?
Thank you!
I get the error:
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindSDL2_ttf.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2_ttf",
but CMake did not find one.
Could not find a package configuration file provided by "SDL2_ttf" with any
of the following names:
SDL2_ttfConfig.cmake
sdl2_ttf-config.cmake
Add the installation prefix of "SDL2_ttf" to CMAKE_PREFIX_PATH or set
"SDL2_ttf_DIR" to a directory containing one of the above files. If
"SDL2_ttf" provides a separate development package or SDK, be sure it has
been installed.
Here is what my cmake file looks like:
cmake_minimum_required(VERSION 3.14)
project(Smithereens)
set(CMAKE_CXX_STANDARD 17)
add_executable(Smithereens main.cpp)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
find_package(SDL2_ttf REQUIRED)
include_directories(${SDL2_ttf_INCLUDE_DIRS})
target_link_libraries(Smithereens ${SDL2_LIBRARIES} ${SDL2_ttf_LIBRARIES})
Both SDL2 and SDL2_ttf are installed on my machine, I'm sure I'm just linking incorrectly, learning CMake has been a huge headache for me.
This works pretty well for me, Ubuntu 18.04.
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
PKG_SEARCH_MODULE(SDL2TTF REQUIRED SDL2_ttf>=2.0.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE
include ${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE
${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} ${SDL2TTF_LIBRARIES})
I'm trying to write a CMake file which needs cuda functionalities. Consulting this answer, I added this line to my CMakeLists.txt:
set(CMAKE_CUDA_COMPILER /usr/local/cuda-9.2/bin/nvcc)
But when using cmake command it still complains:
yuqiong#yuqiong-G7-7588:/media/yuqiong/DATA/alexnet/src/cpp/train$ cmake .
CMake Error: Could not find cmake module file: CMakeDetermineCUDACompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CUDA_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file: /media/yuqiong/DATA/alexnet/src/cpp/train/CMakeFiles/3.5.1/CMakeCUDACompiler.cmake
CMake Error: Could not find cmake module file: CMakeCUDAInformation.cmake
CMake Error: Could not find cmake module file: CMakeTestCUDACompiler.cmake
-- Configuring incomplete, errors occurred!
See also "/media/yuqiong/DATA/alexnet/src/cpp/train/CMakeFiles/CMakeOutput.log".
Which seems confusing, as I don't know where else to set the environment variable? Any idea why the set command does not help cmake find the nvcc compiler?
Just in case helpful, here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CUDA_COMPILER /usr/local/cuda-9.2/bin/nvcc)
project(train LANGUAGES CXX CUDA)
set(CMAKE_CXX_STANDARD 14)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable(train train.cu)
target_link_libraries( train ${OpenCV_LIBS} )
Actually, you need CMake 3.8 on Linux to use project(train LANGUAGES CUDA). Before, you need the old way with:
FindPackage(CUDA)
And manually add the libraries.
The failure is because there is no native support for CUDA in your CMake version, use the old method.
For anyone stumbled upon this question, here is the final CMakeLists.txt file I've used:
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CUDA_COMPILER /usr/local/cuda-9.2/bin/nvcc)
project(train)
include(FindCUDA)
set(CMAKE_CXX_STANDARD 14)
find_package( OpenCV REQUIRED )
find_package(CUDA REQUIRED)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -gencode arch=compute_30,code=sm_30)
include_directories( ${OpenCV_INCLUDE_DIRS} )
cuda_add_executable(train train.cu)
target_link_libraries( train ${OpenCV_LIBS} )