get_std_cmake_args delegates to CMakePackage._std_args fixes #2665 (#2805)

This commit is contained in:
Massimiliano Culpo 2017-01-15 11:34:15 +01:00 committed by Todd Gamblin
parent 957cb968c6
commit 436f6a4ab6
3 changed files with 55 additions and 14 deletions

View File

@ -432,19 +432,15 @@ def get_rpaths(pkg):
return rpaths
def get_std_cmake_args(cmake_pkg):
# standard CMake arguments
ret = ['-DCMAKE_INSTALL_PREFIX=%s' % cmake_pkg.prefix,
'-DCMAKE_BUILD_TYPE=RelWithDebInfo',
'-DCMAKE_VERBOSE_MAKEFILE=ON']
if platform.mac_ver()[0]:
ret.append('-DCMAKE_FIND_FRAMEWORK=LAST')
def get_std_cmake_args(pkg):
"""Returns the list of standard arguments that would be used if this
package was a CMakePackage instance.
# Set up CMake rpath
ret.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE')
ret.append('-DCMAKE_INSTALL_RPATH=%s' % ":".join(get_rpaths(cmake_pkg)))
:param pkg: pkg under consideration
return ret
:return: list of arguments for cmake
"""
return spack.CMakePackage._std_args(pkg)
def parent_class_modules(cls):

View File

@ -0,0 +1,42 @@
##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/spack
# Please also see the LICENSE file for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import spack
from spack.build_environment import get_std_cmake_args
from spack.spec import Spec
def test_cmake_std_args(config, builtin_mock):
# Call the function on a CMakePackage instance
s = Spec('cmake-client')
s.concretize()
pkg = spack.repo.get(s)
assert pkg.std_cmake_args == get_std_cmake_args(pkg)
# Call it on another kind of package
s = Spec('mpich')
s.concretize()
pkg = spack.repo.get(s)
assert get_std_cmake_args(pkg)

View File

@ -32,15 +32,13 @@ def check(condition, msg):
raise InstallError(msg)
class CmakeClient(Package):
class CmakeClient(CMakePackage):
"""A dumy package that uses cmake."""
homepage = 'https://www.example.com'
url = 'https://www.example.com/cmake-client-1.0.tar.gz'
version('1.0', '4cb3ff35b2472aae70f542116d616e63')
depends_on('cmake', type='build')
def setup_environment(self, spack_env, run_env):
spack_cc # Ensure spack module-scope variable is avaiabl
check(from_cmake == "from_cmake",
@ -68,6 +66,11 @@ def setup_dependent_package(self, module, dspec):
"link arg on dependency spec not readable from "
"setup_dependent_package.")
def cmake(self, spec, prefix):
pass
build = cmake
def install(self, spec, prefix):
# check that cmake is in the global scope.
global cmake