Dcmake_toolchain_file

/ Comments off

This document describes how to build the Intel® RealSense™ SDK 2.0 including headless tools and examples for Android devices. Read about Android support here. Root your Android device.Download the Native Development Kit (NDK) for Linux to your host machine.Install CMake 3.6.1. The CMAKETOOLCHAINFILE variable specifies which compiler to use and sets some CMake variables, like the system name and the default search path. For more information about cross compiling with CMake, see Cross Compiling on the official CMake wiki. The CMakeLists.txt and toolchain files must be in the correct locations.

  • 2Installing CMake and Ninja
  • 4Building using CMake
  • 5C++ Builder-specific support in a CMakeLists.txt
  • 6Example CMakeLists.txt file

CMake Command-Line Support

RAD Studio 10.2 Tokyo Release 3 includes support for building CMake projects on the command line using RAD Studio's C++ Compilers. You can compile for Windows or for other platforms from Windows. CMake supports RAD Studio’s Clang-enhanced compilers: BCCAARM for Android, BCCIOSARM64 for 64-bit iOS, BCCIOSARM for 32-bit iOS, BCC64 for 64-bit Windows, and BCC32X for 32-bit Windows.RAD Studio 10.2 Tokyo Release 3 also supports using Ninja with CMake. This allows for fast parallel compilation.

Installing CMake and Ninja

CMake

Download and install CMake 3.10. Use the binary installer, since it can optionally add CMake to the system path. Make sure you select that option during the installation.

CMake files are located in C:Program Files (x86)EmbarcaderoStudio19.0cmake. However, to prevent errors in the build process, you need to move one file manually. Follow the steps below to do this:

  1. Locate your CMake installation folder and the ModulesPlatform subfolder. E.g. C:Program FilesCMakesharecmake-3.10ModulesPlatform
  2. Locate the Windows-Embarcadero.cmake file and make a backup.
  3. Copy Windows-Embarcadero.cmake from the Studio19.0cmake folder and overwrite the version in the CMake folder.

We have greatly extended the inbuilt CMake support for the Windows compilers and you need to use this file to build successfully.

Ninja

Download and install Ninja 1.8.2. You’ll need to add it to the system path manually.

How to use CMake

CMake builds based on a text file called CMakeLists.txt that tells CMake which files to build. You can find more information in their developer documentation. We also recommend Jeff Preshing’s blog series on CMake: How to Build a CMake-based Project and Learn CMake’s Scripting Language in 15 Minutes.

To use CMake, you need the following files:

  • C++ source you want to build: A number of C++ files and headers.
  • CMakeLists.txt file: Defines the project name, tells it to find all source files, and builds them in one executable, library, package, etc. See below for several sample files. More advanced CMakeLists.txt files specify several projects.
  • (Optionally) Batch script to drive CMake: Use the batch script (*.bat) to contain a number of commands. CMake can create a large number of files, and you can use the batch file to create a subfolder where all output including CMake’s files are placed. This blog post on using bcc32c with CMake has more details.
Run the batch script from the command line to generate the executable file along with many other files in the specified subfolder.
Note: Store the CMakeLists.txt file in the root folder of your project. You can store the source files in a subfolder.

Building using CMake

Start a RAD Studio command prompt from the Start menu, or by opening a command prompt and executing rsvars.bat in the RAD Studio bin folder.

CMake looks for a CMakeLists.txt file. See below for information on creating one of these for a project.

Targeting Windows

To target Win32:cmake -DCMAKE_C_COMPILER=bcc32x.exe -DCMAKE_CXX_COMPILER=bcc32x.exe -G Ninja <directory> [1]

To target Win64:cmake -DCMAKE_C_COMPILER=bcc64.exe -DCMAKE_CXX_COMPILER=bcc64.exe -G Ninja <directory> [1]

Then,ninja

To invoke Ninja to do the actual build.

Targeting iOS and Android

iOS and Android are handled through toolchain files, which are used for cross-compiling. Make sure you can build and deploy from the IDE (including setting up the SDK) before attempting a command-line build.

