dev-qt/qttest: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / dev-util / cmake / cmake-3.16.5.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 CMAKE_MAKEFILE_GENERATOR="emake"
7 CMAKE_REMOVE_MODULES_LIST=( none )
8 inherit bash-completion-r1 cmake elisp-common flag-o-matic multiprocessing \
9         toolchain-funcs virtualx xdg-utils
10
11 MY_P="${P/_/-}"
12
13 DESCRIPTION="Cross platform Make"
14 HOMEPAGE="https://cmake.org/"
15 SRC_URI="https://cmake.org/files/v$(ver_cut 1-2)/${MY_P}.tar.gz"
16
17 LICENSE="CMake"
18 SLOT="0"
19 [[ "${PV}" = *_rc* ]] || \
20 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
21 IUSE="doc emacs ncurses qt5 test"
22 RESTRICT="!test? ( test )"
23
24 RDEPEND="
25         app-crypt/rhash
26         >=app-arch/libarchive-3.0.0:=
27         >=dev-libs/expat-2.0.1
28         >=dev-libs/jsoncpp-1.9.2-r2:0=
29         >=dev-libs/libuv-1.10.0:=
30         >=net-misc/curl-7.21.5[ssl]
31         sys-libs/zlib
32         virtual/pkgconfig
33         emacs? ( >=app-editors/emacs-23.1:* )
34         ncurses? ( sys-libs/ncurses:0= )
35         qt5? (
36                 dev-qt/qtcore:5
37                 dev-qt/qtgui:5
38                 dev-qt/qtwidgets:5
39         )
40 "
41 DEPEND="${RDEPEND}"
42 BDEPEND="
43         doc? (
44                 dev-python/requests
45                 dev-python/sphinx
46         )
47 "
48
49 S="${WORKDIR}/${MY_P}"
50
51 SITEFILE="50${PN}-gentoo.el"
52
53 PATCHES=(
54         # prefix
55         "${FILESDIR}"/${PN}-3.16.0_rc4-darwin-bundle.patch
56         "${FILESDIR}"/${PN}-3.14.0_rc3-prefix-dirs.patch
57         # Next patch requires new work from prefix people
58         #"${FILESDIR}"/${PN}-3.1.0-darwin-isysroot.patch
59
60         # handle gentoo packaging in find modules
61         "${FILESDIR}"/${PN}-3.15.0_rc2-FindBLAS.patch
62         "${FILESDIR}"/${PN}-3.14.0_rc1-FindLAPACK.patch
63         "${FILESDIR}"/${PN}-3.5.2-FindQt4.patch
64
65         # respect python eclasses
66         "${FILESDIR}"/${PN}-2.8.10.2-FindPythonLibs.patch
67         "${FILESDIR}"/${PN}-3.9.0_rc2-FindPythonInterp.patch
68
69         # upstream fixes (can usually be removed with a version bump)
70 )
71
72 cmake_src_bootstrap() {
73         # disable running of cmake in boostrap command
74         sed -i \
75                 -e '/"${cmake_bootstrap_dir}\/cmake"/s/^/#DONOTRUN /' \
76                 bootstrap || die "sed failed"
77
78         # execinfo.h on Solaris isn't quite what it is on Darwin
79         if [[ ${CHOST} == *-solaris* ]] ; then
80                 sed -i -e 's/execinfo\.h/blablabla.h/' \
81                         Source/kwsys/CMakeLists.txt || die
82         fi
83
84         tc-export CC CXX LD
85
86         # bootstrap script isn't exactly /bin/sh compatible
87         ${CONFIG_SHELL:-sh} ./bootstrap \
88                 --prefix="${T}/cmakestrap/" \
89                 --parallel=$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)") \
90                 || die "Bootstrap failed"
91 }
92
93 cmake_src_test() {
94         # fix OutDir and SelectLibraryConfigurations tests
95         # these are altered thanks to our eclass
96         sed -i -e 's:^#_cmake_modify_IGNORE ::g' \
97                 "${S}"/Tests/{OutDir,CMakeOnly/SelectLibraryConfigurations}/CMakeLists.txt \
98                 || die
99
100         pushd "${BUILD_DIR}" > /dev/null
101
102         local ctestargs
103         [[ -n ${TEST_VERBOSE} ]] && ctestargs="--extra-verbose --output-on-failure"
104
105         # Excluded tests:
106         #    BootstrapTest: we actualy bootstrap it every time so why test it.
107         #    BundleUtilities: bundle creation broken
108         #    CMakeOnly.AllFindModules: pthread issues
109         #    CTest.updatecvs: which fails to commit as root
110         #    Fortran: requires fortran
111         #    RunCMake.CompilerLauncher: also requires fortran
112         #    RunCMake.CPack_RPM: breaks if app-arch/rpm is installed because
113         #        debugedit binary is not in the expected location
114         #    RunCMake.CPack_DEB: breaks if app-arch/dpkg is installed because
115         #        it can't find a deb package that owns libc
116         #    TestUpload, which requires network access
117         "${BUILD_DIR}"/bin/ctest \
118                 -j "$(makeopts_jobs)" \
119                 --test-load "$(makeopts_loadavg)" \
120                 ${ctestargs} \
121                 -E "(BootstrapTest|BundleUtilities|CMakeOnly.AllFindModules|CompileOptions|CTest.UpdateCVS|Fortran|RunCMake.CompilerLauncher|RunCMake.PrecompileHeaders|RunCMake.CPack_(DEB|RPM)|TestUpload)" \
122                 || die "Tests failed"
123
124         popd > /dev/null
125 }
126
127 src_prepare() {
128         cmake_src_prepare
129
130         # disable Xcode hooks, bug #652134
131         if [[ ${CHOST} == *-darwin* ]] ; then
132                 sed -i -e 's/__APPLE__/__DISABLED_APPLE__/' \
133                         Source/cmGlobalXCodeGenerator.cxx || die
134         fi
135
136         # Add gcc libs to the default link paths
137         sed -i \
138                 -e "s|@GENTOO_PORTAGE_GCCLIBDIR@|${EPREFIX}/usr/${CHOST}/lib/|g" \
139                 -e "$(usex prefix-guest "s|@GENTOO_HOST@||" "/@GENTOO_HOST@/d")" \
140                 -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}/|g" \
141                 Modules/Platform/{UnixPaths,Darwin}.cmake || die "sed failed"
142         if ! has_version \>=${CATEGORY}/${PN}-3.4.0_rc1 ; then
143                 CMAKE_BINARY="${S}/Bootstrap.cmk/cmake"
144                 cmake_src_bootstrap
145         fi
146 }
147
148 src_configure() {
149         # Fix linking on Solaris
150         [[ ${CHOST} == *-solaris* ]] && append-ldflags -lsocket -lnsl
151
152         local mycmakeargs=(
153                 -DCMAKE_USE_SYSTEM_LIBRARIES=ON
154                 -DCMAKE_DOC_DIR=/share/doc/${PF}
155                 -DCMAKE_MAN_DIR=/share/man
156                 -DCMAKE_DATA_DIR=/share/${PN}
157                 -DSPHINX_MAN=$(usex doc)
158                 -DSPHINX_HTML=$(usex doc)
159                 -DBUILD_CursesDialog="$(usex ncurses)"
160                 -DBUILD_TESTING=$(usex test)
161         )
162
163         if use qt5 ; then
164                 mycmakeargs+=(
165                         -DBUILD_QtDialog=ON
166                         $(cmake_use_find_package qt5 Qt5Widgets)
167                 )
168         fi
169
170         cmake_src_configure
171 }
172
173 src_compile() {
174         cmake_src_compile
175         use emacs && elisp-compile Auxiliary/cmake-mode.el
176 }
177
178 src_test() {
179         virtx cmake_src_test
180 }
181
182 src_install() {
183         cmake_src_install
184
185         if use emacs; then
186                 elisp-install ${PN} Auxiliary/cmake-mode.el Auxiliary/cmake-mode.elc
187                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
188         fi
189
190         insinto /usr/share/vim/vimfiles/syntax
191         doins Auxiliary/vim/syntax/cmake.vim
192
193         insinto /usr/share/vim/vimfiles/indent
194         doins Auxiliary/vim/indent/cmake.vim
195
196         insinto /usr/share/vim/vimfiles/ftdetect
197         doins "${FILESDIR}/${PN}.vim"
198
199         dobashcomp Auxiliary/bash-completion/{${PN},ctest,cpack}
200
201         rm -r "${ED}"/usr/share/cmake/{completions,editors} || die
202 }
203
204 pkg_postinst() {
205         use emacs && elisp-site-regen
206         if use qt5; then
207                 xdg_icon_cache_update
208                 xdg_desktop_database_update
209                 xdg_mimeinfo_database_update
210         fi
211 }
212
213 pkg_postrm() {
214         use emacs && elisp-site-regen
215         if use qt5; then
216                 xdg_icon_cache_update
217                 xdg_desktop_database_update
218                 xdg_mimeinfo_database_update
219         fi
220 }