您如何在Eclipse中更改cmake生成器?

时间:2019-03-21 22:56:37

标签: eclipse cmake

由于某种原因,当我尝试在Eclipse中构建时,它会强制-G Ninja。我希望Eclipse只是不将-G选项指定为cmake,但我不知道如何配置Eclipse来做到这一点。

例如,在我的控制台窗口中:

Building in: /home/bgass/eclipse-workspace/scomlib/build/default
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
CMake Error: Error: generator : Ninja
Does not match the generator used previously: Unix Makefiles
Either remove the CMakeCache.txt file or choose a different binary directory.
cmake --build . -- -v
GNU Make 4.2.1
Built for x86_64-redhat-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Build complete (0 errors, 0 warnings): /home/bgass/eclipse-workspace/scomlib/build/default

在终端中,无需指定生成器就可以正常工作。

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/bgass/eclipse-workspace/scomlib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bgass/eclipse-workspace/scomlib/build/default

1 个答案:

答案 0 :(得分:1)

我总是在Eclipse外执行.filter(),并在Eclipse中打开生成的Eclipse项目。

使用const data = [{ name: 'John', date: '24 April 2001', sex: 'male' }, { name: 'steve', date: '12 August 2012', sex: 'male' }, { name: 'natasha', date: '13 October 1992', sex: 'female' }, { name: 'chris', date: '8 September 2004', sex: 'remain unknown' }] sortAndFilter = (arr, orderBy, order, filterBy, filterValue, dataType) => { let result; if (filterValue === '') { if (dataType === 'string') { switch (order) { case 'asc': result = arr.sort((a, b) => a[orderBy].localeCompare(b[orderBy])); break; case 'dsc': result = arr.sort((a, b) => b[orderBy].localeCompare(a[orderBy])); break; default: result = arr.sort((a, b) => a[orderBy].localeCompare(b[orderBy])); } } else if (dataType === 'date') { switch (order) { case 'asc': result = arr.sort((a, b) => new Date(a[orderBy]) - new Date(b[orderBy])); break; case 'dsc': result = arr.sort((a, b) => new Date(b[orderBy]) - new Date(a[orderBy])); break; default: result = arr.sort((a, b) => new Date(a[orderBy]) - new Date(b[orderBy])); } } } else { if (dataType === 'string') { switch (order) { case 'asc': result = arr.sort((a, b) => a[orderBy].localeCompare(b[orderBy])).filter(el => el[filterBy] === filterValue); break; case 'dsc': result = arr.sort((a, b) => b[orderBy].localeCompare(a[orderBy])).filter(el => el[filterBy] === filterValue); break; default: result = arr.sort((a, b) => a[orderBy].localeCompare(b[orderBy])).filter(el => el[filterBy] === filterValue); } } else if (dataType === 'date') { switch (order) { case 'asc': result = arr.sort((a, b) => new Date(a[orderBy]) - new Date(b[orderBy])).filter(el => el[filterBy] === filterValue); break; case 'dsc': result = arr.sort((a, b) => new Date(b[orderBy]) - new Date(a[orderBy])).filter(el => el[filterBy] === filterValue); break; default: result = arr.sort((a, b) => new Date(a[orderBy]) - new Date(b[orderBy])).filter(el => el[filterBy] === filterValue); } } } return result; } sortAndFilter(data, 'name', 'asc', 'sex', 'male', 'string'); console.log('this is not filtered: ', data); const finalData = sortAndFilter(data, 'name', 'asc', 'sex', 'male', 'string'); console.log('this one is sorted and filtered: ', finalData);将Eclipse指定为生成器。

以下是全套Eclipse生成器。

cmake

键入-G "Eclipse CDT4 - Unix Makefiles",以查看您的特定cmake版本支持哪些生成器。