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
6825ac9c
Commit
6825ac9c
authored
May 04, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #313 from dean0x7d/test-fixes
Fix a few bugs related to compile tests
parents
40421982
f3d6d3a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
test/CMakeLists.txt
test/CMakeLists.txt
+7
-3
test/compile-test/CMakeLists.txt
test/compile-test/CMakeLists.txt
+10
-3
No files found.
test/CMakeLists.txt
View file @
6825ac9c
...
@@ -137,8 +137,10 @@ if (FMT_PEDANTIC)
...
@@ -137,8 +137,10 @@ if (FMT_PEDANTIC)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/find-package-test"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/find-package-test"
--build-generator
${
CMAKE_GENERATOR
}
--build-generator
${
CMAKE_GENERATOR
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-options
"-DFMT_DIR=
${
PROJECT_BINARY_DIR
}
"
--build-options
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DFMT_DIR=
${
PROJECT_BINARY_DIR
}
"
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
# test if the targets are findable when add_subdirectory is used
# test if the targets are findable when add_subdirectory is used
add_test
(
add-subdirectory-test
${
CMAKE_CTEST_COMMAND
}
add_test
(
add-subdirectory-test
${
CMAKE_CTEST_COMMAND
}
...
@@ -148,5 +150,7 @@ if (FMT_PEDANTIC)
...
@@ -148,5 +150,7 @@ if (FMT_PEDANTIC)
"
${
CMAKE_CURRENT_BINARY_DIR
}
/add-subdirectory-test"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/add-subdirectory-test"
--build-generator
${
CMAKE_GENERATOR
}
--build-generator
${
CMAKE_GENERATOR
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-options
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
--build-options
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
"
)
endif
()
endif
()
test/compile-test/CMakeLists.txt
View file @
6825ac9c
...
@@ -9,7 +9,7 @@ set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG})
...
@@ -9,7 +9,7 @@ set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG})
function
(
generate_source result fragment
)
function
(
generate_source result fragment
)
set
(
${
result
}
"
set
(
${
result
}
"
#define FMT_HEADER_ONLY 1
#define FMT_HEADER_ONLY 1
#include
\"
fmt/
format
.h
\"
#include
\"
fmt/
posix
.h
\"
int main() {
int main() {
${
fragment
}
${
fragment
}
}
}
...
@@ -20,22 +20,28 @@ function (expect_compile code)
...
@@ -20,22 +20,28 @@ function (expect_compile code)
generate_source
(
source
"
${
code
}
"
)
generate_source
(
source
"
${
code
}
"
)
check_cxx_source_compiles
(
"
${
source
}
"
compiles
)
check_cxx_source_compiles
(
"
${
source
}
"
compiles
)
if
(
NOT compiles
)
if
(
NOT compiles
)
message
(
FATAL_ERROR
"Compile error for:
${
code
}
"
)
set
(
error_msg
"Compile error for:
${
code
}
"
)
endif
()
endif
()
# Unset the CMake cache variable compiles. Otherwise the compile test will
# Unset the CMake cache variable compiles. Otherwise the compile test will
# just use cached information next time it runs.
# just use cached information next time it runs.
unset
(
compiles CACHE
)
unset
(
compiles CACHE
)
if
(
error_msg
)
message
(
FATAL_ERROR
${
error_msg
}
)
endif
()
endfunction
()
endfunction
()
function
(
expect_compile_error code
)
function
(
expect_compile_error code
)
generate_source
(
source
"
${
code
}
"
)
generate_source
(
source
"
${
code
}
"
)
check_cxx_source_compiles
(
"
${
source
}
"
compiles
)
check_cxx_source_compiles
(
"
${
source
}
"
compiles
)
if
(
compiles
)
if
(
compiles
)
message
(
FATAL_ERROR
"No compile error for:
${
code
}
"
)
set
(
error_msg
"No compile error for:
${
code
}
"
)
endif
()
endif
()
# Unset the CMake cache variable compiles. Otherwise the compile test will
# Unset the CMake cache variable compiles. Otherwise the compile test will
# just use cached information next time it runs.
# just use cached information next time it runs.
unset
(
compiles CACHE
)
unset
(
compiles CACHE
)
if
(
error_msg
)
message
(
FATAL_ERROR
${
error_msg
}
)
endif
()
endfunction
()
endfunction
()
# check if the source file skeleton compiles
# check if the source file skeleton compiles
...
@@ -57,6 +63,7 @@ expect_compile_error("fmt::MemoryWriter() << fmt::pad(42, 5, L' ');")
...
@@ -57,6 +63,7 @@ expect_compile_error("fmt::MemoryWriter() << fmt::pad(42, 5, L' ');")
# Formatting a wide character with a narrow format string is forbidden.
# Formatting a wide character with a narrow format string is forbidden.
expect_compile_error
(
"fmt::format(
\"
{}
\"
, L'a';"
)
expect_compile_error
(
"fmt::format(
\"
{}
\"
, L'a';"
)
expect_compile
(
"FMT_STATIC_ASSERT(true,
\"
this should never happen
\"
);"
)
expect_compile_error
(
"FMT_STATIC_ASSERT(0 > 1,
\"
oops
\"
);"
)
expect_compile_error
(
"FMT_STATIC_ASSERT(0 > 1,
\"
oops
\"
);"
)
# Make sure that compiler features detected in the header
# Make sure that compiler features detected in the header
...
...
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