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 .
Related
I need to build my CMake based project under MSVC 2013 and MSVC 2019.
With MSVC 2019 using Ninja generator I build it successfully with following commands:
cmake -S . -B build -GNinja "-DCMAKE_BUILD_TYPE:STRING=Release"
cmake --build build --target all
On MSVC 2013 I have no Ninja available, so I tried the following:
cmake -S . -B build -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build build --target all
Anyway I am getting following error and nothing is built:
MSBUILD : error MSB1009: Project file does not exist.
Switch: all.vcxproj
Any idea how to build it without ninja? (I cannot install it, since I am building it on a build server.)
In contrast to other generators (like Makefiles or Ninja) CMake does not generate an all target for Visual Studio solution but an ALL_BUILD target.
So cmake --build build --target ALL_BUILD --config Release should succeed.
I'm using this .NET wrapper https://github.com/charlesw/tesseract and I wanted to update the included tesseract and leptonica DLLs but after a long google search I was not able to generate them from the original tesseract and leptonica github repositories.
I already ask on the charlesw repository but did not get any reply (https://github.com/charlesw/tesseract/issues/486).
Any help on how to build the DLLs is much appreciated.
Thanks!
https://github.com/tesseract-ocr/tesseract
https://github.com/danbloomberg/leptonica
Answer : (thank you user898678 for the link)
Using bucket401 blog post tutorial I extracted the required part to generate:
leptonica-X.XX.X.dll
tesseract.exe
tesseractXX.dll
and created this buildTesseractLeptonica.bat :
mkdir buildTesseractLeptonica
cd buildTesseractLeptonica
mkdir bin
set INSTALL_DIR=%cd%
set PATH=%PATH%;%INSTALL_DIR%\bin
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" x64
set INCLUDE=%INCLUDE%;%INSTALL_DIR%\include
set LIBPATH=%LIBPATH%;%INSTALL_DIR%\lib
set TESSDATA_PREFIX=%INSTALL_DIR%\share\tesseract\tessdata
git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
cd leptonica
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DBUILD_PROG=OFF -DSW_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
cd ..
git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git
cd tesseract
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DLeptonica_DIR=%INSTALL_DIR%\lib\cmake -DBUILD_TRAINING_TOOLS=OFF -DSW_BUILD=OFF -DOPENMP_BUILD=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release --target install
cd ..
bucket401 blog post link: https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html
There are several tutorials you can follow:
https://bucket401.blogspot.com/2021/03/building-tesserocr-on-ms-windows-64bit.html
http://spell.linux.sk/building-minimalistic-tesseract
https://github.com/tesseract-ocr/tessdoc/blob/main/Compiling.md#windows
I'm using a shell gitlab runner on my macbook. It's task is currently to run a very simple yaml file to build my project using cmake.
build:
before_script:
- git submodule update --init --recursive
- mkdir cmake-build-debug
- cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" .
script:
- cmake --build . --target all -- -j 4
It returns this though: CMake 3.17 or higher is required. You are running version 3.16.3.
When I add - which cmake to my before_script, it returns /usr/bin/cmake
When I run ls /usr/bin | grep cmake in my terminal, it doesn't return anything. When I run brew info cmake it returns the version as cmake: stable 3.19.3
How do I update cmake in my runner? Apparently It can't find brew in the before_script either.
PS: added bonus, if I set the minimum cmake version required to 3.16 it suddenly seems to be unable to link libm
I forgot to add a tag. So it wasn't running on my computer but on a different server.
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)
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
...