To target iOS32:cmake -DCMAKE_TOOLCHAIN_FILE='<BDS>cmakebccios32.cmake' -G Ninja <directory> [1]

To target iOS64:cmake -DCMAKE_TOOLCHAIN_FILE='<BDS>cmakebccios64.cmake' -G Ninja <directory> [1]

To target Android:cmake -DCMAKE_TOOLCHAIN_FILE='<BDS>cmakebccaarm.cmake' -G Ninja <directory> [1]

Then,ninja

To invoke Ninja to do the actual build.

  1. 1.01.11.21.31.4Directory where cmakelists.txt file is located

Other command-line flags

  • -G”Borland Makefiles” to use old-fashioned make to build.
  • -DCMAKE_BUILD_TYPE_INIT=Release to target debug or release builds.
  • -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON for easier to debug output.
  • --debug-output to put CMake in debug mode.

For example:

To use the Win32 compiler, release build, some verbose and debugging flags, and build using make, with CMakeLists.txt located in the parent folder.

C++ Builder-specific support in a CMakeLists.txt

Targets

Dcmake_toolchain_file Not Working

Using CMake, you can create executables, DLLs, static libraries, and packages.

Or combinations:

Macros and variables

There are a number of macros and variables for Windows, iOS, and Android. This sample CMakeLists.txt shows several of them:

Example CMakeLists.txt file

For a project called Example, with source files in the same folder, a very minimal CMakeLists.txt file is:

This specifies the minimum version (3.10); the project name; that it uses all available .cpp and .h files, and compiles them all into Example.exe.

“Glob”-ing all files together is quick and easy, but is not a recommended best practice; instead, it is better to specify the files you want to use. You can specify .cpp files and headers, but one minimal example specifying .cpp files is:

Sample CMakeLists.txt: VCL app

Sample CMakeLists.txt: FMX app

Sample CMakeLists.txt: shared library

Sample CMakeLists.txt: Static Library

Sample CMakeLists.txt: Package

Sample CMakeLists.txt: Resources

See Also

Retrieved from 'http://docwiki.embarcadero.com/RADStudio/Sydney/e/index.php?title=Using_CMake_with_C%2B%2B_Builder&oldid=271636'

Python¶

Dcmake_toolchain_file Opencv

Please, make sure to use Python 3+. Next, install the latest release from PYPI with the following command in terminal Incarcator ipod apple.

If you want to install it from source files or build unreleased version from Github, you should compile core module first and run

C#¶

Windows(Visual Studio)

You are able to install the latest release from Nuget or build it yourself:

  • Compile BrainFlow’s core module

  • open Visual Studio Solution

  • install required nuget packages

  • build it using Visual Studio

  • make sure that unmanaged(C++) libraries exist in search path - set PATH env variable or copy them to correct folder

Unix(Mono)

  • Compile BrainFlow’s core module

  • install nuget and Mono on your system

  • install required nuget packages

  • build it using Mono

  • make sure that unmanaged(C++) libraries exist in search path - set LD_LIBRARY_PATH env variable or copy them to correct folder

Example for Fedora:

R binding is based on reticulate package and calls Python code, so you need to install Python binding first, make sure that reticulate uses correct virtual environment, after that you will be able to build R package from command line or using R Studio, install it and run samples.

Not

Java¶

You are able to download jar files directly from release page

If you want to install it from source files or build unreleased version from github you should compile core module first and run

Also, you can use GitHub Package and download BrainFlow using Maven or Gradle.To use Github packages you need to change Maven settings. Example file here you need to change OWNER and TOKEN by Github username and token with an access to Github Packages.

Matlab¶

Steps to setup Matlab binding for BrainFlow:

  • Compile Core Module, using instructions below. If you don’t want to compile C++ code you can download Matlab package with precompiled libs from Release page

  • Open Matlab IDE and open brainflow/matlab-package/brainflow folder there

  • Add folders lib and inc to Matlab path

  • If you want to run Matlab scripts from folders different than brainflow/matlab-package/brainflow you need to add it to your Matlab path too

Julia¶

