summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-02-01 10:48:07 +0100
committerMichal Klocek <michal.klocek@qt.io>2021-05-12 09:40:09 +0200
commitb8fb47478db06cac231a8a7222e7afbce7b3cf90 (patch)
treea9070f10735afcabddd477406f60420680f9828e /cmake
parenta282c7a36f8707e0777df201855ef0a8a1980de1 (diff)
Setup cmake project
Add the top level cmake project and ninja and gn cmake builds. Make ninja and gn build optional. With qmake we had four stages during the build: * configure (initial dependencies check) * qmake (build ninja, build gn, run gn) * make (compilation) * make install With cmake we have some limitations: a) we need to pass the build config to gn, however cmake evaluates generator expressions during the generation phase this means we need a recursive call to cmake b) qt-cmake qtbase logic (+syncqt) assumes "fixed" build locations to handle deployment of headers and libs (it uses CMAKE_BINARY_DIR for QT_BUILD_DIR) c) cmake can not run twice in the same build directory d) running recursive/child cmake, makes all generated targets not accessible during configure time of parent's cmake e) cmake can only "build" things for subdirectories To deal with mentioned limitations and to keep things simple we will split those steps into separate projects: * SUPERBUILD - this project does dependency checks, only evaluates features to show the build summary and passes them to EXAMPLES,LIBS,TESTS projects, it also runs the generator expression to feed LIBS project's cmake, it does not try to run syncqt as result of (b) and (c) * NINJA (build ninja) * GN (build gn) * LIBS - projects runs simplified feature evaluation (CONDITIONS resolved by SUPERBUILD cmake) to generate build headers (+syncqt), it also runs gn during configure and does all libs compilation. The project's source root must be "src" directory as a result of (a),(b),(c) * EXAMPLES - builds examples as a result of (d),(e) * TESTS - builds tests as a result of (d),(e) Each of projects will have three stages: configure, compile, install. Task-number: QTBUG-91760 Done-With: Jüri Valdmann <juri.valdmann@qt.io> Change-Id: I3b44decefa17f177e5e07c563796aa158a0b0ecb Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindGn.cmake23
-rw-r--r--cmake/FindNinja.cmake31
2 files changed, 54 insertions, 0 deletions
diff --git a/cmake/FindGn.cmake b/cmake/FindGn.cmake
new file mode 100644
index 000000000..dfbe5b363
--- /dev/null
+++ b/cmake/FindGn.cmake
@@ -0,0 +1,23 @@
+if (NOT DEFINED WEBENGINE_ROOT_BUILD_DIR)
+ set(WEBENGINE_ROOT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../..)
+endif()
+
+set(CMAKE_PROGRAM_PATH ${WEBENGINE_ROOT_BUILD_DIR}/install/bin)
+find_program(Gn_EXECUTABLE NAMES gn)
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(
+ Gn
+ REQUIRED_VARS Gn_EXECUTABLE)
+
+if(Gn_FOUND AND NOT TARGET Gn::gn)
+ add_executable(Gn::gn IMPORTED)
+ set_property(TARGET Gn::gn PROPERTY IMPORTED_LOCATION ${Gn_EXECUTABLE})
+endif()
+
+include(FeatureSummary)
+set_package_properties(Gn PROPERTIES
+ URL "https://gn.googlesource.com/gn/"
+ DESCRIPTION "Meta-build system"
+)
diff --git a/cmake/FindNinja.cmake b/cmake/FindNinja.cmake
new file mode 100644
index 000000000..3615d58b9
--- /dev/null
+++ b/cmake/FindNinja.cmake
@@ -0,0 +1,31 @@
+if (NOT DEFINED WEBENGINE_ROOT_BUILD_DIR)
+ set(WEBENGINE_ROOT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
+endif()
+
+set(CMAKE_PROGRAM_PATH ${WEBENGINE_ROOT_BUILD_DIR}/install/bin)
+find_program(Ninja_EXECUTABLE NAMES ninja ninja-build)
+
+if(Ninja_EXECUTABLE)
+ execute_process(
+ COMMAND ${Ninja_EXECUTABLE} --version
+ OUTPUT_VARIABLE Ninja_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ Ninja
+ REQUIRED_VARS Ninja_EXECUTABLE
+ VERSION_VAR Ninja_VERSION)
+
+if(Ninja_FOUND AND NOT TARGET Ninja::ninja)
+ add_executable(Ninja::ninja IMPORTED)
+ set_property(TARGET Ninja::ninja PROPERTY IMPORTED_LOCATION ${Ninja_EXECUTABLE})
+endif()
+
+include(FeatureSummary)
+set_package_properties(Ninja PROPERTIES
+ URL "https://ninja-build.org/"
+ DESCRIPTION "Build tool"
+)