Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
0fb474be
Commit
0fb474be
authored
Jan 29, 2016
by
Mario Werner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
outlined the compiler feature tests to improve script readability
parent
3019a8c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
52 deletions
+64
-52
CMakeLists.txt
CMakeLists.txt
+2
-29
support/cmake/testCxx11.cmake
support/cmake/testCxx11.cmake
+58
-0
test/CMakeLists.txt
test/CMakeLists.txt
+4
-23
No files found.
CMakeLists.txt
View file @
0fb474be
...
...
@@ -23,39 +23,12 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
CMAKE_BINARY_DIR
}
/bin
)
include
(
CheckCXXCompilerFlag
)
check_cxx_compiler_flag
(
-std=c++11 HAVE_STD_CPP11_FLAG
)
if
(
HAVE_STD_CPP11_FLAG
)
# Check if including cmath works with -std=c++11 and -O3.
# It may not in MinGW due to bug http://ehc.ac/p/mingw/bugs/2250/.
set
(
CMAKE_REQUIRED_FLAGS
"-std=c++11 -O3"
)
check_cxx_source_compiles
(
"
#include <cmath>
int main() {}"
FMT_CPP11_CMATH
)
# Check if including <unistd.h> works with -std=c++11.
# It may not in MinGW due to bug http://sourceforge.net/p/mingw/bugs/2024/.
check_cxx_source_compiles
(
"
#include <unistd.h>
int main() {}"
FMT_CPP11_UNISTD_H
)
if
(
FMT_CPP11_CMATH AND FMT_CPP11_UNISTD_H
)
set
(
CPP11_FLAG -std=c++11
)
else
()
check_cxx_compiler_flag
(
-std=gnu++11 HAVE_STD_GNUPP11_FLAG
)
if
(
HAVE_STD_CPP11_FLAG
)
set
(
CPP11_FLAG -std=gnu++11
)
endif
()
endif
()
set
(
CMAKE_REQUIRED_FLAGS
)
else
()
check_cxx_compiler_flag
(
-std=c++0x HAVE_STD_CPP0X_FLAG
)
if
(
HAVE_STD_CPP0X_FLAG
)
set
(
CPP11_FLAG -std=c++0x
)
endif
()
endif
()
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/support/cmake"
)
include
(
testCxx11
)
if
(
CMAKE_GENERATOR MATCHES
"Visual Studio"
)
# If Microsoft SDK is installed create script run-msbuild.bat that
# calls SetEnv.cmd to to set up build environment and runs msbuild.
...
...
support/cmake/testCxx11.cmake
0 → 100644
View file @
0fb474be
include
(
CheckCXXCompilerFlag
)
check_cxx_compiler_flag
(
-std=c++11 HAVE_STD_CPP11_FLAG
)
if
(
HAVE_STD_CPP11_FLAG
)
# Check if including cmath works with -std=c++11 and -O3.
# It may not in MinGW due to bug http://ehc.ac/p/mingw/bugs/2250/.
set
(
CMAKE_REQUIRED_FLAGS
"-std=c++11 -O3"
)
check_cxx_source_compiles
(
"
#include <cmath>
int main() {}"
FMT_CPP11_CMATH
)
# Check if including <unistd.h> works with -std=c++11.
# It may not in MinGW due to bug http://sourceforge.net/p/mingw/bugs/2024/.
check_cxx_source_compiles
(
"
#include <unistd.h>
int main() {}"
FMT_CPP11_UNISTD_H
)
if
(
FMT_CPP11_CMATH AND FMT_CPP11_UNISTD_H
)
set
(
CPP11_FLAG -std=c++11
)
else
()
check_cxx_compiler_flag
(
-std=gnu++11 HAVE_STD_GNUPP11_FLAG
)
if
(
HAVE_STD_CPP11_FLAG
)
set
(
CPP11_FLAG -std=gnu++11
)
endif
()
endif
()
set
(
CMAKE_REQUIRED_FLAGS
)
else
()
check_cxx_compiler_flag
(
-std=c++0x HAVE_STD_CPP0X_FLAG
)
if
(
HAVE_STD_CPP0X_FLAG
)
set
(
CPP11_FLAG -std=c++0x
)
endif
()
endif
()
set
(
CMAKE_REQUIRED_FLAGS
${
CPP11_FLAG
}
)
# Check if variadic templates are working and not affected by GCC bug 39653:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653
check_cxx_source_compiles
(
"
template <class T, class ...Types>
struct S { typedef typename S<Types...>::type type; };
int main() {}"
SUPPORTS_VARIADIC_TEMPLATES
)
# Check if initializer lists are supported.
check_cxx_source_compiles
(
"
#include <initializer_list>
int main() {}"
SUPPORTS_INITIALIZER_LIST
)
# Check if enum bases are available
check_cxx_source_compiles
(
"
enum C : char {A};
int main() {}"
SUPPORTS_ENUM_BASE
)
# Check if type traits are available
check_cxx_source_compiles
(
"
#include <type_traits>
class C { void operator=(const C&); };
int main() { static_assert(!std::is_copy_assignable<C>::value,
\"\"
); }"
SUPPORTS_TYPE_TRAITS
)
set
(
CMAKE_REQUIRED_FLAGS
)
test/CMakeLists.txt
View file @
0fb474be
...
...
@@ -28,18 +28,8 @@ endif ()
# Check if variadic templates are working and not affected by GCC bug 39653:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653
check_cxx_source_compiles
(
"
template <class T, class ...Types>
struct S { typedef typename S<Types...>::type type; };
int main() {}"
FMT_VARIADIC_TEMPLATES
)
# Check if initializer lists are supported.
check_cxx_source_compiles
(
"
#include <initializer_list>
int main() {}"
FMT_INITIALIZER_LIST
)
if
(
NOT FMT_VARIADIC_TEMPLATES OR NOT FMT_INITIALIZER_LIST
)
add_definitions
(
-DGTEST_LANG_CXX11=0
)
if
(
NOT SUPPORTS_VARIADIC_TEMPLATES OR NOT SUPPORTS_INITIALIZER_LIST
)
target_compile_definitions
(
gmock PUBLIC GTEST_LANG_CXX11=0
)
endif
()
# Workaround a bug in implementation of variadic templates in MSVC11.
...
...
@@ -91,11 +81,7 @@ if (CPP11_FLAG)
set_target_properties
(
util-test PROPERTIES COMPILE_FLAGS
${
CPP11_FLAG
}
)
endif
()
check_cxx_source_compiles
(
"
enum C : char {A};
int main() {}"
HAVE_ENUM_BASE
)
if
(
HAVE_ENUM_BASE
)
if
(
SUPPORTS_ENUM_BASE
)
set_target_properties
(
util-test
PROPERTIES COMPILE_DEFINITIONS
"FMT_USE_ENUM_BASE=1"
)
endif
()
...
...
@@ -104,12 +90,7 @@ foreach (src ${FMT_SOURCES})
set
(
FMT_TEST_SOURCES
${
FMT_TEST_SOURCES
}
../
${
src
}
)
endforeach
()
check_cxx_source_compiles
(
"
#include <type_traits>
class C { void operator=(const C&); };
int main() { static_assert(!std::is_copy_assignable<C>::value,
\"\"
); }"
HAVE_TYPE_TRAITS
)
if
(
HAVE_TYPE_TRAITS
)
if
(
SUPPORTS_TYPE_TRAITS
)
foreach
(
target format-test util-test
)
set_target_properties
(
${
target
}
PROPERTIES COMPILE_DEFINITIONS
"FMT_USE_TYPE_TRAITS=1"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment