CMakePackage : added hook for roo CmakeLists.txt, removed duplicated code from build_environment.py

This commit is contained in:
alalazo 2016-07-14 12:04:24 +02:00
parent 1ecea4c2f1
commit b8fccb5f61
2 changed files with 18 additions and 14 deletions

View file

@ -344,16 +344,8 @@ def set_module_variables_for_package(pkg, module):
m.cmake = Executable('cmake') m.cmake = Executable('cmake')
m.ctest = Executable('ctest') m.ctest = Executable('ctest')
# standard CMake arguments # Standard CMake arguments
m.std_cmake_args = ['-DCMAKE_INSTALL_PREFIX=%s' % pkg.prefix, m.std_cmake_args = spack.CMakePackage._std_args(pkg)
'-DCMAKE_BUILD_TYPE=RelWithDebInfo']
if platform.mac_ver()[0]:
m.std_cmake_args.append('-DCMAKE_FIND_FRAMEWORK=LAST')
# Set up CMake rpath
m.std_cmake_args.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE')
m.std_cmake_args.append('-DCMAKE_INSTALL_RPATH=%s' %
":".join(get_rpaths(pkg)))
# Put spack compiler paths in module scope. # Put spack compiler paths in module scope.
link_dir = spack.build_env_path link_dir = spack.build_env_path

View file

@ -1655,17 +1655,29 @@ class CMakePackage(PackageBase):
def build_type(self): def build_type(self):
return 'RelWithDebInfo' return 'RelWithDebInfo'
def root_cmakelists_dir(self):
return self.source_directory
@property @property
def std_cmake_args(self): def std_cmake_args(self):
# standard CMake arguments # standard CMake arguments
args = ['-DCMAKE_INSTALL_PREFIX:PATH={0}'.format(self.prefix), return CMakePackage._std_args(self)
'-DCMAKE_BUILD_TYPE:STRING={0}'.format(self.build_type())]
@staticmethod
def _std_args(pkg):
try:
build_type = pkg.build_type()
except AttributeError:
build_type = 'RelWithDebInfo'
args = ['-DCMAKE_INSTALL_PREFIX:PATH={0}'.format(pkg.prefix),
'-DCMAKE_BUILD_TYPE:STRING={0}'.format(build_type)]
if platform.mac_ver()[0]: if platform.mac_ver()[0]:
args.append('-DCMAKE_FIND_FRAMEWORK:STRING=LAST') args.append('-DCMAKE_FIND_FRAMEWORK:STRING=LAST')
# Set up CMake rpath # Set up CMake rpath
args.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE') args.append('-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE')
rpaths = ':'.join(spack.build_environment.get_rpaths(self)) rpaths = ':'.join(spack.build_environment.get_rpaths(pkg))
args.append('-DCMAKE_INSTALL_RPATH:STRING={0}'.format(rpaths)) args.append('-DCMAKE_INSTALL_RPATH:STRING={0}'.format(rpaths))
return args return args
@ -1676,7 +1688,7 @@ def cmake_args(self):
return list() return list()
def cmake(self, spec, prefix): def cmake(self, spec, prefix):
options = [self.source_directory] + self.std_cmake_args + self.cmake_args() options = [self.root_cmakelists_dir()] + self.std_cmake_args + self.cmake_args()
create = not os.path.exists(self.wdir()) create = not os.path.exists(self.wdir())
with working_dir(self.wdir(), create=create): with working_dir(self.wdir(), create=create):
inspect.getmodule(self).cmake(*options) inspect.getmodule(self).cmake(*options)