Apache Thrift errors with CMakeLists.txt - c++

I am trying to build the C++ library for Apache Thrift and I am getting a cmake error that I cannot quite decipher, this is the series of steps I followed to get the error
git clone https://git-wip-us.apache.org/repos/asf/thrift.git
cd thrift/lib/cpp
mkdir cmake-build
cmake ..
And the error I get is
CMake Error at CMakeLists.txt:162 (include):
include could not find load file:
ThriftMacros
CMake Error at CMakeLists.txt:164 (ADD_LIBRARY_THRIFT):
Unknown CMake command "ADD_LIBRARY_THRIFT".
Has someone else encountered this error before as well?

This isn't the way to build it. You need to build from the root directory as instructed otherwise, you will miss a whole slew of CMake definitions.
From the root repository directory:
mkdir cmake-build && cd cmake-build
cmake .. -DBUILD_CPP:BOOL=ON

Related

cmake --target source directory does not exist

I am compiling a rather big C++ project with cmake.
The project has several targets defined in the CMakeLists.txt of the various subdirectories
I can create a folder somewhere and use cmake to prepare compilation of the targets, and compile any of the target :
cmake ..
make -j8 cytosim
And this works.
However, if I call cmake with a target :
cmake .. --target cytosim
I get the error
CMake Error: The source directory ".../build/cytosim" does not exist.
I thought target was supposed to be a module/library/executable target... What am I missing ?
CMake --target argument is usable in CMake Build Mode (--build).
Try cmake --build .. --target cytosim

libssh's functions couldn't be found on qt

I have cloned libssh library and built it with cmake. Building process was like this :
git clone https://git.libssh.org/projects/libssh.git/
mkdir build in libssh directory.
cd build
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
after this line i got this error about cmocka:
Could NOT find CMocka (missing: CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
then : rm CMakeCache.txt
cmake ..
make
sudo make install
Now I want to use this library on qt but I have some issues there.
I got errors like :
error: undefined reference to `ssh_session_is_known_server'
I can't use any of function or structures on this library. My OS is ubuntu 18.04.

make: *** No targets specified and no makefile found. Stop. [ubuntu]

I'm trying to build this
https://github.com/patrikhuber/eos
but I'm having troubles.
The instructions are pretty simple, as it says on gitHub
To build:
git clone --recursive https://github.com/patrikhuber/eos.git
mkdir build && cd build # creates a build directory next to the 'eos' folder
cmake -G "<your favourite generator>" ../eos -DCMAKE_INSTALL_PREFIX=../install/
make && make install # or open the project file and build in an IDE like Visual Studio
I'm using "Ninja" as generator and it looks like the cmake part goes through successfully as I get
-- Configuring done
-- Generating done
-- Build files have been written to: /home/francesco/eos/build
That's where things stop "working" for me, or where I fail to understand what's next. Following the instructions, I type
make && make install
and I get this message
make: *** No targets specified and no makefile found. Stop.
I looked around for solutions but I don't really understand what I am supposed to do: I tried
./configure
but I'm getting
bash: ./configure: No such file or directory
Anyone can please help?
Thanks
It always depends on your CMake "Generator". The 'make' is linux/mingw tool/command. For VisualStudio you can use nmake or sln/proj generated stuff.
More reliable could be utilize CMake for building i.e. for "NMake Makefiles" generator:
cmake --build <build folder> --target install
or
cmake --build <build folder> --config release --target install
for VisualStudio generator
I had the same problem, and solved by tinkering with locations for cmake and make. Here's what I used:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local
make
I believe /usr/local is the default location (see here)

CMake compile -s -mt version of rabbitmq-c

I run cmake in command prompt with:
mkdir build && cd build
.. cmake
But now, I have problem constructing the command to build realease static.
I tried:
C:\Users\Kuba\Downloads\rabbitmq-c>cmake --build build --BUILD_STATIC_LIBS=ON
Which yields the error:
Unknown argument --BUILD_STATIC_LIBS=ON
How to correct this? Thanks !
You should define the variable using the -D option:
cmake --build build -DBUILD_STATIC_LIBS=ON
Please read the documentation for more information.
Configuring the build is a separate step from building it.
From the source directory create a binary directory:
mkdir build && cd build
Then configure the build (this is where you can add other build-flags):
cmake -DBUILD_STATIC_LIBS=ON ..
then build it:
cmake --build .

CMake build multiple targets in different build directories

I have the following CMake structure:
CMakelists.txt
toolchain.cmake
folder1
----CMakelists.txt
folder2
----CMakelists.txt
etc..
My first-level CMakelists.txt file includes the other subdirectories. Now I want to build my code for a different target.
The manual way is:
1.
mkdir hostBuild
cd hostBuild
cmake ..
make
2.
mkdir crossBuild
cd crossBuild
cmake .. --DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
make
Is it possible that this process can run automatically?
For example, I just have to run cmake . at my first level.
Is something like this is possible?
No. The recommendation would be to just put your manual steps into a shell script.
CMake can only handle one compiler/make environment at a time (if you switch the compiler you need a different binary output directory).
Especially a toolchain file that does contain SET(CMAKE_SYSTEM_NAME ...) does change the whole outcome of the configuration/generation process.
For details on what CMake does see: CMake: In which Order are Files parsed (Cache, Toolchain, …)?
And you could make use of some CMake command line options in your shell script:
if [ ! -d hostBuild ]; then
cmake -E make_directory hostBuild
cmake -E chdir hostBuild cmake ..
fi
cmake --build hostBuild
...