BrainFlow is a registered package in the Julia general registry, so it can be installed via the Pkg manager:

Example:

When using BrainFlow for the first time in Julia, the BrainFlow artifact containing the compiled BrainFlow libraries will be downloaded from release page automatically.

If you compile BrainFlow from source local libraries will take precedence over the artifact.

Docker Image¶

There are docker images with precompiled BrainFlow. You can get them from DockerHub.

All bindings except Matlab are preinstalled there and libraries compiled with OpenMP support.

Also, there are other packages for BCI research and development:

  • mne

  • pyriemann

  • scipy

  • matplotlib

  • jupyter

  • pandas

  • etc

If your devices uses TCPIP to send data, you need to run docker container with --networkhost. For serial port connection you need to pass serial port to docker using --device%yourporthere%

Example:

Compilation of Core Module and C++ Binding¶

Windows¶

  • Install CMake>=3.13 you can install it from PYPI via pip

  • Install Visual Studio 2017, you can use another version but you will need to change CMake generator in batch files or run CMake commands manually. Also in CI we test only VS2017

  • In VS installer make sure you selected “Visual C++ ATL support”

  • Build it as a CMake project manually or use cmd files from tools directory

Compilation using cmd files:

Dcmake_toolchain_file Cmake

Linux¶

  • Install CMake>=3.13 you can install it from PYPI via pip

  • If you are going to distribute compiled Linux libraries you HAVE to build it inside manylinux Docker container

  • Build it as a CMake project manually or use bash file from tools directory

  • You can use any compiler but for Linux we test only GCC, also we test only 64bit libraries for Linux

Compilation using bash file:

MacOS¶

  • Install CMake>=3.13 you can install it from PYPI via pip

  • Build it as a CMake project manually or use bash file from tools directory

  • You can use any compiler but for MacOS we test only Clang

Compilation using bash file:

Compilation with OpenMP¶

Some data processing and machine learning algorithms work much faster if you run them in multiple threads. To parallel computations we use OpenMP library.

Dcmake_toolchain_file Not Used

Precompiled libraries which you download from PYPI/Nuget/Maven/etc built without OpenMP support and work in single thread.

If you want to increase performance of signal processing algorithms you can compile BrainFlow from the source and turn on USE_OPENMP option.

To build BrainFlow with OpenMP support first of all you need to install OpenMP.

  • On Windows all you need is Visual C++ Redist package which is installed automatically with Visual Studio

  • On Linux you may need to install libgomp if it’s not currently installed

  • On MacOS you need to run brewinstalllibomp

After that you need to compile BrainFlow with OpenMP support, steps are exactly the same as above, but you need to run bash or cmd scripts whith _omp postfix.

Example:

If you use CMake directly to build BrainFlow you need to add -DUSE_OPENMP=ON to CMake config command line.

Android¶

To check supported boards for Android visit Supported Boards

Installation instructions¶

  • Create Java project in Android Studio, Kotlin is not supported

  • Download jniLibs.zip from Release page

  • Unpack jniLibs.zip and copy it’s content to project/app/src/main/jniLibs

  • Download brainflow-jar-with-dependencies.jar from Release page or from Github package

  • Copy brainflow-jar-with-dependencies.jar to project/app/libs folder

Now you can use BrainFlow SDK in your Android application!

Note: Android Studio inline compiler may show red errors but it should be compiled fine with Gradle. To fix inline compiler you can use File > Sync Project with Gradle Files or click at File > Invalidate Cache/Restart > Invalidate and Restart

For some API calls you need to provide additional permissions via manifest file of your application

Compilation using Android NDK¶

For BrainFlow developers

To test your changes in BrainFlow on Android you need to build it using Android NDK manually.

Cmake_toolchain_file Cmake

Compilation instructions:

  • Download Ninja or get one from the tools folder, make sure that ninja.exe is in search path

  • You can also try MinGW Makefiles instead Ninja, but it’s not tested and may not work

  • Build C++ code using cmake and Ninja for all ABIs

  • Compiled libraries will be in tools/jniLibs folder

Cmake_toolchain_file Not Used

Command line examples: