This is an effort to create a document on how to migrate from cmt to cmake, for projects outside tdaq (such as sub-detector online software, which is compiled against tdaq release) This page is mainly done for Muon DAQ experts. It's based on my experience when I migrated CSC online software. It can be incomplete or some parts can be inaccurate.

CSC CMake build can be seen at: Note that CSC has a slightly different code structure, and many packages are not built with cmt, so don't get confused with non-conventional stuff in the CMakeLists file. I tried to add as much comments to avoid this confusion

Basic setup for detector specific online code

There is a very nice twiki page on usage of cmake in ATLAS TDAQ projects. It has some sections on non-tdaq projects too.

Top level CMakeLists.txt

Your top level CMakeLists.txt file should ONLY include the following:
cmake_minimum_required(VERSION 3.4.3)
tdaq_project(myproject 1.0.0 USES tdaq 6.2.0)

Package level CMakeLists.txt

Each package under this directory should start their CMakeLists.txt with the following function call
You don't need to enter a package name, it will retrieve the package name from the directory name. After this line, one should enter all the information to build the specific package. CMakeLists.txt in the subdirectories will do the job of cmt/requirement files.


Say you call your main directory MyProject, and you checkout 2 packages from your software, called package1 and package2. Assuming you still kept the cmt folders, your folder structure should be something like this (This is output of tree command):


MyProject/CMakeLists.txt is the top level file, whereas MyProject/package1/CMakeLists.txt and MyProject/package2/CMakeLists.txt are package level cmake files.

Other resources

One very useful help source is the cmake files of tdaq projects: /afs/, /afs/

In each of tdaq and tdaq-common, all packages have their CMakeLists.txt and cmt/requirement files, so one can compare how tdaq migrated to cmake. Note that there are some tdaq specific conventions that may not work for your project.

CMT-CMake cheat sheet

Whatcmt requirementsCMakeLists.txtnotes
use statements
use TDAQPolicy
use OnlinePolicy
use Boost * TDAQCExternal
use ers
use ipc
use config
use dal
use ROOT * DQMCExternal
use CORAL * TDAQExternal
use COOL  * TDAQExternal

use config
use genconfig

You don't need anything in cmake. From what I get, you just need to use correct naming when you include libraries (such as COOL::CoolKernel etc.)
Define global include directories
include_dirs "/path/to/includedir"
Dal Generation
macro generate-config-include-dirs  "${TDAQ_INST_PATH}/share/data/dal \

document generate-config            CSCdal -s=../schema/ \
                     namespace="CSCdal"   \
                     include="CSCdal"     \

macro   gdir                        "$(bin)CSCdal.tmp"
library cscdal                      $(gdir)/*.cpp
macro   cscdal_dependencies         "CSCdal"
macro   CSCdal_libraries            "cscdal"
      INCLUDE_DIRECTORIES dal DFConfiguration
      INCLUDE CSCdal
      CPP_OUTPUT dal_cpp_srcs)

tdaq_add_library(cscdal DAL ${dal_cpp_srcs})
This is an example from CSC. You may need to put tde following in your CMakeLists.txt before dal generation (At least it was necessary for CSC)

Adding a library
library mylib            path/to/ path/to/
macro   mylib_shlibflags              "-lohroot -loh -lis -lipc -lers -lsomething"
tdaq_add_library(mylib  path/to/ path/to/
      LINK_LIBRARIES tdaq::ohroot tdaq::oh tdaq::is tdaq::ipc tdaq-common::ers something)
Note that to link against tdaq libraries, one should use the full name including project(tdaq,tdaq-common etc.).
Adding an application/executable
application   myapp     "path/to/ path/to/"
macro         myapplinkopts           "-lsomething -lsomethingelse -lrc_CmdLine "
macro         myapp_dependencies      "dep1 dep2" 
tdaq_add_executable(myapp  path/to/ path/to/
      LINK_LIBRARIES  something somethingelse tdaq::rc_CmdLine)
add_dependencies(myapp dep1 dep2)
Again, as example, rc_CmdLine is a tdaq package, so one should enter it as tdaq::rc_CmdLine
IS generation
action is_gen_myis            " -d $(bin)/my_is_dir -cpp ../schema/myischema.schema.xml"
action is_gen_myisn           " -d $(bin)/my_is_dir -cpp -n ../schema/myischema.schema.xml"

action is_gen_myis_j          " -d $(bin)/my_is_dirj -java ../schema/myischema.schema.xml"
action is_gen_myis_jn         " -d $(bin)/my_is_dirj -java -n ../schema/myischema.schema.xml"

apply_pattern install_data  name=is_schema target_dir="schema" src_dir="../schema" files="myischema.schema.xml"

tdaq_generate_isinfo(my_ISINFO    schema/myischema.schema.xml 
                    CPP_OUTPUT cpp_srcs
                    SIMPLE NAMED
                    OUTPUT_DIRECTORY my_is_dir) 

tdaq_generate_isinfo(my_ISINFO_j    schema/myischema.schema.xml 
                    JAVA_OUTPUT java_srcs
                    SIMPLE NAMED
                    OUTPUT_DIRECTORY my_is_dirj) 

Variables ${cpp_srcs} and ${java_srcs} refer to generated files.
apply_pattern install_libs      files=""
apply_pattern install_apps      files="app1 app2 app3"
apply_pattern install_headers   src_dir="$(bin)/mydal " \
                                files="*.h " \
                                target_dir="../mydal/ "

Nothing to do for cmake. Cmake will install the necessary files (headers, dal and is generated files, applications, libraries) when you do make install
Installing special header files with non-standard extension (such as hh)
apply_pattern install_headers   src_dir="../mydir " \
tdaq_add_header_directory(mydir PATTERN *.hh )

-- CenkYildiz - 2016-09-27

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng cmake_folders.png r1 manage 29.1 K 2016-09-28 - 08:46 CenkYildiz  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2016-09-28 - CenkYildiz
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback