CMake Port/Porting Guide: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
== Porting Notes ==
== Porting Notes ==
* Process of getting new CMakeLists.txt files, ideally:
 
** Run the conversion script pro2cmake.py
=== General porting guide ===
** Edit the places which fail by hand, add a comment "# special case" next to the manual changes, this helps with future git diffs when re-running the script.
There is a python script called '''pro2cmake.py''' in qtbase/cmake/utils.
** When the conversion script was fixed, and it is re-run:
 
*** Either the code next to the comment is fixed automatically
It takes a .pro file as input, and generates a CMakeLists.txt file in the same folder. You need to have python3 installed and a few packages from pip (pyparsing, sympy) to use the script.
*** Or the hand-edited version needs to be kept
 
Example:
python3 qtbase/util/cmake/pro2cmake.py qtbase/src/corelib/corelib.pro
 
The script does a good chunk of the conversion process for you, but you'll sometimes need to do manual fixes to the file. Make sure to mark those manual changes with a "# special case" marker. Example:
 
SOURCES
  foo.cpp
  bar.cpp # special case
 
This way when you re-run the script, you won't lose your manual modifications.
You can also use block special case markers:
# special case begin
LIBRARIES
  Qt::Gui
# special case end
 
There is also another script called run_pro2cmake.py which runs the first script recursively on all .pro files in the given folder. A good place to use it would be on the examples folder, or on the whole repository you are porting: Example:
python3 qtbase/util/cmake/run_pro2cmake.py qtbase/examples
python3 qtbase/util/cmake/run_pro2cmake.py qtsvg

Revision as of 14:33, 23 May 2019

Porting Notes

General porting guide

There is a python script called pro2cmake.py in qtbase/cmake/utils.

It takes a .pro file as input, and generates a CMakeLists.txt file in the same folder. You need to have python3 installed and a few packages from pip (pyparsing, sympy) to use the script.

Example:

python3 qtbase/util/cmake/pro2cmake.py qtbase/src/corelib/corelib.pro

The script does a good chunk of the conversion process for you, but you'll sometimes need to do manual fixes to the file. Make sure to mark those manual changes with a "# special case" marker. Example:

SOURCES
 foo.cpp
 bar.cpp # special case

This way when you re-run the script, you won't lose your manual modifications. You can also use block special case markers:

# special case begin
LIBRARIES
  Qt::Gui
# special case end

There is also another script called run_pro2cmake.py which runs the first script recursively on all .pro files in the given folder. A good place to use it would be on the examples folder, or on the whole repository you are porting: Example:

python3 qtbase/util/cmake/run_pro2cmake.py qtbase/examples
python3 qtbase/util/cmake/run_pro2cmake.py qtsvg