diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-10-18 19:40:49 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2019-02-07 08:26:31 +0000 |
commit | 97df448edbc035a2f531508a5cfe5739fb2de18d (patch) | |
tree | 732de8143e1dcb6a5b25e25eb8ec2954bf8ac87f /README.cmake.md | |
parent | 9a371088d6b8e8a0986a30a8dfb0076669275103 (diff) |
Modernize cmake build
Add a CMake super project that includes the shiboken2, PySide2 and
pyside2-tools subprojects, so that it's possible to build everything
from Qt Creator (or any other IDE that supports CMake)
with minimal set up effort, and thus inform the IDE CMake integration
of all relevant files, for easier code editing, navigation and
refactoring.
This also lays the foundation for allowing 3rd parties to use the
shiboken2 generator to generate custom modules. This is
achieved by eliminating various hardcoded paths for libraries and
include directories.
Start using CMake targets throughout the build code to correctly
propagate link flags and include dirs for libshiboken and
shiboken2 executable targets. Same for the libpyside target.
Generate two separate cmake config files (build-tree / install-tree)
that can be used with find_package(Shiboken2), to make sure that
the PySide2 project can be built as part of the super project build.
This is currently the only way I've found to allow the super build
to work.
Note that for the build-tree find_package() to work, the
CMAKE_MODULE_PATH has to be adjusted in the super project file.
The generated config files contain variables and logic that allow
usage of the installed shiboken package in downstream projects
(PySide2). This involves things like getting the includes and
libraries for the currently found python interpreter, the shiboken
build type (release or debug), was shiboken built with limited
api support, etc.
Generate 2 separate (build-tree and install-tree) config files
for PySide2, similar to how it's done for the shiboken case, for
pyside2-tools to build correctly.
Install shiboken2 target files using install(EXPORT)
to allow building PySide2 with an installed Shiboken2 package
(as opposed to one that is built as part of the super project).
Same with PySide2 targets for pyside2-tools subproject.
Make sure not to redefine uninstall targets if they are already
defined.
Add a --shorter-paths setup.py option, which would be used by
the Windows CI, to circumvent creating paths that are too long,
and thus avoiding build issues.
Output the build characteristics / classifiers into the generated
build_history/YYYY-MM-DD_AAAAAA/build_dir.txt file, so it can be
used by the test runner to properly filter out blacklisted
tests. This was necessary due to the shorter paths options.
Fix various issues regarding target includes and library
dependencies.
Remove certain duplicated cmake code (like limited api check and build
type checks) in PySide2, given that that information will now be
present in the exported shiboken2 config file.
Include a short README.cmake.md file that describes how to build
the super project.
References used
https://rix0r.nl/blog/2015/08/13/cmake-guide/
https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
https://cliutils.gitlab.io/modern-cmake/chapters/basics/functions.html
https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
https://github.com/ComicSansMS/libstratcom/blob/master/CMakeLists.txt
Abandoned approach using ExternalProject references:
https://cmake.org/cmake/help/latest/module/ExternalProject.html
https://stackoverflow.com/questions/44990964/how-to-perform-cmakefind-package-at-build-stage-only
Fixes: PYSIDE-919
Change-Id: Iaa15d20b279a04c5e16ce2795d03f912bc44a389
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'README.cmake.md')
-rw-r--r-- | README.cmake.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/README.cmake.md b/README.cmake.md new file mode 100644 index 000000000..60c446e8d --- /dev/null +++ b/README.cmake.md @@ -0,0 +1,39 @@ +# CMake super project +For development convenience, a CMake super project is included in the root of the repository. + +The super project can be built using standalone CMake, or using an IDE's CMake integration +(Qt Creator for example). + +Nevertheless the default build process is done via setup.py, in which case each of the +sub-projects are built and installed separately, as mentioned, the super project is just +for development convenience. + +## IDE (Qt Creator) case + +When using an IDE, just open the root CMakeLists.txt file as a new project, and make sure to +specify the following things: + + * LLVM_INSTALL_DIR - the environment variable should point to your libclang library location + * Qt - either select a Qt Kit when configuring the project, or make sure that the + qmake binary is present in the PATH environment variable. + * Python - the PATH environment variable should also point to the Python interpreter + which you wish to use for building the projects (can either be a system + interpreter, or a virtualenv one for example) + +Once that is done, just re-run CMake, so that it picks up the new environment values. +If needed, all other cache variables defined by the project files can be re-adjusted +(for example FORCE_LIMITED_API). + +## Command line CMake case + +When building using the command line CMake binary, make sure to invoke it in a separate +build directory, and not in the root source directory. + +Make sure you have the correct environment variables set up, as described in the previous section. + +The invocation would then look like: +```bash +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +# make or nmake or msbuild or jom +``` |