Table of Contents
There are a few pitfalls that one should be aware of when migrating from .pro files
to CMake files, even when using the .pro file converter in MeVisLab.
MeVisLab has an interactive tool for converting .pro files into CMake files.
This is accessible through the MeVisLab main menu, select
Scripting → Migration → Convert Pro Files to CMake...
This is how it looks like (with a package from the Standard SDK converted):
Select in the upper bar the directory of the .pro files that should
(recursively) be converted with the Browse... button. The directory is
persistent, so there is no need to re-enter the directory for another try.
The Options... button opens a small dialog where one can define which packages should get which CMake namespace. A sample definition could look like this:
MyPackageGroup/*=MyNamespace
MyPackageGroup/MySpecialPackage=MySpecialNamespace
This is also persistent, so this needs to be entered only once.
After entering this data, pressing the Convert button starts the process.
The script will now first scan all packages for package .pri files
(which it will need to
correctly assign CMake namespaces to the entries in the CONFIG variable).
Then it will convert the requested .pro files. The resulting files are not
written back immediately, but listed in the area below, where they can be inspected and saved
manually.
The list on the left side displays all the converted files and directories. Note that one can
also click on intermediate directories, since CMakeLists.txt files are
generated for these too (for the necessary
add_subdirectory
statements).
If there were any errors during the conversion,
a number on the right of the item will show how many errors were emitted for this file.
The area to the right of the list allows the inspection of the conversion itself.
The left half shows the original .pro file (if one selects a .pro file,
for directories this stays empty).
The right half shows the resulting file under the Generated tab.
If there is already a file in this place, its content is shown under the
Existing tab. The target file name is shown below this area on the right
(usually it is "CMakeLists.txt", but if more than one .pro
file is in a directory, the converter will decide to work with include files that end on
.cmake).
Below this are two buttons Explore and Save. Explore will open the file explorer at the selected location. Save will save the currently selected file. The keyboard shortcut Ctrl+S will also do this.
![]() |
Note |
|---|---|
All files are saved together with the Save All button below the directory/file tree (keyboard shortcut Ctrl+Shift+S). |
The area below the text areas shows the warnings/errors that happened for the selected file. One should inspect any errors and modify the generated file if necessary.
The entries in the CONFIG variable usually denote other libraries that the project
links against.
The name stays the same for entries that are found in one's own package .pri files,
but is prefixed with the CMake namespace that was defined in the dialog opened by the
Options... button. The known exports of the StandardSDK on the other hand are
converted through an internal list. These are then added as arguments of the
target_link_libraries
function.
Occasionally an entry in the CONFIG variable is unknown. The converter
will still treat this as a library to link, but will prefix it with the UNKNOWN
namespace. To resolve this, one needs to find either what the correct CMake name for this
library is, or if this is not a library at all and just serves some other purpose. In this case one
might perhaps use an
option
statement to define an optional variable, and some
if
statement afterwards that uses this variable, and has the necessary
statements in its body. What these statements should look like is out of scope for the converter
and this text.
Include directories in CMake are specified through the
target_include_directories
directive. One important aspect of this is that the directories are specified differently
for in-build use and after installation (this assumes that the target library is installed
in a completely different directory).
For in-build use, include directories are specified as absolute paths, using the
CMAKE_CURRENT_SOURCE_DIR variable, and in a generator expression that only expands
for the in-build use. Example:
target_include_directories(MLModuleWrapperExample PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/someSubDirectory>
)
These directories should be PUBLIC if other libraries build against
this library.
For building against the installed library, include directories are specified as relative
paths, but relative to the installation folder.
If one uses the
mlab_install_headers
directive, it is not necessary to do anything
if your include directory is the source directory of your library itself, or a sub-folder called
include, Include, or src,
since mlab_install_headers sets this
automatically. Otherwise it is necessary to add a statement like this:
# compute relative installation directory:
file(RELATIVE_PATH REL ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(MLModuleWrapperExample PUBLIC
$<INSTALL_INTERFACE:${REL}/someSubDirectory>
)
© 2026 MeVis Medical Solutions AG