Skip to content

Latest commit

 

History

History
146 lines (119 loc) · 3.86 KB

build_guide.asciidoc

File metadata and controls

146 lines (119 loc) · 3.86 KB

Build Guide

FiberTaskingLib is built using CMake. As such, the build is pretty much standard CMake. That said, this page will give an overview of how to build the library and how to include it in your own projects.


Building the Library and Tests

Windows

  1. Open a cmd window and cd to the project root

    > cd C:/path/to/FiberTaskingLib
  2. Create the build files with cmake. The code snippet below assumes Visual Studio 2015, and building 64bit. Other Visual Studio versions should also work, as long as they are C++11 capable. 32 bit builds should work as well.

    > mkdir build
    > cd build
    > cmake -G "Visual Studio 14 2015 Win64" ../
  3. Build

    1. Open the .sln file in Visual Studio and build

    2. Alternatively, you can build from command line

      > msbuild FiberTaskingLib.sln /p:configuration=release /p:platform=x64
  4. Run the tests. The exe should be located at 'build/tests/Release/ftl-test.exe'

    > build/tests/Release/ftl-test.exe


Unix systems

  1. Open a terminal and cd to the project root

    $ cd /path/to/FiberTaskingLib
  2. Create the build files with cmake. The code snippet below uses CMake’s default generator, makefiles. However, you’re free to use any of the other generators. For the makefile generator, the compiler/linker will use whatever CC/CXX are set to.

    $ mkdir build
    $ cd build
    $ cmake ../
  3. Build

    $ make -j
  4. Run the tests

    $ ./tests/ftl-test


Including FiberTaskingLib in your own project

There are two ways to consume FiberTaskingLib: with Cmake or without CMake

Your Project Uses CMake

The simplest way to include FiberTaskingLib is to include the source directly in your project and use CMake’s add_subdirectory(). Let’s do a quick example:

Let’s assume your project’s file structure is:

└── MyProject
    ├── CMakeLists.txt
    ├── include
    │   └── MyProject
    │       ├── header2.hpp
    │       └── header.hpp
    ├── source
    │   └── main.cpp
    └── third_party
        └── FiberTaskingLib
            ├── CMakeLists.txt
            └── ...

Then, the project CMakeLists.txt could be as follows:

cmake_minimum_required(VERSION 3.8)
project(MyProject)

# You can use the FTL_BUILD_TESTS variable to enable / disable test building
set( FTL_BUILD_TESTS OFF CACHE BOOL  "Disable tests" )

# You can use the FTL_BUILD_BENCHMARKS variable to enable / disable benchamark building
set( FTL_BUILD_TESTS OFF CACHE BOOL  "Disable benchmarks" )

# Add FiberTaskingLib
# You do not need to explicitly add the include directory, CMake with automagically do this for us.
add_subdirectory(third_party/FiberTaskingLib)


# Create the MyProject executable
add_executable(MyProject source/main.cpp)

# Add the MyProject include directory
target_include_directories(MyProject PRIVATE include)

# Link to FiberTaskingLib
target_link_libraries(MyProject ftl)
Summary
  • FiberTaskingLib is a standard 'modern' CMake project

  • FiberTaskingLib defines the CMake options FTL_BUILD_TESTS and FTL_BUILD_BENCHMARKS

    • If set to ON (default), CMake will build the FTL tests / benchmarks

    • If set to OFF, CMake will skip the FTL tests / benchmarks

  • Internally, FiberTaskingLib uses target_* family of functions.

    • Thus, when you link to FiberTaskingLib, CMake with automagically resolve all dependencies and include directories.


Your Project Does Not Use CMake

  1. Build FiberTaskingLib as per the instructions above

  2. Add {FTL_ROOT}/include and {FTL_ROOT}/third_party/boost_context/include to your toolchain’s include directories

  3. Link to ftl.lib and boost_context.lib built in step 1