Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: Maciej Mrozowski <reavertm@×××××.com>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 1/2] cmake-utils.eclass: CMake argument passing rework - clean build_rules and toolchain_file files from unrelated stuff (pass to CMake directly) - move some invariant CMake options actually to invariants parts - eliminate common_config (pass to CMake directly) for better transparency
Date: Thu, 03 Nov 2016 06:31:26
Message-Id: 20161103073110.6093f557.mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/2] cmake-utils.eclass: CMake argument passing rework - clean build_rules and toolchain_file files from unrelated stuff (pass to CMake directly) - move some invariant CMake options actually to invariants parts - eliminate common_config (pass to CMake directly) for better transparency by Maciej Mrozowski
1 On Thu, 3 Nov 2016 00:52:16 +0100
2 Maciej Mrozowski <reavertm@×××××.com> wrote:
3
4 > From: Maciej Mrozowski <reavertm@g.o>
5 >
6 > ---
7 > eclass/cmake-utils.eclass | 54 ++++++++++++++++++-----------------------------
8 > 1 file changed, 21 insertions(+), 33 deletions(-)
9 >
10 > diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
11 > index 393ee28..88d2163 100644
12 > --- a/eclass/cmake-utils.eclass
13 > +++ b/eclass/cmake-utils.eclass
14 > @@ -517,13 +517,10 @@ enable_cmake-utils_src_configure() {
15 > includes="<INCLUDES>"
16 > fi
17 > cat > "${build_rules}" <<- _EOF_ || die
18 > - SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
19 > SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${includes} ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
20 > SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
21 > SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
22 > SET (CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> ${includes} ${FCFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "Fortran compile command" FORCE)
23 > - SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
24 > - SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE)
25 > _EOF_
26 >
27 > local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake
28 > @@ -531,6 +528,8 @@ enable_cmake-utils_src_configure() {
29 > SET (CMAKE_C_COMPILER $(tc-getCC))
30 > SET (CMAKE_CXX_COMPILER $(tc-getCXX))
31 > SET (CMAKE_Fortran_COMPILER $(tc-getFC))
32 > + SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
33 > + SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
34 > _EOF_
35 >
36 > if tc-is-cross-compiler; then
37 > @@ -571,32 +570,29 @@ enable_cmake-utils_src_configure() {
38 > # in Prefix we need rpath and must ensure cmake gets our default linker path
39 > # right ... except for Darwin hosts
40 > IF (NOT APPLE)
41 > - SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
42 > - SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)"
43 > - CACHE STRING "" FORCE)
44 > -
45 > + SET (CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
46 > + SET (CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH "${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
47 > ELSE ()
48 > -
49 > - SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX}" CACHE STRING "" FORCE)
50 > - SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
51 > - SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
52 > - SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "")
53 > - SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
54 > - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
55 > - SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX}/lib" CACHE STRING "" FORCE)
56 > -
57 > + SET(CMAKE_PREFIX_PATH "${EPREFIX}${PREFIX}" CACHE STRING "" FORCE)
58 > + SET(CMAKE_SKIP_BUILD_RPATH OFF CACHE BOOL "" FORCE)
59 > + SET(CMAKE_SKIP_RPATH OFF CACHE BOOL "" FORCE)
60 > + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE CACHE BOOL "")
61 > + SET(CMAKE_INSTALL_RPATH "${EPREFIX}${PREFIX}/lib;${EPREFIX}/usr/${CHOST}/lib/gcc;${EPREFIX}/usr/${CHOST}/lib;${EPREFIX}/usr/$(get_libdir);${EPREFIX}/$(get_libdir)" CACHE STRING "" FORCE)
62 > + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "" FORCE)
63 > + SET(CMAKE_INSTALL_NAME_DIR "${EPREFIX}${PREFIX}/lib" CACHE STRING "" FORCE)
64 > ENDIF (NOT APPLE)
65 > _EOF_
66 > fi
67 >
68 > # Common configure parameters (invariants)
69 > - local common_config=${BUILD_DIR}/gentoo_common_config.cmake
70 > local libdir=$(get_libdir)
71 > - cat > "${common_config}" <<- _EOF_ || die
72 > - SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
73 > - SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
74 > - _EOF_
75 > - [[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
76 > + local cmakeargs=(
77 > + -DLIB_SUFFIX="${libdir/lib}"
78 > + -DCMAKE_INSTALL_LIBDIR="${libdir}"
79 > + -DPKG_CONFIG_EXECUTABLE="$(type -P $(tc-getPKG_CONFIG))"
80 > + -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
81 > + -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
82 > + )
83
84 Wasn't the point of using a config file to avoid warnings when the
85 variables aren't used?
86
87 >
88 > # Convert mycmakeargs to an array, for backwards compatibility
89 > # Make the array a local variable since <=portage-2.1.6.x does not
90 > @@ -615,25 +611,17 @@ enable_cmake-utils_src_configure() {
91 > local mycmakeargs_local=("${mycmakeargs[@]}")
92 > fi
93 >
94 > - if [[ ${CMAKE_WARN_UNUSED_CLI} == no ]] ; then
95 > - local warn_unused_cli="--no-warn-unused-cli"
96 > - else
97 > - local warn_unused_cli=""
98 > - fi
99 > -
100 > # Common configure parameters (overridable)
101 > # NOTE CMAKE_BUILD_TYPE can be only overriden via CMAKE_BUILD_TYPE eclass variable
102 > # No -DCMAKE_BUILD_TYPE=xxx definitions will be in effect.
103 > - local cmakeargs=(
104 > - ${warn_unused_cli}
105 > - -C "${common_config}"
106 > + cmakeargs+=(
107 > + $([[ ${CMAKE_WARN_UNUSED_CLI} == no ]] && echo --no-warn-unused-cli)
108 > + $([[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo -DCMAKE_COLOR_MAKEFILE=OFF)
109 > -G "$(_cmake_generator_to_use)"
110 > -DCMAKE_INSTALL_PREFIX="${EPREFIX}${PREFIX}"
111 > "${mycmakeargs_local[@]}"
112 > -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
113 > $([[ ${EAPI} == [2345] ]] && echo -DCMAKE_INSTALL_DO_STRIP=OFF)
114 > - -DCMAKE_USER_MAKE_RULES_OVERRIDE="${build_rules}"
115 > - -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}"
116 > "${MYCMAKEARGS}"
117 > )
118 >
119
120
121
122 --
123 Best regards,
124 Michał Górny
125 <http://dev.gentoo.org/~mgorny/>

Replies