diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-07-14 12:04:24 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-07-14 12:04:24 +0200 |
commit | b8fccb5f614cd0550c69b3e7951e94bfa9e41fca (patch) | |
tree | f8040466520702bc0796d5764eb01758847980fc | |
parent | 1ecea4c2f12f3f70bcfcdc46dc01acbf6d285f09 (diff) | |
download | spack-b8fccb5f614cd0550c69b3e7951e94bfa9e41fca.tar.gz spack-b8fccb5f614cd0550c69b3e7951e94bfa9e41fca.tar.bz2 spack-b8fccb5f614cd0550c69b3e7951e94bfa9e41fca.tar.xz spack-b8fccb5f614cd0550c69b3e7951e94bfa9e41fca.zip |
CMakePackage : added hook for roo CmakeLists.txt, removed duplicated code from build_environment.py
-rw-r--r-- | lib/spack/spack/build_environment.py | 12 | ||||
-rw-r--r-- | lib/spack/spack/package.py | 20 |
2 files changed, 18 insertions, 14 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 839991deaa..ec03caef94 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -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 diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index c90fd5808b..c22625e44e 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -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 @@ class CMakePackage(PackageBase): 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) |