Skip to main content

Getting Started

The SoCMake source code is available on the following link.

Dependencies

Only mandatory SoCMake dependencies are CMake>=3.25.0 and make.

pip install cmake==3.26.3

Usage

Since SoCMake runs on CMake scripting language, no installation is required.
It is recommended to fetch the SoCMake locally within your CMake project.
There are multiple ways to add SoCMake within project, 2 of them are with CPM or inbuilt FetchContent. In both cases SoCMake will be downloaded during configuration phase of the project, only the first time.

It is recommended to create a file deps/deps.cmake with the content from one of the 2 options:

deps/deps.cmake

deps/deps.cmake
include(FetchContent)

FetchContent_Declare(SoCMake
GIT_REPOSITORY "ssh://git@gitlab.cern.ch:7999/socrates/SoCMake.git"
GIT_TAG master # You can define GIT_TAG or GIT_COMMIT for specific versions
)

FetchContent_MakeAvailable(SoCMake)

FetchContent is a built in CMake function for handling dependencies.

CMakeLists.txt

In the main CMakeLists.txt include deps/deps.cmake. It should look like this:

cmake_minimum_required(VERSION 3.25)
project(example NONE)

include("deps/deps.cmake")

After the previous code block, all of the SoCMake functions are available.

Directory structure

The directory tree of the project should look like this

├── CMakeLists.txt
└── deps
├── CPM.cmake
└── deps.cmake

Running CMake

Since CMake is endorsing out-of-source builds, meaning that the source files and build artifacts are in separate directories. We are creating a build directory.

mkdir build
cd build
cmake ../

After executing CMake we should ge the following messages:

-- Downloading CPM.cmake to .../build/cmake/CPM_0.38.1.cmake
-- CPM: Adding package SoCMake@ (master)
-- Configuring done
-- Generating done
-- Build files have been written to: .../build

By default the packages will be downloaded in ${CMAKE_BINARY_DIR}/_deps/. This is possible to change by setting FETCHCONTENT_BASE_DIR before the first CPMAddPackage command.

tip

For larger projects it is recommended to set set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}/_deps) in deps/deps.cmake, this will download all the dependencies git repository wide, so they will be available from different subdirectories like verification, documentation etc...

The previous example only set up the project, but we didnt add any design files or added any targets. Jump to the Examples page next.