Compiling Caffe with Cmake and Ninja fails - cmake

I tried compiling Caffe on windows with CMAKE_BUILD_SHARED_LIBS option on, but it failed and stated I need to use Ninja. When I set Ninja to 1 in the config file (build_win.cmd), and run the script, it complains and gives the following error message:
CMake Error: CMake was unable to find a build program corresponding to
"Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select
a different build tool. CMake Error: CMAKE_C_COMPILER not set, after
EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after
EnableLanguage
-- Configuring incomplete, errors occurred! ERROR: Configure failed
I don't know what other steps I need to take in order to have a successful compilation process. All I did was to download Ninja, extract it somewhere and add it to my environment variable.
Do I need to install gcc as well?
Update
As suggested in the comments, I checked my path and noticed it was ill-configured. I fixed that now I get these errors, it seems it can't find the needed libraries:
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: C:/Users/Master/gcc/bin/gcc.exe
-- Check for working C compiler: C:/Users/Master/gcc/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Users/Master/gcc/bin/c++.exe
-- Check for working CXX compiler: C:/Users/Master/gcc/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
cmake/Dependencies.cmake:8 (find_package)
CMakeLists.txt:79 (include)
CMake Warning at C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
cmake/Dependencies.cmake:8 (find_package)
CMakeLists.txt:79 (include)
CMake Warning at C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
cmake/Dependencies.cmake:8 (find_package)
CMakeLists.txt:79 (include)
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
cmake/Dependencies.cmake:8 (find_package)
CMakeLists.txt:79 (include)
-- Could NOT find GFlags (missing: GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
-- Could NOT find Glog (missing: GLOG_INCLUDE_DIR GLOG_LIBRARY)
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find Protobuf (missing: Protobuf_LIBRARIES Protobuf_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindProtobuf.cmake:393 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/ProtoBuf.cmake:9 (find_package)
cmake/Dependencies.cmake:48 (include)
CMakeLists.txt:79 (include)
-- Configuring incomplete, errors occurred!
See also "G:/caffe_latest2/build/CMakeFiles/CMakeOutput.log".
See also "G:/caffe_latest2/build/CMakeFiles/CMakeError.log".
ERROR: Configure failed

I found the cause. I had installed GCC on my system, and cmake would try to use that instead of Visual C++ compiler.
All that is needed is just downloading Ninja, placing it in your Path Variable and you are good to go.
Change the needed settings in the build_win.cmd to use Ninja and you are done

Related

CMake can not find Boost Python

I'm trying to build 3d party application using CMake 3.17.5.
I have boost installed by vcpkg (on Windows). I checked I have boost-python installed by vcpkg.
I got the following error in CMake GUI:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: python) (found version "1.75.0")
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args)
cmake/modules/FindUSDMonolithic.cmake:71 (find_package)
cmake/defaults/Packages.cmake:34 (find_package)
CMakeLists.txt:11 (include)
I tried setting CMAKE_TOOLCHAIN_FILE to vcpkg.cmake but it didn't hepled.
NOTE: CMake DOES find boost after I set Boost_INCLUDE_DIR to vcpkg/installed/x64-windows/include/ but it still have this weird error. Without setting this variable CMake can not find boost at all and error is different
You should find Python first:
find_package(Python3 REQUIRED COMPONENTS Development)
target_include_directories(MyTarget SYSTEM PRIVATE ${Python3_INCLUDE_DIRS})
find_package(Boost REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
target_link_libraries(MyTarget PRIVATE Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})

Why is this find_package failing in newer CMake versions?

