This repository has been archived by the owner on Feb 12, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Nava2/add-cmake-features
Add cmake features
- Loading branch information
Showing
10 changed files
with
226 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
build*/ | ||
|
||
CMakeCache.txt | ||
CMakeFiles/ | ||
|
||
#vscode | ||
.vscode/ | ||
|
||
# Jetbrains | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
comp_feature(auto_type "int main() {auto i = 0.f;}" COMP_CPP11_FLAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
# Taken from: | ||
# http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226 | ||
comp_feature(default_function_template_args | ||
"template <class T, class U = double> | ||
void f(T t = 0, U u = 0) | ||
{ (void)t; (void) u; } | ||
int main() | ||
{ | ||
f(1, 'c'); // f<int,char>(1,'c') | ||
f(1); // f<int,double>(1,0) | ||
// f(); // error: T cannot be deduced | ||
f<int>(); // f<int,double>(0,0) | ||
f<int,char>(); // f<int,char>(0,0) | ||
return 0; | ||
}" COMP_CPP11_FLAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
comp_feature(enum_class "enum class Colour: unsigned int { Red = 1, Blue = 3 }; | ||
int main() { const Colour c = Colour::Red; }" COMP_CPP11_FLAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
# Taken from: | ||
# http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226 | ||
comp_feature(lambdas | ||
"#include <algorithm> | ||
#include <cmath> | ||
void abssort(float *x, unsigned N) { | ||
std::sort(x, x+N, | ||
[](float a, float b) { | ||
return std::abs(a) < std::abs(b); | ||
}); | ||
} | ||
int main() | ||
{ | ||
float* arr = new float[20]; | ||
abssort(arr, 20); | ||
} | ||
" COMP_CPP11_FLAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
comp_feature(parameter_pack "template <typename... Tn> | ||
void f(const Tn&... args); | ||
template <typename T, typename... Tn> | ||
void f(const T& t, const Tn&... rest) | ||
{ (void)t; f(rest...); } | ||
template <> | ||
void f() | ||
{ } | ||
int main() | ||
{ f(1, 2); f(\"one\", 2); f(1); f(); } | ||
" COMP_CPP11_FLAG) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
comp_feature(range_for "int main() | ||
{ | ||
int array[3] = { 1, 2, 3 }; | ||
for (int& x : array) | ||
x *= 2; | ||
}" COMP_CPP11_FLAG) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (C) 2015-2016 Jonathan Müller <jonathanmueller.dev@gmail.com> | ||
# This file is subject to the license terms in the LICENSE file | ||
# found in the top-level directory of this distribution. | ||
|
||
if(NOT COMP_API_VERSION) | ||
message(FATAL_ERROR "needs newer comp_base.cmake version") | ||
endif() | ||
comp_api_version(1) | ||
|
||
comp_feature(right_angle_brackets "#include <vector> | ||
typedef std::vector<std::vector<int> > Table; // OK | ||
typedef std::vector<std::vector<bool>> Flags; // OK (Error < CPP11) | ||
int main(){}" COMP_CPP11_FLAG) | ||
|