Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
617ee7c5
Commit
617ee7c5
authored
Sep 18, 2013
by
Stephen Kelly
Browse files
Add a test for SYSTEM headers in INTERFACE libraries.
parent
7e4910fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
View file @
617ee7c5
...
...
@@ -17,3 +17,31 @@ target_include_directories(upstream SYSTEM PUBLIC
add_library
(
consumer consumer.cpp
)
target_link_libraries
(
consumer upstream
)
target_compile_options
(
consumer PRIVATE -Werror=unused-variable
)
add_library
(
iface IMPORTED INTERFACE
)
set_property
(
TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/systemlib_header_only"
)
add_library
(
imported_consumer imported_consumer.cpp
)
target_link_libraries
(
imported_consumer iface
)
target_compile_options
(
imported_consumer PRIVATE -Werror=unused-variable
)
macro
(
do_try_compile error_option
)
set
(
TC_ARGS
IFACE_TRY_COMPILE_
${
error_option
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/try_compile_iface"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/imported_consumer.cpp"
LINK_LIBRARIES iface
)
if
(
${
error_option
}
STREQUAL WITH_ERROR
)
list
(
APPEND TC_ARGS COMPILE_DEFINITIONS -Werror=unused-variable
)
endif
()
try_compile
(
${
TC_ARGS
}
)
endmacro
()
do_try_compile
(
NO_ERROR
)
if
(
NOT IFACE_TRY_COMPILE_NO_ERROR
)
message
(
SEND_ERROR
"try_compile failed with imported target."
)
endif
()
do_try_compile
(
WITH_ERROR
)
if
(
NOT IFACE_TRY_COMPILE_WITH_ERROR
)
message
(
SEND_ERROR
"try_compile failed with imported target with error option."
)
endif
()
Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp
0 → 100644
View file @
617ee7c5
#include
"systemlib.h"
int
main
()
{
return
systemlib
();
}
Tests/IncludeDirectories/SystemIncludeDirectories/systemlib_header_only/systemlib.h
0 → 100644
View file @
617ee7c5
#ifndef SYSTEMLIB_H
#define SYSTEMLIB_H
int
systemlib
()
{
return
0
;
}
int
unusedFunc
()
{
int
unused
;
return
systemlib
();
}
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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