I am experiencing a problem in a project, when upgrading from CMake 3.8 to 3.14. I have reduced this to the following issue. Note that project is before find_package (the other way around I do not have the issue I am describing).
cmake_minimum_required(VERSION 3.2.1)
find_package(MPI REQUIRED)
project(Test CXX)).
When I build with CMake 3.8, the output is as follows:
build3_8$ cmake ../source/
-- The CXX compiler identification is Intel 17.0.5.20170817
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: (...)/build3_8
With CMake 3.14 I get the following output:
build3_14$ cmake ../source/
CMake Error at (...)/CMake/3.14.0/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:211 (message):
No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()
Call Stack (most recent call first):
(...)/CMake/3.14.0/share/cmake-3.14/Modules/FindMPI.cmake:1672 (find_package_handle_standard_args)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
I wonder why this is happening with the newer CMake version (although FindMPI.cmake is completely different)?
Also, what can I do to solve this? Do I need to write my own config?
(I cannot just change the order of project and find_package, because wrappers are created for the compilers (not my choice, please don't blame me))

Cmake not able to recognize cache entry for FOLLY_LIBRARIES while installing fbtorch using luarocks

I am trying to install fbtorch on linux. However, when I try to run luarocks install fbtorch I get the following error.
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/home/user/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/home/user/torch/install/lib/luarocks/rocks/fbtorch/scm-1"
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /home/user/torch/install
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_fbtorch-scm-1-4920/fbtorch/build/CMakeFiles/CMakeOutput.log".
Now, to fix the REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES) I changed the cmake command to:
cmake -E make_directory build && cd build && cmake .. -DFOLLY_LIBRARIES="/home/user/local/lib" -DFOLLY_INCLUDE_DIR="/home/user/local/include" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
Kindly note that I have compiles and installed folly at /home/user/local/ in appropriate directories
This fixed the FOLLY_INCLUDE_DIR error but its still showing error for FOLLY_LIBRARIES like so:
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
REQUIRED_ARGS (missing: FOLLY_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (FIND_PACKAGE)
What am I missing here? Why did the cmake recognize the cache entry for FOLLY_INCLUDE_DIR but not for FOLLY_LIBRARIES?
Variables listed in "missed" list in find_package() call are not required to be CACHE ones. So, setting cache variable with the same name may do not resolve the problem.
If searched package is actually installed into non-standard location, instead of blindly setting "missing" variables it is better to hint the "Find" script about that location.
Many "Find" scripts describe possible ways of parametrization at the beginning of their code. Aside from this, there are common ways for hinting "Find" scripts about actual location of the package; these ways works for most of scripts. E.g. you may add install location of the package into CMAKE_PREFIX_PATH variable (See that question).
If you look at FindFolly.cmake you can see the line -
SET(FOLLY_LIBRARIES ${FOLLY_LIBRARY})
This means that FOLLY_LIBRARIES is being set but it needs FOLLY_LIBRARY.
So in your command line change -DFOLLY_LIBRARIES to -DFOLLY_LIBRARY

CMake generates error with project statement in CLion

I'm trying to load a project into CLion (using Windows 10 and Cygwin). When CLion processes the CMakeLists.txt file, the following errors are generated
C:\Users\doobop\.CLion2017.2\system\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /cygdrive/m/stream
CMake Error at /cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/CMakeDetermineSystem.cmake:180 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
CMakeLists.txt:12 (project)
-- The C compiler identification is GNU 5.4.0
CMake Error at /cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/CMakeDetermineCCompiler.cmake:175 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
CMakeLists.txt:12 (project)
-- The CXX compiler identification is GNU 5.4.0
CMake Error at /cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/CMakeDetermineCXXCompiler.cmake:170 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
CMakeLists.txt:12 (project)
CMake Error at /cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/CMakeDetermineRCCompiler.cmake:55 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
/cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/Platform/CYGWIN-GNU.cmake:50 (enable_language)
/cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/Platform/CYGWIN-GNU-C.cmake:2 (__cygwin_compiler_gnu)
/cygdrive/c/Users/doobop/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/CMakeCInformation.cmake:48 (include)
CMakeLists.txt:12 (project)
What is at line 12?
project( SWP )
Why would the project assignment cause all these errors?

CGAL cmake on cygwin fails

I'm trying to compile CGAL 4.5 on cygwin (windows 7). i have gcc-core, gcc-g++ and gmp installed but when i try to run cmake i get following error:
$ cmake .
-- The CXX compiler identification is GNU 4.8.3
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeCXXCompiler.cmake
-- The C compiler identification is GNU 4.8.3
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeCCompiler.cmake
CMake Warning at /usr/share/cmake-2.8.11.2/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-2.8.11.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:7 (project)
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeRCCompiler.cmake
-- Check for working CXX compiler: /usr/bin/c++.exe
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCXXCompiler.cmake:40 (try_compile):
Unknown extension ".cxx" for file
/home/metalab/CGAL-4.5/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
try_compile() works only for enabled languages. Currently these are:
C CXX RC
See project() command to enable other languages.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
-- Check for working CXX compiler: /usr/bin/c++.exe -- broken
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test
program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
-- Configuring incomplete, errors occurred!
i already tried playing with CMAKE_LEGACY_CYGWIN_WIN32 but no success.
I ran in a similar error. cmake seemed to not be able to find anything from Cygwin.
The fact is that you need to run the Cygwin version of cmake. If you installed cmake from an installer and it went under C:\Program Files, you have the wrong cmake and it won't find most everything which it should otherwise find.