<md>
# Build Guide

## Preparing paths.cmake

Alright, all the tools and libraries are available on your machine. What's next?

As we mentioned earlier, Jancy build system has its own path configuration instead of relying on system-wide environment variables or path auto-detection. This is done to let developers (such as ourselves) have multiple versions of tools and libraries installed on a single build machine and at the same time be in full control over which tool or library is going to be used when building a particular project.

The path configuration is stored in *paths.cmake* file in *$AXL_DIR/cmake/std* and *$JANCY_DIR/cmake/std* subdirectories. Note that you will not find one there if you look it up right after unpacking the downloaded package. That's because *paths.cmake* is a volatile machine-dependent configuration file and it has to be created by hand for each particular machine. If it's missing during build, the empty one will be generated from *paths.cmake.template* for you to fill in.

* `LLVM_INC_DIR` points to LLVM includes in source directory
* `LLVM_INC_DIR_2` points to generated LLVM includes (in build directory)
* `LLVM_LIB_DIR` points to generated LLVM libraries (in build directory)
* `LLVM_CMAKE_DIR` points to generated LLVM cmake files (in build directory)
* `QT_CMAKE_DIR` points to QT cmake files
* `QT_DLL_DIR` points to QT DLL files (Windows only)
* `AXL_CMAKE_DIR` points to `$AXL_DIR/cmake`
* `GRACO_CMAKE_DIR` points to `$GRACO_DIR/cmake`
* `PERL_EXE` points to Perl executable
* `RAGEL_EXE` points to Ragel executable

The final *$JANCY_DIR/cmake/std/paths.cmake* might look something like:

<div class='new_frame snippet'>
<code name="text">
set (LLVM_VERSION      3.3)
set (QT_VERSION        5.0.2)
set (AXL_VERSION       5.3.2)
set (GRACO_VERSION     1.1.1)
set (RAGEL_VERSION     6.7)

set (LLVM_INC_DIR        "c:/Develop/llvm/llvm-${LLVM_VERSION}/include")
set (LLVM_INC_DIR_2      "c:/Develop/llvm/llvm-${LLVM_VERSION}/build/include")
set (LLVM_LIB_DIR        "c:/Develop/llvm/llvm-${LLVM_VERSION}/build/lib/${CONFIGURATION}")
set (LLVM_CMAKE_DIR      "c:/Develop/llvm/llvm-${LLVM_VERSION}/build/share/llvm/cmake")
set (QT_CMAKE_DIR        "c:/Develop/qt/qt-${QT_VERSION}/build/qtbase/lib/cmake")
set (QT_DLL_DIR          "c:/Develop/qt/qt-${QT_VERSION}/build/qtbase/lib")

set (AXL_CMAKE_DIR       "c:/Develop/axl/axl-${AXL_VERSION}/cmake/latest")
set (GRACO_CMAKE_DIR     "c:/Develop/graco/graco-${GRACO_VERSION}/cmake")

set (PERL_EXE            "c:/Develop/ActivePerl/bin/perl.exe")
set (RAGEL_EXE           "c:/Develop/ragel/ragel-${RAGEL_VERSION}/ragel.exe")
</code>
</div>
<br>

Next to the template *paths.cmake.template* you will also find sample files *paths-sample-windows.cmake* and *paths-sample-linux.cmake* (taken from our Windows and Linux build machines). Feel free to use these as a reference when editing your own *paths.cmake*.

After *paths.cmake* files are properly configured, you are ready to build.

## Building

You will need to build the support library AXL first.

Go to *$AXL_DIR* and create build directory, let's say, *$AXL_DIR/build*. From this directory run:

<div class='new_frame snippet'>
<code>
cmake ..
</code>
</div>
<br>

Usually this is enough to create proper project files. After projects have been created, you can use *cmake-gui* to fine-tune build settings. For example, you can adjust target CPU or Debug/Release for Unix makefiles, tweak C++ runtime library settings and debug information type for Microsoft Visual C++, and so on.

<div class='new_frame snippet'>
<code>
cmake-gui .
</code>
</div>
<br>

Of course, you can use *cmake-gui* for generating project files all along. Once project files have been created, you build them.

</md>

<table style="border-spacing:0;width:100%;background-color:#eeeeee">
<tr style="vertical-align:top">
<td style="width:50%;padding:10px">

<md>

On Windows you can start Visual Studio by double-clicking the newly generated solution file *axl.sln* and build from the IDE.

Or, if you  prefer building from command line you need to have *msbuild.exe* in your *PATH*. Then you can run (from *$AXL_DIR/build*):

<div class='new_frame snippet'>
<code>
msbuild axl.sln
</code>
</div>
<br>

You might need to specify extra command-line parameters. For example, if you want to have a multi-core build of *Release* configuration, run:


<div class='new_frame snippet'>
<code>
msbuild /maxcpucount /property:configuration=Release axl.sln
</code>
</div>
<br>

Please refer to *msbuild* documentation for more details on command-line parameters.

</md>

</td>
<td style="width:50%;padding:10px">

<md>

On Linux simply run (again, from *$AXL_DIR/build*):

<div class='new_frame snippet'>
<code>
make
</code>
</div>
<br>

You might also want to add *-j &lt;n&gt;* to make use of all your CPU cores and speed up build process, like:

<div class='new_frame snippet'>
<code>
make -j 4
</code>
</div>
<br>

</md>

</td>
</tr>
</table>
<br>
<md>

Once AXL is built, you repeat the very same process from *$JANCY_DIR/build* (of course it will take significantly more time than building AXL).

After Jancy build is complete you will have Jancy library files in *$JANCY_DIR/build/lib* directory; command line compiler and sample executable binaries can be found in *$JANCY_DIR/build/bin*.

Now let's test compiled binaries.
</md>

<table style="border-spacing:0;width:100%;background-color:#eeeeee">
<tr style="vertical-align:top">
<td style="width:50%;padding:10px">

<md>On Windows run (from *$JANCY_DIR/build*):</md>

<div class='new_frame snippet'>
<code>
ctest -C Debug
</code>
</div>
<br>

<md>Or, if you were building under *Release* configuration:</md>

<div class='new_frame snippet'>
<code>
ctest -C Release
</code>
</div>

</td>
<td style="width:50%;padding:10px">

<md>On Linux running tests is done by:</md>

<div class='new_frame snippet'>
<code>
make test
</code>

</div>
</td>
</tr>
</table>
<br>

<md>
Hopefully what you saw was:

<div class='new_frame snippet'>

<code>
100% tests passed, 0 tests failed out of 40
</code>

</div>
<br>

If that's the case -- congratulations! You have just successfully built Jancy.

Explore the sources, play with the samples (definitely try *02_dialog* and see how to apply reactive programming to QT widgets) and use Jancy in you own C++ projects!

---
Proceed to [live demo](/jancy/live_demo.html)
</md>