How to avoid update checks with CMake FetchContent? - c++

all.
I decided to use the new cmake macro to download external dependencies.
I took the sample code from the documentation for the Catch2 library.
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.4
)
FetchContent_GetProperties(Catch2)
if(NOT Catch2_POPULATED)
FetchContent_Populate(Catch2)
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
endif()
The solution works great, except for the ability to restart the cmake when I am offline (no wifi and mobile network only me and my laptop).
I get the following error:
[0/7] Performing update step for 'catch2-populate'
fatal: «https://github.com/catchorg/Catch2.git/» недоступно: Could not resolve host: github.com
CMake Error at /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake:97 (execute_process):
execute_process failed command indexes:
1: "Child return code: 128"
FAILED: catch2-populate-prefix/src/catch2-populate-stamp/catch2-populate-update
cd /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-src && /usr/local/Cellar/cmake/3.20.1/bin/cmake -P /Users/evgeny.proydakov/repository/ihft/build/_deps/catch2-subbuild/catch2-populate-prefix/tmp/catch2-populate-gitupdate.cmake
ninja: build stopped: subcommand failed.
CMake Error at /usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1012 (message):
Build step for catch2 failed: 1
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141:EVAL:2 (__FetchContent_directPopulate)
/usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1141 (cmake_language)
/usr/local/Cellar/cmake/3.20.1/share/cmake/Modules/FetchContent.cmake:1184 (FetchContent_Populate)
.cmake/icmake.cmake:46 (FetchContent_MakeAvailable)
CMakeLists.txt:10 (include)
-- Configuring incomplete, errors occurred!
Is it possible to download dependency one time, check revision and don't try to connect each time to remote server?

The documentation for FetchContent_Populate says you can get exactly what you want with the FETCHCONTENT_UPDATES_DISCONNECTED cache variable:
FETCHCONTENT_UPDATES_DISCONNECTED
... This ... disables the
update stage. Therefore, if content has not been downloaded
previously, it will still be downloaded when this option is enabled.
This can speed up the configure stage... It is OFF by default.
So set this one to ON globally, or for Catch2 only, set the variable FETCHCONTENT_UPDATES_DISCONNECTED_Catch2 to ON.

Related

How to use CMake to compile SharkML library? [duplicate]

I am trying to build ripple by following the build guide on GitHub, but boost is continuously throwing some unknown error. Boost is installed and running. I installed boost_1_71_0 as described by the build guide.
/home/usman/Downloads/clion-2020.1.2/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /home/usman/Desktop/ripple/rippled
-- Using 4 cores for ExternalProject builds.
-- rippled version: 1.6.0
-- NIH-EP cache path: /home/usman/Desktop/ripple/rippled/.nih_c/unix_makefiles/GNU_9.3.0/Debug
-- using [01bd5a2646cda78ee09d2067c287c8f89872736d] as build container tag...
-- docker local user id: 1000
-- docker local group id: 1000
-- BOOST_ROOT: /usr/local
-- BOOST_LIBRARYDIR: /usr/local/lib/
CMake Error at /usr/local/lib/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
Found package configuration file:
/usr/local/lib/cmake/boost_chrono-1.71.0/boost_chrono-config.cmake
but it set boost_chrono_FOUND to FALSE so package "boost_chrono" is
considered to be NOT FOUND. Reason given by package:
No suitable build variant has been found.
The following variants have been tried and rejected:
* libboost_chrono.so.1.71.0 (shared, Boost_USE_STATIC_LIBS=ON)
* libboost_chrono.a (shared runtime, Boost_USE_STATIC_RUNTIME=ON)
Call Stack (most recent call first):
/usr/local/lib/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
Builds/CMake/deps/FindBoost.cmake:273 (find_package)
Builds/CMake/deps/Boost.cmake:50 (find_package)
CMakeLists.txt:43 (include)
-- Configuring incomplete, errors occurred!
See also "/home/usman/Desktop/ripple/rippled/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/home/usman/Desktop/ripple/rippled/cmake-build-debug/CMakeFiles/CMakeError.log".
[Finished]
There is a similar question here, but your issue appears to be the opposite case.
The important section of the error is here:
No suitable build variant has been found.
The following variants have been tried and rejected:
* libboost_chrono.so.1.71.0 (shared, Boost_USE_STATIC_LIBS=ON)
* libboost_chrono.a (shared runtime, Boost_USE_STATIC_RUNTIME=ON)
It shows you what libraries were found, and even gives the reason why they were rejected. All of the libraries found on your machine are shared libraries. However, your CMake configuration indicates you do not want to use shared libraries (Boost_USE_STATIC_LIBS=ON and Boost_USE_STATIC_RUNTIME=ON). To fix the error, you have two options:
Set Boost_USE_STATIC_LIBS to OFF and Boost_USE_STATIC_RUNTIME to OFF:
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost ... )
Build the static Boost libraries also, so not only the shared libraries are available on your machine.

