- # Run cmake
- os.putenv('PKG_CONFIG_PATH', os.path.join(self.installDir, 'lib', 'pkgconfig')) # I found no way to do this within cmake
- subprocess.check_call(['cmake', self.sourceFolder, '-DCMAKE_BUILD_TYPE='+self.buildType,
- '-DCMAKE_INSTALL_PREFIX='+self.installDir]+self.projectConfig.get('cmakeParameters', []))
- os.unsetenv('PKG_CONFIG_PATH')
+ # Run cmake, in the proper environment, then restore old environment
+ oldPKGConfigPath = self.setEnv('PKG_CONFIG_PATH', os.path.join(self.config['installDir'], 'lib', 'pkgconfig'))
+ oldCMakePrefixPath = self.setEnv('CMAKE_PREFIX_PATH', self.config['installDir'])
+ oldXDGDataDirs = self.prependDirToEnv('XDG_DATA_DIRS', os.path.join(self.config['installDir'], 'share'), '/usr/share')
+ oldXDGConfigDirs = self.prependDirToEnv('XDG_CONFIG_DIRS', os.path.join(self.config['installDir'], 'etc', 'xdg'), '/etc/xdg')
+ subprocess.check_call(['cmake', self.sourceFolder, '-DCMAKE_BUILD_TYPE='+self.config['buildType'],
+ '-DCMAKE_INSTALL_PREFIX='+self.config['installDir']]+self.config.get('cmakeParameters', []))
+ self.restoreEnv('PKG_CONFIG_PATH', oldPKGConfigPath)
+ self.restoreEnv('CMAKE_PREFIX_PATH', oldCMakePrefixPath)
+ self.restoreEnv('XDG_DATA_DIRS', oldXDGDataDirs)
+ self.restoreEnv('XDG_CONFIG_DIRS', oldXDGConfigDirs)