ModernCMake-Chinese
  • Introduction
  • Modern CMake 简介
    • 安装 CMake
    • 运行 CMake
    • Do's and Don'ts
    • CMake 中的新变化
  • 基础知识简介
    • 变量和 Cache
    • 在CMake 中编程
    • 与你的代码交互
    • 如何结构化你的工程
    • 运行其他程序
  • Adding Features
    • C++11 and Beyond
    • Small but common needs
    • Utilities
    • Useful modules
    • IDEs
    • Debugging
  • Including Projects
    • Submodule
    • DownloadProject
    • Fetch (CMake 3.11)
  • Testing
    • GoogleTest
    • Catch
  • Exporting and Installing
    • Installing
    • Exporting
    • Packaging
  • Looking for libraries
    • CUDA
    • OpenMP
    • Boost
    • MPI
    • ROOT
      • UseFile Example
      • Simple Example
      • Simple Example CMake 3.11+
      • Dictionary Example
    • Minuit2
Powered by GitBook
On this page
  • examples/root-dict/CMakeLists.txt
  • Supporting files
  • examples/root-dict/DictExample.cxx
  • examples/root-dict/DictExample.h
  • examples/root-dict/DictLinkDef.h
  • Testing it
  • examples/root-dict/CheckLoad.C

Was this helpful?

  1. Looking for libraries
  2. ROOT

Dictionary Example

PreviousSimple Example CMake 3.11+NextMinuit2

Last updated 6 years ago

Was this helpful?

This is an example of building a module that includes a dictionary in CMake. Instead of using the ROOT suggested flags, we will manually add threading via find_package, which is the only important flag in the list on most systems.

examples/root-dict/CMakeLists.txt

Supporting files

This is just a simple-as-possible class definition, with one method:

examples/root-dict/DictExample.cxx

examples/root-dict/DictExample.h

We need a LinkDef.h, as well.

examples/root-dict/DictLinkDef.h

Testing it

This is an example of a macro that tests the correct generation from the files listed above.

examples/root-dict/CheckLoad.C

import:'main', lang:'cmake'
import, lang:'c_cpp'
import, lang:'c_cpp'
import, lang:'c_cpp'
import, lang:'c_cpp'