Installing darknet on Windows 10

I'm trying to install darknet on Windows 10 using the instructions in the following link:
https://github.com/kiyoshiiriemon/yolov4_darknet/tree/b504cc3b4e47617c2cf28c37a6581fc733854f06
However, I got the following error through Windows PowerShell:
-- Configuring x64-windows CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:106 (message):
Command failed: ninja -v
Working Directory: C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\Users\hedey\vcpkg\buildtrees\opencv4\config-x64-windows-out.log
Call Stack (most recent call first): scripts/cmake/vcpkg_configure_cmake.cmake:312 (vcpkg_execute_required_process) ports/opencv4/portfile.cmake:280 (vcpkg_configure_cmake) scripts/ports.cmake:135 (include)
Error: Building package opencv4:x64-windows failed with: BUILD_FAILED Please ensure you're using the latest portfiles with `.\vcpkg update`, then submit an issue at https://github.com/Microsoft/vcpkg/issues including: Package: opencv4:x64-windows Vcpkg version:
2020.06.15-nohash
Additionally, attach any relevant sections from the log files above.
I'm totally stuck getting a solution for this issue.
This is the complete log file can be found in the following link:
https://www.dropbox.com/s/f30g354t26n1mvg/log_files.zip?dl=0
I noticed that the png.h file exists at C:\Users\hedey\vcpkg\installed\x64-windows\include\libpng16 instead of C:\Users\hedey\vcpkg\installed\x64-windows\include\libpng (which is where it's being searched for as in the CMakeError file.
Also, both of png.h and pthread.h exist at C:\Users\hedey\vcpkg\installed\x64-windows\include.
EDIT:
The above problem was solved after I updated vcpkg (using git pull).
However, I got another error as follows:
FAILED: modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.obj
cmd.exe /C "cd /D C:\Users\hedey\vcpkg\buildtrees\opencv4\x64-windows-dbg\modules\core\CMakeFiles\cuda_compile_1.dir\src\cuda && C:\Users\hedey\vcpkg\downloads\tools\cmake-3.18.4-windows\cmake-3.18.4-win32-x86\bin\cmake.exe -E make_directory C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-dbg/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/. && C:\Users\hedey\vcpkg\downloads\tools\cmake-3.18.4-windows\cmake-3.18.4-win32-x86\bin\cmake.exe -D verbose:BOOL=OFF -D build_configuration:STRING=Debug -D generated_file:STRING=C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-dbg/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.obj -D generated_cubin_file:STRING=C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-dbg/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.obj.cubin.txt -P C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-dbg/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.obj.Debug.cmake"
nvcc fatal : Unsupported gpu architecture 'compute_30'
CMake Error at cuda_compile_1_generated_gpu_mat.cu.obj.Debug.cmake:220 (message):
Error generating
C:/Users/hedey/vcpkg/buildtrees/opencv4/x64-windows-dbg/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.obj
I faced this problem before with the cmake gui, and it can be solved by setting CUDA_ARCH_BIN to the value that's suitable to the GPU (6.1 in my case).
However, I don't know how to solve it in case of installing using vcpkg. I tried to find a file where I can edit, and I think it's 'OpenCVDetectCUDA.cmake'. I tried some edits to that file, and I'm still getting the same error. Could you pls help me overcome this issue?

How to use Facebook Wangle in Windows with vcpkg

When I install Wangle with vcpkg install wangle I see the below message:
The following packages are already installed:
wangle[core]:x64-windows
Starting package 1/1: wangle:x64-windows
Package wangle:x64-windows is already installed
Elapsed time for package wangle:x64-windows: 3.573 ms
Total elapsed time: 4.733 ms
The package wangle:x64-windows provides CMake targets:
find_package(wangle CONFIG REQUIRED)
target_link_libraries(main PRIVATE wangle::wangle)
But when I write my own CMakeLists.txt and write find_package(wangle CONFIG REQUIRED) . and run with
cmake .. -DCMAKE_TOOLCHAIN_FILE='C:\Users\sooro\Documents\vcpkg\vcpkg\scripts\buildsystems\vcpkg.cmake'
I see the below error:
CMake Error at C:/Users/sooro/Documents/vcpkg/vcpkg/installed/x64-windows/share/wangle/wangle-config.cmake:22 (message):
File or directory
C:/Users/sooro/Documents/vcpkg/vcpkg/installed/x64-windows/lib/cmake/wangle
referenced by variable WANGLE_CMAKE_DIR does not exist !
Call Stack (most recent call first):
C:/Users/sooro/Documents/vcpkg/vcpkg/installed/x64-windows/share/wangle/wangle-config.cmake:39 (set_and_check)
C:/Users/sooro/Documents/vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake:258 (_find_package)
CMakeLists.txt:35 (find_package)
-- Configuring incomplete, errors occurred!
As you can see in [wangle] find_package(wangle) failed issue on vcpkg, this problem is for bug on port, and after this bug was resolved, the above error (WANGLE_CMAKE_DIR does not exist) was resolved, and the library worked properly.
So as you can see in the install message below, the command is working correctly for using Wangle in Windows with vcpkg in all CMake base projects.
find_package(wangle CONFIG REQUIRED)
target_link_libraries(main PRIVATE wangle::wangle)

Gnuradio crash after installing own block

i am trying to install a own Block for gnuradio. I go through this(http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_GNU_Radio_in_C++) tutorial. But in Step 5, Installing, I get some problems.
I installed it, but i didnt see the Block in gnuradio-companion.
I added the path:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/
export GRC_BLOCKS_PATH=/usr/local/share/gnuradio/grc/blocks/
Now i can see the Block: But if I want to use it, the gnuradio-companion crash.
^[[A^[[BFatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
Gnuradio Version: 3.7.10.1
OS: OS X El Capitan
What could be the problem? Wrong/Missing path? Mistake in the program?
/edit2: To add a Block, writen in python works fine(With the tutorial: http://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_GNU_Radio_in_Python)
/edit: When I install it, I get many warnings when i use cmake:
-- Build type not specified: defaulting to release.
-- Boost version: 1.59.0
-- Found the following Boost libraries:
-- filesystem
-- system
Checking for GNU Radio Module: RUNTIME
* INCLUDES=/opt/local/include
* LIBS=/opt/local/lib/libgnuradio-runtime.dylib;/opt/local/lib/libgnuradio-pmt.dylib
GNURADIO_RUNTIME_FOUND = TRUE
CMake Warning (dev) at cmake/Modules/GrTest.cmake:45 (get_target_property):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "test-tutorialCPP".
Use the target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
Call Stack (most recent call first):
lib/CMakeLists.txt:77 (GR_ADD_TEST)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Using install prefix: /usr/local
-- Building for version: v1.0-compat-xxx-xunknown / 1.0.0git
--
-- Checking for module SWIG
-- Found SWIG version 3.0.10.
CMake Warning (dev) at cmake/Modules/GrTest.cmake:45 (get_target_property):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target
"gnuradio-tutorialCPP". Use the target name directly with
add_custom_command, or use the generator expression $<TARGET_FILE>, as
appropriate.
Call Stack (most recent call first):
python/CMakeLists.txt:44 (GR_ADD_TEST)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at cmake/Modules/GrTest.cmake:45 (get_target_property):
Policy CMP0045 is not set: Error on non-existent target in
get_target_property. Run "cmake --help-policy CMP0045" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
get_target_property() called with non-existent target
"/opt/local/bin/python2.7".
Call Stack (most recent call first):
python/CMakeLists.txt:44 (GR_ADD_TEST)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at cmake/Modules/GrTest.cmake:45 (get_target_property):
Policy CMP0045 is not set: Error on non-existent target in
get_target_property. Run "cmake --help-policy CMP0045" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
get_target_property() called with non-existent target
"/Users/abc/dev/gnuradio/modul/gr-tutorialCPP/python/qa_my_qpsk_demod_cb.py".
Call Stack (most recent call first):
python/CMakeLists.txt:44 (GR_ADD_TEST)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/abc/dev/gnuradio/modul/gr-tutorialCPP/build
This happens when GNU Radio and your module are linked against different Python libraries.
On OSX, there is usually a system installation and another one from Homebrew or MacPorts. Try linking everything against the Homebrew/MacPorts libraries.
You seem to have a Python installation in /opt/local. Use cmake to reconfigure your module and point PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to the installation in /opt.

QiBuild/CMake cannot not find BOOST_FILESYSTEM

I'm trying to build the C++ examples from Aldebaran like helloworld and sayhelloworld, but qiBuild keeps saying it cannot not find BOOST_FILESYSTEM. Boost is installed and working, I tested it with some other projects in Visual Studio.
This is the error after running qibuild configure -c atom1145:
[WARN ]: Nested worktrees detected:
d:\ald_sdk\naoqi-sdk-1.14.5-win32-vs2010\doc\examples is already in a worktree
(in d:\ald_sdk)
Current build worktree: d:\ald_sdk\naoqi-sdk-1.14.5-win32-vs2010\doc\examples
Using toolchain: atom1145
Build type: Debug
* (1/1) Configuring sayhelloworld
-- Using qibuild 3.7.1
-- Binary: sayhelloworld
CMake Error at D:/Programs/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find BOOST_FILESYSTEM (missing: BOOST_FILESYSTEM_LIBRARIES)
Call Stack (most recent call first):
D:/Programs/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
d:/Programs/Python27/share/cmake/qibuild/find.cmake:361 (find_package_handle_standard_args)
d:/Programs/Python27/share/cmake/qibuild/find.cmake:269 (_qi_call_fphsa)
d:/Programs/Python27/share/cmake/qibuild/modules/boostutils.cmake:39 (export_lib)
d:/Programs/Python27/share/cmake/qibuild/modules/boost_filesystem-config.cmake:9 (boost_flib)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:80 (find_package)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:94 (_qi_use_lib_get_deps)
d:/Programs/Python27/share/cmake/qibuild/internal/uselib.cmake:158 (_qi_use_lib_get_deps)
d:/Programs/Python27/share/cmake/qibuild/stage.cmake:246 (_qi_use_lib_internal)
CMakeLists.txt:17 (qi_use_lib)
-- Configuring incomplete, errors occurred!
See also "D:/ALD_SDK/naoqi-sdk-1.14.5-win32-vs2010/doc/examples/core/sayhelloworld/build-atom1145/CMakeFiles/CMakeOutput.log".
See also "D:/ALD_SDK/naoqi-sdk-1.14.5-win32-vs2010/doc/examples/core/sayhelloworld/build-atom1145/CMakeFiles/CMakeError.log".
[ERROR]: ConfigureFailed Error occurred when configuring project sayhelloworld
After Boost compiled, I got the following paths:
The following directory should be added to compiler include paths:
D:/Programs/boost_1_57_0
The following directory should be added to linker library paths:
D:\Programs\boost_1_57_0\stage\lib
These are not the default path's and I guess that's causing some problems.
In the CMakeCache.txt I found that the Boost entries were "cleared":
//The directory containing a CMake configuration file for BOOST.
BOOST_DIR:PATH=d:/Programs/Python27/share/cmake/qibuild/modules
//The directory containing a CMake configuration file for BOOST_FILESYSTEM.
BOOST_FILESYSTEM_DIR:PATH=d:/Programs/Python27/share/cmake/qibuild/modules
//Cleared.
BOOST_FILESYSTEM_EXECUTABLE:STRING=
//Cleared.
BOOST_FILESYSTEM_EXECUTABLE_DEBUG:STRING=
//Cleared.
Boost_DEFINITIONS:STRING=
//Cleared.
Boost_EXECUTABLE:STRING=
//Cleared.
Boost_EXECUTABLE_DEBUG:STRING=
//Boost filesystem library (debug)
Boost_FILESYSTEM_LIBRARY_DEBUG:FILEPATH=Boost_FILESYSTEM_LIBRARY_DEBUG-NOTFOUND
//Boost filesystem library (release)
Boost_FILESYSTEM_LIBRARY_RELEASE:FILEPATH=Boost_FILESYSTEM_LIBRARY_RELEASE-NOTFOUND
//Path to a file.
Boost_INCLUDE_DIR:PATH=D:/ALD_SDK/naoqi-sdk-1.14.5-win32-vs2010/include
//Cleared.
Boost_INCLUDE_DIRS:STRING=
//Cleared.
Boost_LIBRARIES:STRING=
I tried to add some variables to the CMakeLists.txt like this, but it didn't help:
set(Boost_DEBUG true)
set(BOOST_ROOT "D:/Programs/boost_1_57_0")
set(BOOST_INCLUDEDIR "D:/Programs/boost_1_57_0/boost")
set(BOOST_LIBRARYDIR "D:/Programs/boost_1_57_0/stage/lib")
Any help would be really appreciated!
This was the solution from the Aldebaran support:
It seems to have some incompatibilty between the NAOqi 1.14.5 C++ SDK for windows and the latest version of qibuild.
On my side I have tested with the latest version of qibuild and it gave me the same error as yours.
I will let our team now to update the documentation.
In the mean time I can propose you a workaround, ie, uninstall qibuild by using
pip uninstall qibuild and reinstall a version that is working with the NAOqi 1.14.5 C++ SDK for windows
pip install qibuild==3.5.1
This one should be working.