diff options
author | Brad King <brad.king@kitware.com> | 2019-08-23 18:27:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-28 17:20:36 (GMT) |
commit | facc240a45cb81f4437c7c41cf97ecb8d5b0ce55 (patch) | |
tree | ad68450ef9dcabdf32fe5711a3d899b57f55ea0d /Utilities | |
parent | bf832ccf01894bf605c17a89f2bc3babd24df108 (diff) | |
download | CMake-facc240a45cb81f4437c7c41cf97ecb8d5b0ce55.zip CMake-facc240a45cb81f4437c7c41cf97ecb8d5b0ce55.tar.gz CMake-facc240a45cb81f4437c7c41cf97ecb8d5b0ce55.tar.bz2 |
Utilities/Release: Add docker specs to build and test Linux binaries
These will allow anyone to produce portable binaries like those
published on `cmake.org`.
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/Release/README.rst | 57 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/Dockerfile | 35 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/base/Dockerfile | 30 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/cache.txt | 44 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/deps/Dockerfile | 142 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/deps/openssl-source.patch | 12 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/deps/qt-install.patch | 24 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/test/Dockerfile | 26 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/test/cache-ninja.txt | 4 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/test/test-make.bash | 17 | ||||
-rw-r--r-- | Utilities/Release/linux/x86_64/test/test-ninja.bash | 17 |
11 files changed, 408 insertions, 0 deletions
diff --git a/Utilities/Release/README.rst b/Utilities/Release/README.rst index 3752e06..e7f0eb3 100644 --- a/Utilities/Release/README.rst +++ b/Utilities/Release/README.rst @@ -6,6 +6,63 @@ on ``cmake.org``. See also the `CMake Source Code Guide`_. .. _`CMake Source Code Guide`: ../../Help/dev/source.rst +Docker +------ + +The ``linux/<arch>/`` directories contain Docker specifications that anyone +may use to produce Linux binaries for CMake: + +* ``linux/<arch>/base/Dockerfile``: + Produces a base image with a build environment for portable CMake binaries. + This image is published in the `kitware/cmake Docker Hub Repository`_ + with tag ``build-linux-<arch>-base-<date>``. + +* ``linux/<arch>/deps/Dockerfile``: + Produces an image with custom-built dependencies for portable CMake binaries. + This image is published in the `kitware/cmake Docker Hub Repository`_ + with tag ``build-linux-<arch>-deps-<date>``. + +* ``linux/<arch>/Dockerfile``: + Produce an image containing a portable CMake binary package for Linux. + Build this image using the CMake source directory as the build context. + The resulting image will have an ``/out`` directory containing the package. + For example: + + .. code-block:: console + + $ docker build --tag=cmake:build --network none \ + -f cmake-src/Utilities/Release/linux/$arch/Dockerfile cmake-src + $ docker container create --name cmake-build cmake:build + $ docker cp cmake-build:/out . + $ ls out/cmake-*-Linux-$arch.tar.gz + +* ``linux/<arch>/test/Dockerfile``: + Produces a base image with a test environment for packaged CMake binaries. + For example, build the test base image: + + .. code-block:: console + + $ docker build --tag=cmake:test-base \ + cmake-src/Utilities/Release/linux/$arch/test + + Then create a local ``test/Dockerfile`` to prepare an image with both the + CMake source tree and the above-built package:: + + FROM cmake:test-base + COPY cmake-src /opt/cmake/src/cmake + ADD out/cmake-<ver>-Linux-<arch>.tar.gz /opt/ + ENV PATH=/opt/cmake-<ver>-Linux-<arch>/bin:$PATH + + Build the test image and run it to drive testing: + + .. code-block:: console + + $ docker build --tag cmake:test --network none -f test/Dockerfile . + $ docker run --network none cmake:test bash test-make.bash + $ docker run --network none cmake:test bash test-ninja.bash + +.. _`kitware/cmake Docker Hub Repository`: https://hub.docker.com/r/kitware/cmake + Scripts for Kitware ------------------- diff --git a/Utilities/Release/linux/x86_64/Dockerfile b/Utilities/Release/linux/x86_64/Dockerfile new file mode 100644 index 0000000..f3ba69c --- /dev/null +++ b/Utilities/Release/linux/x86_64/Dockerfile @@ -0,0 +1,35 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Produce an image containing a portable CMake binary package for Linux/x86_64. +# Build using the CMake source directory as the build context. +# The resulting image will have an '/out' directory containing the package. + +ARG FROM_IMAGE_NAME=kitware/cmake:build-linux-x86_64-deps-2019-08-09 +ARG FROM_IMAGE_DIGEST=@sha256:630c320b26a67fc584e0bc98314f1fb0cb0abc764348bb2613ef07437f7101f9 +ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST +FROM $FROM_IMAGE + +COPY . /opt/cmake/src/cmake + +ARG TEST=true + +RUN : \ + && mkdir -p /opt/cmake/src/cmake-build \ + && cd /opt/cmake/src/cmake-build \ + && cp ../cmake/Utilities/Release/linux/x86_64/cache.txt CMakeCache.txt \ + && source /opt/rh/devtoolset-6/enable \ + && source /opt/rh/rh-python36/enable \ + && export LANG=en_US.UTF-8 \ + && set -x \ + && ../cmake/bootstrap --parallel=$(nproc) --docdir=doc/cmake \ + && nice make -j $(nproc) \ + && if $TEST; then \ + # Run tests that require the full build tree. + bin/ctest --output-on-failure -j 8 -R '^(CMake\.|CMakeLib\.|CMakeServerLib\.|RunCMake\.ctest_memcheck)'; \ + fi \ + && bin/cpack -G TGZ \ + && set +x \ + && mkdir /out \ + && mv cmake-*-Linux-x86_64.tar.gz /out \ + && : diff --git a/Utilities/Release/linux/x86_64/base/Dockerfile b/Utilities/Release/linux/x86_64/base/Dockerfile new file mode 100644 index 0000000..dfc7df8 --- /dev/null +++ b/Utilities/Release/linux/x86_64/base/Dockerfile @@ -0,0 +1,30 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Produce a base image with a build environment for portable CMake binaries. +# Build using the directory containing this file as its own build context. + +ARG FROM_IMAGE_NAME=centos:6 +ARG FROM_IMAGE_DIGEST=@sha256:dec8f471302de43f4cfcf82f56d99a5227b5ea1aa6d02fa56344986e1f4610e7 +ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST +FROM $FROM_IMAGE + +RUN : \ + && yum install -y centos-release-scl \ + && yum install -y \ + ca-certificates \ + curl \ + devtoolset-6-gcc \ + devtoolset-6-gcc-c++ \ + fontconfig-devel \ + freetype-devel \ + git \ + libX11-devel \ + libxcb-devel \ + make \ + patch \ + perl \ + rh-python36-python-pip \ + xz \ + && yum clean all \ + && : diff --git a/Utilities/Release/linux/x86_64/cache.txt b/Utilities/Release/linux/x86_64/cache.txt new file mode 100644 index 0000000..a2864e9 --- /dev/null +++ b/Utilities/Release/linux/x86_64/cache.txt @@ -0,0 +1,44 @@ +CMAKE_BUILD_TYPE:STRING=Release + +CMAKE_C_STANDARD:STRING=11 +CMAKE_CXX_STANDARD:STRING=14 + +# Require only older APIs where possible. +CMAKE_C_FLAGS:STRING=-D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1 + +# Link C++ library statically. +CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc + +# Enable ssl support in curl +CMAKE_USE_OPENSSL:BOOL=ON +OPENSSL_CRYPTO_LIBRARY:STRING=/opt/openssl/lib/libcrypto.a;-pthread +OPENSSL_INCLUDE_DIR:PATH=/opt/openssl/include +OPENSSL_SSL_LIBRARY:FILEPATH=/opt/openssl/lib/libssl.a + +# Enable ccmake +BUILD_CursesDialog:BOOL=ON +CURSES_FORM_LIBRARY:FILEPATH=/opt/ncurses/lib/libform.a +CURSES_INCLUDE_PATH:PATH=/opt/ncurses/include +CURSES_NCURSES_LIBRARY:FILEPATH=/opt/ncurses/lib/libncurses.a + +# Enable cmake-gui with static qt plugins +BUILD_QtDialog:BOOL=TRUE +CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3 +CMAKE_PREFIX_PATH:STRING=/opt/qt +CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES:STRING=/opt/qt/plugins/platforms/libqxcb.a;/opt/qt/lib/libQt5XcbQpa.a;/opt/qt/lib/libQt5ServiceSupport.a;/opt/qt/lib/libQt5EdidSupport.a;/opt/qt/lib/libQt5EventDispatcherSupport.a;/opt/qt/lib/libQt5FontDatabaseSupport.a;/opt/qt/lib/libQt5ThemeSupport.a;/opt/qt/lib/libxcb-static.a;-lxcb;-lfontconfig;-lfreetype + +# Build documentation. +SPHINX_EXECUTABLE:FILEPATH=/opt/rh/rh-python36/root/usr/bin/sphinx-build +SPHINX_HTML:BOOL=ON +SPHINX_MAN:BOOL=ON +SPHINX_QTHELP:BOOL=ON +QCOLLECTIONGENERATOR_EXECUTABLE:PATH=/opt/qt/bin/qhelpgenerator + +# We bootstrap as part of the build so skip its test. +CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE + +# Skip Qt5 tests because our Qt is static. +CMake_TEST_Qt5:BOOL=FALSE + +# CPack package file name component for this platform. +CPACK_SYSTEM_NAME:STRING=Linux-x86_64 diff --git a/Utilities/Release/linux/x86_64/deps/Dockerfile b/Utilities/Release/linux/x86_64/deps/Dockerfile new file mode 100644 index 0000000..db5551c --- /dev/null +++ b/Utilities/Release/linux/x86_64/deps/Dockerfile @@ -0,0 +1,142 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Produce an image with custom-built dependencies for portable CMake binaries. +# Build using the directory containing this file as its own build context. + +ARG FROM_IMAGE_NAME=kitware/cmake:build-linux-x86_64-base-2019-08-09 +ARG FROM_IMAGE_DIGEST=@sha256:d2c13617f01181a3143a069e4496d6b78eafffa19d181c42be196d5dfd588151 +ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST +FROM $FROM_IMAGE + +# Sphinx +RUN : \ + && source /opt/rh/rh-python36/enable \ + && pip install sphinx==2.1.2 \ + && : + +# Qt +# Version 5.12.0 was the last to bundle xkbcommon. +COPY qt-install.patch /opt/qt/src/ +RUN : \ + && mkdir -p /opt/qt/src/qt-build \ + && cd /opt/qt/src \ + && curl -OL https://download.qt.io/archive/qt/5.12/5.12.0/single/qt-everywhere-src-5.12.0.tar.xz \ + && sha512sum qt-everywhere-src-5.12.0.tar.xz | grep -q 0dd03d2645fb6dac5b58c8caf92b4a0a6900131f1ccfb02443a0df4702b5da0458f4c45e758d1b929ec709b0f4b36900df2fd60a058af9cc8c1a0748b6d57aae \ + && tar xJf qt-everywhere-src-5.12.0.tar.xz \ + && cd qt-build \ + && source /opt/rh/devtoolset-6/enable \ + && ../qt-everywhere-src-5.12.0/configure \ + -prefix /opt/qt \ + -static \ + -release \ + -c++std c++11 \ + -opensource -confirm-license \ + -gui \ + -widgets \ + -xcb \ + -fontconfig \ + -sql-sqlite \ + -qt-doubleconversion \ + -qt-libjpeg \ + -qt-libpng \ + -qt-pcre \ + -qt-sqlite \ + -qt-xcb \ + -qt-xkbcommon \ + -qt-zlib \ + -system-freetype \ + -no-accessibility \ + -no-compile-examples \ + -no-cups \ + -no-dbus \ + -no-directfb \ + -no-egl \ + -no-eglfs \ + -no-evdev \ + -no-gbm \ + -no-gif \ + -no-glib \ + -no-gtk \ + -no-harfbuzz \ + -no-iconv \ + -no-icu \ + -no-journald \ + -no-kms \ + -no-libinput \ + -no-libproxy \ + -no-linuxfb \ + -no-ltcg \ + -no-mirclient \ + -no-mtdev \ + -no-opengl \ + -no-openssl \ + -no-pch \ + -no-sql-mysql \ + -no-sql-psql \ + -no-sql-sqlite2 \ + -no-syslog \ + -no-system-proxies \ + -no-tslib \ + -no-use-gold-linker \ + -skip declarative \ + -skip multimedia \ + -skip qtcanvas3d \ + -skip qtconnectivity \ + -skip qtdeclarative \ + -skip qtlocation \ + -skip qtmultimedia \ + -skip qtsensors \ + -skip qtserialport \ + -skip qtsvg \ + -skip qtwayland \ + -skip qtwebchannel \ + -skip qtwebengine \ + -skip qtwebsockets \ + -skip qtwinextras \ + -skip qtxmlpatterns \ + -nomake examples \ + -nomake tests \ + && make install -j $(nproc) \ + && cd /opt/qt \ + && patch -p1 -i src/qt-install.patch \ + && cd /opt \ + && rm -rf /opt/qt/src \ + && : + +# Curses +RUN : \ + && mkdir -p /opt/ncurses/src/ncurses-build \ + && cd /opt/ncurses/src \ + && curl -O https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz \ + && sha512sum ncurses-6.1.tar.gz | grep -q e308af43f8b7e01e98a55f4f6c4ee4d1c39ce09d95399fa555b3f0cdf5fd0db0f4c4d820b4af78a63f6cf6d8627587114a40af48cfc066134b600520808a77ee \ + && tar xzf ncurses-6.1.tar.gz \ + && cd ncurses-build \ + && source /opt/rh/devtoolset-6/enable \ + && ../ncurses-6.1/configure \ + --prefix=/opt/ncurses \ + --with-terminfo-dirs=/etc/terminfo:/lib/terminfo:/usr/share/terminfo \ + --with-default-terminfo-dir=/usr/share/terminfo \ + --without-shared \ + && make -j $(nproc) \ + && make install.libs install.includes \ + && cd /opt \ + && rm -rf /opt/ncurses/src \ + && : + +# OpenSSL +COPY openssl-source.patch /opt/openssl/src/ +RUN : \ + && mkdir -p /opt/openssl/src \ + && cd /opt/openssl/src \ + && curl -O https://www.openssl.org/source/openssl-1.1.1c.tar.gz \ + && sha512sum openssl-1.1.1c.tar.gz | grep -q 8e2c5cc11c120efbb7d7850980cb6eaa782d29b4996b3f3378d37613c1679f852d7cc08a90d62e78fcec3439f06bdbee70064579a8c2adaffd91532a97f646ff \ + && tar xzf openssl-1.1.1c.tar.gz \ + && cd openssl-1.1.1c \ + && patch -p1 -i ../openssl-source.patch \ + && source /opt/rh/devtoolset-6/enable \ + && ./Configure --prefix=/opt/openssl linux-elf no-asm no-shared -D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1 \ + && make install_dev -j $(nproc) \ + && cd /opt \ + && rm -rf /opt/openssl/src \ + && : diff --git a/Utilities/Release/linux/x86_64/deps/openssl-source.patch b/Utilities/Release/linux/x86_64/deps/openssl-source.patch new file mode 100644 index 0000000..c81fe2f --- /dev/null +++ b/Utilities/Release/linux/x86_64/deps/openssl-source.patch @@ -0,0 +1,12 @@ +# enable pthread APIs disabled by our _POSIX_SOURCE definitions +--- openssl-source/crypto/threads_pthread.c.orig ++++ openssl-source/crypto/threads_pthread.c +@@ -6,6 +6,8 @@ + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ ++#undef _POSIX_C_SOURCE ++#undef _POSIX_SOURCE + + #include <openssl/crypto.h> + #include "internal/cryptlib.h" diff --git a/Utilities/Release/linux/x86_64/deps/qt-install.patch b/Utilities/Release/linux/x86_64/deps/qt-install.patch new file mode 100644 index 0000000..792aefd --- /dev/null +++ b/Utilities/Release/linux/x86_64/deps/qt-install.patch @@ -0,0 +1,24 @@ +# Add Qt Core dependencies missing from static Qt build. +--- qt-install/lib/cmake/Qt5Core/Qt5CoreConfig.cmake.orig ++++ qt-install/lib/cmake/Qt5Core/Qt5CoreConfig.cmake +@@ -111,7 +111,7 @@ + list(REMOVE_DUPLICATES Qt5Core_COMPILE_DEFINITIONS) + list(REMOVE_DUPLICATES Qt5Core_EXECUTABLE_COMPILE_FLAGS) + +- set(_Qt5Core_LIB_DEPENDENCIES "") ++ set(_Qt5Core_LIB_DEPENDENCIES "${_qt5Core_install_prefix}/lib/libqtpcre2.a") + + + add_library(Qt5::Core STATIC IMPORTED) +# Add Qt Gui dependencies missing from static Qt build. +--- qt-install/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake.orig ++++ qt-install/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake +@@ -111,7 +111,7 @@ + list(REMOVE_DUPLICATES Qt5Gui_COMPILE_DEFINITIONS) + list(REMOVE_DUPLICATES Qt5Gui_EXECUTABLE_COMPILE_FLAGS) + +- set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core") ++ set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core;${_qt5Gui_install_prefix}/lib/libqtlibpng.a") + + + add_library(Qt5::Gui STATIC IMPORTED) diff --git a/Utilities/Release/linux/x86_64/test/Dockerfile b/Utilities/Release/linux/x86_64/test/Dockerfile new file mode 100644 index 0000000..6629156 --- /dev/null +++ b/Utilities/Release/linux/x86_64/test/Dockerfile @@ -0,0 +1,26 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# Produce a base image with a test environment for packaged CMake binaries. +# Build using the directory containing this file as its own build context. + +ARG FROM_IMAGE_NAME=debian:9 +ARG FROM_IMAGE_DIGEST=@sha256:397b2157a9ea8d7f16c613aded70284292106e8b813fb1ed5de8a8785310a26a +ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST +FROM $FROM_IMAGE + +RUN : \ + && apt-get update \ + && apt-get install -y \ + dpkg \ + file \ + gcc \ + g++ \ + gfortran \ + qt5-default \ + make \ + ninja-build \ + && apt-get clean \ + && : + +COPY test-make.bash test-ninja.bash / diff --git a/Utilities/Release/linux/x86_64/test/cache-ninja.txt b/Utilities/Release/linux/x86_64/test/cache-ninja.txt new file mode 100644 index 0000000..b00370e --- /dev/null +++ b/Utilities/Release/linux/x86_64/test/cache-ninja.txt @@ -0,0 +1,4 @@ +CMAKE_Fortran_COMPILER:STRING= +CMake_TEST_IPO_WORKS_C:BOOL=ON +CMake_TEST_IPO_WORKS_CXX:BOOL=ON +CMake_TEST_Qt5:BOOL=ON diff --git a/Utilities/Release/linux/x86_64/test/test-make.bash b/Utilities/Release/linux/x86_64/test/test-make.bash new file mode 100644 index 0000000..10d30c3 --- /dev/null +++ b/Utilities/Release/linux/x86_64/test/test-make.bash @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set -e +set -x +mkdir -p /opt/cmake/src/cmake-make +cd /opt/cmake/src/cmake-make +echo >CMakeCache.txt ' +CMake_TEST_IPO_WORKS_C:BOOL=ON +CMake_TEST_IPO_WORKS_CXX:BOOL=ON +CMake_TEST_IPO_WORKS_Fortran:BOOL=ON +CMake_TEST_NO_NETWORK:BOOL=ON +CMake_TEST_Qt5:BOOL=ON +' +cmake ../cmake -DCMake_TEST_HOST_CMAKE=1 -G "Unix Makefiles" +make -j $(nproc) +ctest --output-on-failure -j $(nproc) diff --git a/Utilities/Release/linux/x86_64/test/test-ninja.bash b/Utilities/Release/linux/x86_64/test/test-ninja.bash new file mode 100644 index 0000000..fe39e2e --- /dev/null +++ b/Utilities/Release/linux/x86_64/test/test-ninja.bash @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set -e +set -x +mkdir -p /opt/cmake/src/cmake-ninja +cd /opt/cmake/src/cmake-ninja +echo >CMakeCache.txt ' +CMAKE_Fortran_COMPILER:STRING= +CMake_TEST_IPO_WORKS_C:BOOL=ON +CMake_TEST_IPO_WORKS_CXX:BOOL=ON +CMake_TEST_NO_NETWORK:BOOL=ON +CMake_TEST_Qt5:BOOL=ON +' +cmake ../cmake -DCMake_TEST_HOST_CMAKE=1 -G "Ninja" +ninja +ctest --output-on-failure -j $(nproc) |