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.ctest = Executable('ctest')
# standard CMake arguments
m.std_cmake_args = ['-DCMAKE_INSTALL_PREFIX=%s' % pkg.prefix,
'-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)))
# Standard CMake arguments
m.std_cmake_args = spack.CMakePackage._std_args(pkg)
# Put spack compiler paths in module scope.
link_dir = spack.build_env_path

View file

@ -1655,17 +1655,29 @@ class CMakePackage(PackageBase):
def build_type(self):
return 'RelWithDebInfo'
def root_cmakelists_dir(self):
return self.source_directory
@property
def std_cmake_args(self):
# standard CMake arguments
args = ['-DCMAKE_INSTALL_PREFIX:PATH={0}'.format(self.prefix),
'-DCMAKE_BUILD_TYPE:STRING={0}'.format(self.build_type())]
return CMakePackage._std_args(self)
@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]:
args.append('-DCMAKE_FIND_FRAMEWORK:STRING=LAST')
# Set up CMake rpath
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))
return args
@ -1676,7 +1688,7 @@ def cmake_args(self):
return list()
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())
with working_dir(self.wdir(), create=create):
inspect.getmodule(self).cmake(*options)