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
d5e918b6
Commit
d5e918b6
authored
Sep 28, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect C++14 compiler support
parent
be5b4552
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
36 deletions
+36
-36
CMakeLists.txt
CMakeLists.txt
+2
-2
fmt/CMakeLists.txt
fmt/CMakeLists.txt
+1
-1
support/cmake/cxx14.cmake
support/cmake/cxx14.cmake
+22
-22
test/CMakeLists.txt
test/CMakeLists.txt
+6
-6
test/add-subdirectory-test/CMakeLists.txt
test/add-subdirectory-test/CMakeLists.txt
+2
-2
test/compile-test/CMakeLists.txt
test/compile-test/CMakeLists.txt
+1
-1
test/find-package-test/CMakeLists.txt
test/find-package-test/CMakeLists.txt
+2
-2
No files found.
CMakeLists.txt
View file @
d5e918b6
...
...
@@ -23,7 +23,7 @@ option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF)
option
(
FMT_DOC
"Generate the doc target."
${
MASTER_PROJECT
}
)
option
(
FMT_INSTALL
"Generate the install target."
${
MASTER_PROJECT
}
)
option
(
FMT_TEST
"Generate the test target."
${
MASTER_PROJECT
}
)
option
(
FMT_USE_CPP1
1
"Enable the addition of C++11
compiler flags."
ON
)
option
(
FMT_USE_CPP1
4
"Enable the addition of C++14
compiler flags."
ON
)
project
(
FMT
)
...
...
@@ -43,7 +43,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/support/cmake"
)
include
(
cxx1
1
)
include
(
cxx1
4
)
if
(
CMAKE_COMPILER_IS_GNUCXX
OR
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
))
set
(
PEDANTIC_COMPILE_FLAGS -Wall -Wextra -Wshadow -pedantic
)
...
...
fmt/CMakeLists.txt
View file @
d5e918b6
...
...
@@ -16,7 +16,7 @@ if (FMT_CPPFORMAT)
endif
()
# Starting with cmake 3.1 the CXX_STANDARD property can be used instead.
target_compile_options
(
fmt PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
fmt PUBLIC
${
CPP1
4
_FLAG
}
)
if
(
FMT_PEDANTIC
)
target_compile_options
(
fmt PRIVATE
${
PEDANTIC_COMPILE_FLAGS
}
)
endif
()
...
...
support/cmake/cxx1
1
.cmake
→
support/cmake/cxx1
4
.cmake
View file @
d5e918b6
# C++1
1
feature support detection
# C++1
4
feature support detection
if
(
NOT FMT_USE_CPP1
1
)
if
(
NOT FMT_USE_CPP1
4
)
return
()
endif
()
include
(
CheckCXXCompilerFlag
)
if
(
FMT_USE_CPP1
1
)
check_cxx_compiler_flag
(
-std=c++1
1 HAVE_STD_CPP11
_FLAG
)
if
(
HAVE_STD_CPP1
1
_FLAG
)
# Check if including cmath works with -std=c++1
1
and -O3.
if
(
FMT_USE_CPP1
4
)
check_cxx_compiler_flag
(
-std=c++1
4 HAVE_STD_CPP14
_FLAG
)
if
(
HAVE_STD_CPP1
4
_FLAG
)
# Check if including cmath works with -std=c++1
4
and -O3.
# It may not in MinGW due to bug http://ehc.ac/p/mingw/bugs/2250/.
set
(
CMAKE_REQUIRED_FLAGS
"-std=c++1
1
-O3"
)
set
(
CMAKE_REQUIRED_FLAGS
"-std=c++1
4
-O3"
)
check_cxx_source_compiles
(
"
#include <cmath>
int main() {}"
FMT_CPP1
1
_CMATH
)
# Check if including <unistd.h> works with -std=c++1
1
.
int main() {}"
FMT_CPP1
4
_CMATH
)
# Check if including <unistd.h> works with -std=c++1
4
.
# 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_CPP1
1
_UNISTD_H
)
# Check if snprintf works with -std=c++1
1
. It may not in MinGW.
int main() {}"
FMT_CPP1
4
_UNISTD_H
)
# Check if snprintf works with -std=c++1
4
. It may not in MinGW.
check_cxx_source_compiles
(
"
#include <stdio.h>
int main() {
char buffer[10];
snprintf(buffer, 10,
\"
foo
\"
);
}"
FMT_CPP1
1
_SNPRINTF
)
if
(
FMT_CPP1
1_CMATH AND FMT_CPP11_UNISTD_H AND FMT_CPP11
_SNPRINTF
)
set
(
CPP1
1_FLAG -std=c++11
)
}"
FMT_CPP1
4
_SNPRINTF
)
if
(
FMT_CPP1
4_CMATH AND FMT_CPP14_UNISTD_H AND FMT_CPP14
_SNPRINTF
)
set
(
CPP1
4_FLAG -std=c++14
)
else
()
check_cxx_compiler_flag
(
-std=gnu++1
1 HAVE_STD_GNUPP11
_FLAG
)
if
(
HAVE_STD_CPP1
1
_FLAG
)
set
(
CPP1
1_FLAG -std=gnu++11
)
check_cxx_compiler_flag
(
-std=gnu++1
4 HAVE_STD_GNUPP14
_FLAG
)
if
(
HAVE_STD_CPP1
4
_FLAG
)
set
(
CPP1
4_FLAG -std=gnu++14
)
endif
()
endif
()
set
(
CMAKE_REQUIRED_FLAGS
)
else
()
check_cxx_compiler_flag
(
-std=c++
0x HAVE_STD_CPP0X
_FLAG
)
if
(
HAVE_STD_CPP
0X
_FLAG
)
set
(
CPP1
1_FLAG -std=c++0x
)
check_cxx_compiler_flag
(
-std=c++
1y HAVE_STD_CPP1Y
_FLAG
)
if
(
HAVE_STD_CPP
1Y
_FLAG
)
set
(
CPP1
4_FLAG -std=c++1y
)
endif
()
endif
()
endif
()
if
(
CMAKE_CXX_STANDARD
)
# Don't use -std compiler flag if CMAKE_CXX_STANDARD is specified.
set
(
CPP1
1
_FLAG
)
set
(
CPP1
4
_FLAG
)
endif
()
set
(
CMAKE_REQUIRED_FLAGS
${
CPP1
1
_FLAG
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
CPP1
4
_FLAG
}
)
# Check if variadic templates are working and not affected by GCC bug 39653:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39653
...
...
test/CMakeLists.txt
View file @
d5e918b6
...
...
@@ -7,7 +7,7 @@
# at http://code.google.com/p/googletest/wiki/FAQ for more details.
add_library
(
gmock STATIC
gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h
)
target_compile_options
(
gmock PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
gmock PUBLIC
${
CPP1
4
_FLAG
}
)
target_compile_definitions
(
gmock PUBLIC GTEST_HAS_STD_WSTRING=1
)
target_include_directories
(
gmock PUBLIC .
)
...
...
@@ -120,7 +120,7 @@ endif ()
check_cxx_compiler_flag
(
-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG
)
if
(
HAVE_FNO_EXCEPTIONS_FLAG
)
add_library
(
noexception-test ../fmt/format.cc
)
target_compile_options
(
noexception-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
noexception-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_include_directories
(
noexception-test PRIVATE
${
PROJECT_SOURCE_DIR
}
)
target_compile_options
(
noexception-test PRIVATE -fno-exceptions
)
endif
()
...
...
@@ -129,7 +129,7 @@ if (FMT_PEDANTIC)
# Test that the library compiles without windows.h.
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Windows"
)
add_library
(
no-windows-h-test ../fmt/format.cc
)
target_compile_options
(
no-windows-h-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
no-windows-h-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_include_directories
(
no-windows-h-test PRIVATE
${
PROJECT_SOURCE_DIR
}
)
target_compile_definitions
(
no-windows-h-test PRIVATE FMT_USE_WINDOWS_H=0
)
endif
()
...
...
@@ -142,7 +142,7 @@ if (FMT_PEDANTIC)
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-options
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCPP1
1_FLAG=
${
CPP11
_FLAG
}
"
"-DCPP1
4_FLAG=
${
CPP14
_FLAG
}
"
"-DSUPPORTS_USER_DEFINED_LITERALS=
${
SUPPORTS_USER_DEFINED_LITERALS
}
"
)
# test if the targets are findable from the build directory
...
...
@@ -155,7 +155,7 @@ if (FMT_PEDANTIC)
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-options
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCPP1
1_FLAG=
${
CPP11
_FLAG
}
"
"-DCPP1
4_FLAG=
${
CPP14
_FLAG
}
"
"-DFMT_DIR=
${
PROJECT_BINARY_DIR
}
"
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
...
...
@@ -169,6 +169,6 @@ if (FMT_PEDANTIC)
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-options
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCPP1
1_FLAG=
${
CPP11
_FLAG
}
"
"-DCPP1
4_FLAG=
${
CPP14
_FLAG
}
"
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
endif
()
test/add-subdirectory-test/CMakeLists.txt
View file @
d5e918b6
...
...
@@ -5,11 +5,11 @@ project(fmt-test)
add_subdirectory
(
../.. fmt
)
add_executable
(
library-test
"main.cc"
)
target_compile_options
(
library-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
library-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_link_libraries
(
library-test fmt
)
if
(
TARGET fmt-header-only
)
add_executable
(
header-only-test
"main.cc"
)
target_compile_options
(
header-only-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
header-only-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_link_libraries
(
header-only-test fmt-header-only
)
endif
()
test/compile-test/CMakeLists.txt
View file @
d5e918b6
...
...
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.8)
include
(
CheckCXXSourceCompiles
)
set
(
CMAKE_REQUIRED_INCLUDES
${
CMAKE_CURRENT_SOURCE_DIR
}
/../..
)
set
(
CMAKE_REQUIRED_FLAGS
${
CPP1
1
_FLAG
}
)
set
(
CMAKE_REQUIRED_FLAGS
${
CPP1
4
_FLAG
}
)
function
(
generate_source result fragment
)
set
(
${
result
}
"
...
...
test/find-package-test/CMakeLists.txt
View file @
d5e918b6
...
...
@@ -5,11 +5,11 @@ project(fmt-test)
find_package
(
FMT REQUIRED
)
add_executable
(
library-test main.cc
)
target_compile_options
(
library-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
library-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_link_libraries
(
library-test fmt
)
if
(
TARGET fmt-header-only
)
add_executable
(
header-only-test main.cc
)
target_compile_options
(
header-only-test PUBLIC
${
CPP1
1
_FLAG
}
)
target_compile_options
(
header-only-test PUBLIC
${
CPP1
4
_FLAG
}
)
target_link_libraries
(
header-only-test fmt-header-only
)
endif
()
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