Tutorial
It is really easy to develop applications against SCF
. One either has to compile and generate artifacts from SCF
and create an application that links against them.
Develop With SCF
SCF
provides CMake utility scripts to simplify developing applications or libraries that depend on SCF
. All the developer needs is an SCF
build and Suil Project Template
.
This tutorial assumes you have SCF
binaries downloaded to $(pwd)/scf/artifacts
Clone the template repo to a directory with your desired project name
git clone https://github.com/dccarter/suil-template hello-world cd hello-world rm -rf .git
Build the template hello-world project
# Launch project in a docker container docker run -it --rm --name suil-dev \ -v $(pwd)/scf/artifacts:/home/scf/artifacts \ -v $(pwd)/hello-world:/home/scf/hello-world \ -w /home/scf/hello-world \ suilteam/remote:ubuntu bash # Build the project mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=Debug -DSUIL_BASE_PATH=/home/scf/artifacts make deps -j4 make # Execute the built hello world app ./hello-world # Outputs-> global: Hello World! This is suil world
The template contains the following files. Note that these files are for reference only
File/Directory Description 3rdParty.cmake This file contains 3rdParty projects not exported within SCF
package but needed to build dependent applications.gitattributes This file is not needed to build suil, but it will help github highlight .scc
files asC++
files.gitignore Not needed for the build but it is what I use as my .gitignore
filesrc This folder contains the source code of the app or library test his folder contains unit testing source code. CMakeLists.txt Contains the code that drives CMake. There is nothing special in this file
The following is the listing for the CMakeLists.txt template file. It uses Suil.cmake
to configure an application
|
|
This is the line that declares the name of the project. Change this to whatever you wish to name your project (See CMake Project for more info)
|
|
Do not change this code block unless you know what you are doing. The code includes scf
artifacts in the module lookup path for CMake. (See CMAKE_MODULE_PATH
for more info)
|
|
This includes Suil.cmake
from scf
artifacts. This script provides CMake utility functions/macros used in this project.
|
|
This will initialize the project declared in line #2
. This function should only be invoked once with the name of the project.
SuilProject
is a function provided by suil and includes most of the CMake code that would be needed to setup an SCF
project. See SuilProject
for how to use the function
|
|
This code block will create an executable target. The parameters to given SuilApp
are self explanatory. See SuilApp
for all the supported parameters.
Conclusion
Using this template and Suil.cmake
is not a requirement in developing SCF
apps/libraries. Any developer familiar with CMake can rollout a project that depends on suil
in a matter of minutes without using the helper script and the template.
Also note that there is nothing special about the!!! Happy Coding !!!!CMakeLists.txt
included in the template. If the target project needs what’s more that provided bySuil.cmake
, any other requirements can still be added in the CMakeLists.txt.