using CMake to build Google Test - c++

I am trying to use CMake to build Google Test.
As mentioned in the README of Google Test,
I have issued following commands:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake D:\gtest-1.6.0 # (in the README this was set as:cmake ${GTEST_DIR}, but since on my machine D:\gtest-1.6.0 is where I have downloaded gtest, I have used that in command prompt.
And here is the error I get:
Any help? any help would be greatly appreciated as I am stuck with it and can't move forward...... Thanks.
ps. I have Visual Studio 10 installed on my machine.

If you use Visual c++ compiler with cmake you must launch it from the Visual c++ command prompt. Otherwise cmake will not found your compiler.

Related

Building .SLN files on Windows without Visual Studio?

I have recently been trying to set up my CMake environment and some 'hello world' code in C++. I added a CMakeLists.txt and added my configurations, but when I ran cmake . in the command line, something was different from all of the tutorials.
The people on the tutorials were using a Unix based system, so the command cmake . was producing a 'makefile'. They then built the makefile using the command make.
Since I'm on windows, it generated a msvc .sln file instead of a makefile. My question is - how can I build the .sln file, similar to how they did it on Linux? I want to do it without Visual Studio 2019 and preferably in the command prompt.
I have tried searching for this question, but haven't found what I'm looking for. Thank you in advance.
First of all, you should never do an in-tree build with cmake .. It invites problems in the form of name clashes and makes it nearly impossible to get a clean rebuild.
If you're using a recent version of CMake (which you should be), the standard way to build a project varies on whether the backend generator is single-config or multi-config.
If it's single-config (like Make or Ninja), then the commands are:
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S /path/to/sources -B /path/to/build
$ cmake --build /path/to/build
The directory /path/to/build doesn't need to exist when you invoke CMake. If you wanted a Debug build, rather than Release, you would just replace that in the first line. You should never run a single-config generator without setting CMAKE_BUILD_TYPE.
If it's multi-config, like Visual Studio, then the commands are:
$ cmake -G "Visual Studio 16 2019" -A x64 -Thost=x64 -S /path/to/sources -B /path/to/build
$ cmake --build /path/to/build --config Release
The major difference here is that the config is specified in the second (build) command, rather than the first (configure).

How do you compile V8 with Visual Studio?

I've been trying to compile V8. I've obtained a copy of the v8-master folder from GitHub, but I can't figure out how to compile it. A lot of the documentation I could find online are conflicting.
From what I've gathered, it appears as if my best chance of getting it to compile (out of the various methods I've found, though I couldn't get any of them to work) is to create the project files by calling the gyp_v8 script (located in the build folder of v8-master). But it simply gives me File "gyp_v8", line 86 print 'Error running GYP' SyntaxError: Missing parentheses in call to 'print'. From there, I tried to install Gyp (since according to the documentation, I'm led to believe that's what's causing the error). That required me to install depot_tools and do gclient sync. That failed with the error Error: client not configured; see 'gclient config'. And gclient config fails with the erropr gclient.py: error: Inconsistency arguments. Use either --spec or one or 2 args.
Honestly, I'm lost at this point. Is there any way I could just use CMake or something? Or at least a build tutorial that doesn't assume you have a bunch of Google-specific build tools involved?
Confirm Git is installed. git 2.2.1+ recommended.
Temporarily, disable Windows Indexing.
Install "Microsoft Visual C++ 2008 Redistributable Package"
Run bat file as administrator
Bat file:
#echo on
CD /D %~dp0
SET DEPOT_TOOLS_WIN_TOOLCHAIN=0
SET DEPOT_TOOLS=%CD%/depot_tools
SET PYTHONHOME=%DEPOT_TOOLS%/python276_bin
SET PYTHONPATH=%CD%/v8/build/gyp
SET PATH=%DEPOT_TOOLS%;%PYTHONHOME%;%PATH%
SET GYP_DEFINES=target_arch=x64
REM SET GYP_DEFINES=target_arch=x64 component=shared_library v8_use_snapshot=false
REM About GYP_DEFINES: https://github.com/v8/v8/wiki/Building-with-Gyp
IF EXIST %DEPOT_TOOLS% (
ECHO Updating depot_tools
CD %DEPOT_TOOLS%
CALL git pull
CD ..
) ELSE (
ECHO Getting depot_tools
CALL git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
)
CALL gclient
CALL gclient config https://chromium.googlesource.com/v8/v8.git
CALL gclient sync
I've previously built V8 from source for Visual Studio 2010 and then for Visual Studio 2013. Very time consuming tasks in both cases. However for Visual Studio 2017 I found that the headers and prebuilt libraries are available from NuGet. I no longer needed to build from source.

