Skip to content

scandyna/mdt-cmake-modules

Repository files navigation

mdt-cmake-modules

Some CMake modules used in my projects

pipeline status

[[TOC]]

Usage

Add the following to your CMakeLists.txt:

find_package(MdtCMakeModules REQUIRED)

This will also add the path to the installed MdtCMakeModules to CMAKE_MODULE_PATH (if not allready exists).

Then the required modules can be used:

include(AddQt5ToCMakePrefixPath)

For the available CMake modules and their usage, see the documentation page

Project using Conan

If you use Conan, add MdtCMakeModules as requirement:

[tool_requires]
MdtCMakeModules/x.y.z@scandyna/testing

[generators]
CMakeDeps
CMakeToolchain

Add the remote:

conan remote add gitlab https://gitlab.com/api/v4/projects/25668674/packages/conan

Install the dependencies:

mkdir build && cd build
conan install .. --profile your_profile -s build_type=Debug

Configure your project:

cmake -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake ..

Maybe adjust some settings:

cmake-gui .

Build:

cmake --build . --config Debug

To run the tests:

ctest --output-on-failure -C Debug -j4 .

Manual install

It is also possible to install MdtCMakeModules locally. See INSTALL.

Then, configure your project and specify the path of the installed MdtCMakeModules:

cmake -DCMAKE_PREFIX_PATH=/some/path/MdtCMakeModules ..

Find MdtCMakeModules with CMake

In your CMakeLists.txt you can provide a cache variable:

set(MDT_CMAKE_MODULE_PREFIX_PATH CACHE PATH "Path to the root of MdtCMakeModules. (For example: /opt/MdtCMakeModules).")
if(MDT_CMAKE_MODULE_PREFIX_PATH)
  list(APPEND CMAKE_PREFIX_PATH "${MDT_CMAKE_MODULE_PREFIX_PATH}")
endif()

find_package(MdtCMakeModules REQUIRED)

Above method lets the user choose the path to MdtCMakeModules with cmake-gui .

Configuring the project could also be done on the command-line:

cmake -DMDT_CMAKE_MODULE_PREFIX_PATH=/some/path/MdtCMakeModules ..

CMAKE_PREFIX_PATH can also be used directly:

cmake -DCMAKE_PREFIX_PATH=/some/path/MdtCMakeModules ..

It is also possible to not use find_package() and sepcify the path using CMAKE_MODULE_PATH (not recommended):

cmake -DCMAKE_MODULE_PATH=/some/path/MdtCMakeModules/Modules ..

This last method requires to specify exactly where the modules are located. This will break if the internal directory organisation changes.

Work on MdtCMakeModules

Build

See BUILD.

Create Conan package

See README in the conan packaging folder.

Releases

No releases published

Packages

No packages published