How to build cmake-project with atom text editor?

I've installed packages build and build-make, and it's not obvious what to do next.
Build-tools package is bugged and impossible to install now.
I have cmake project, sucsessfully build in different IDE: QTCreator, VisualStudio, via bash. So i want to make it with atom, and there is no instruction how to use it's build-make package. Documentation to this package is empty.
in bash i call: cmake ../src from my build dir.
So in .atom-build.json i put this command and point directory as working - and nothing happens, on f9 i've god "Cannot read peoperty "exec" or undefined"
Actually, there is a cmake package for Atom.
Here you go:
https://atom.io/packages/build-cmake
Firstly, CMake and make are two different things.
What you are looking for is a CMake plugin for Atom, of which there are currently none. (Some for syntax highlighting but none for running graphically...)
If you have CMake working in other IDEs then you shouldn't have a problem running CMake from the command line:
cd /path/to/project
cmake .

Visual Studio Compile Source

I would like to compile the source:
https://github.com/Benjamin-Dobell/Heimdall
I'm have downloaded the source launch visual studio and open heimdall/main.cpp
However when trying F5 nothing happening.
Please help
Have a look at the Readmes (e.g. Win32):
Appendix B - Installing Heimdall Suite from Source
Heimdall and Heimdall Frontend both utilise CMake for managing the build
process. CMake can generate files for various build systems including GNU
Make and Visual Studio. However, official packages are compiled with GNU
Make and MinGW-W64 GCC/G++.
NOTE: Official builds use MinGW-W64 simply because on-going cross-platform
development is simpler when using just the one IDE (Jetbrain's CLion)
and similar toolchains.
1. Setup a MinGW-W64 build environment by utilising MSYS2:
http://msys2.github.io/
2. After installing MSYS2 a command prompt will launch, enter:
Pacman -Syu
Pacman -S mingw-w64-x86_64 mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-libusb mingw-w64-x86_64-qt5-static make
3. Add the MinGW-W64 binaries to your PATH environment variable:
export PATH="/mingw64/bin:$PATH"
4. Build Heimdall & Heimdall Frontend
mkdir build
cd build
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DQt5Widgets_DIR=/c/msys64/mingw64/qt5-static/lib/cmake/Qt5Widgets ..
make
You can checkout v1.4.0 tag, open msvc2012.sln and build that code instead.
You will need Qt Developer Framework (4.7 or later, but prior to 5.0) to build it

Using cpp-netlib in a C++ project under Windows

I want to use the cpp-netlib library in a C++ project of mine running on Windows.
I've strictly followed the instructions under http://cpp-netlib.github.com/getting_started.html up to the "Getting CMake" section, which is where
I stopped understanding the instruction. Is CMake indeed non-obligatory? If so, what are the exact steps required so I can use the library in my projects?
If someone could provide me with instructions here, or refer me to a detailed guide it'd be
great. Google didn't help me that much.
Same problem here:
I got it going with
From the directory I dumped cpp-netlib-0.9.4 in
cd ..
mkdir cpp-netlib-build
cd cpp-netlib-build
cmake.exe -G "Visual Studio 10" -DBOOST_ROOT:string="C:\Dev\Boost\boost_1_51_0" ../cpp-netlib-0.9.4
(Your paths may vary)
This populates the cpp-netlib-build directory with a VS10 solution and projects.