-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp blt_convert_to_system_includes #671
Changes from all commits
da2a7c9
8071668
5f50f73
6c1e1e2
deff1b5
cd7afa8
4214e3b
e94a368
5586190
7c3a897
ff41fba
4e85473
483ccbf
6c8c13e
b944ad2
f6e95ee
2e34ac2
2944bbb
39f17c5
4f374c7
2923a40
cf9628b
b647cd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.code-workspace | ||
*.swp |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,37 +428,166 @@ endmacro(blt_add_target_compile_flags) | |
|
||
|
||
##------------------------------------------------------------------------------ | ||
## blt_convert_to_system_includes(TARGET <target>) | ||
## blt_find_target_dependencies(TARGET <target> TLIST <list name>) | ||
## | ||
## Converts existing interface includes to system interface includes. | ||
## Store all target's dependencies (link libraries and interface link libraries) | ||
## recursively in the variable name TLIST holds. | ||
##------------------------------------------------------------------------------ | ||
macro(blt_convert_to_system_includes) | ||
macro(blt_find_target_dependencies) | ||
set(options) | ||
set(singleValuedArgs TARGET) | ||
set(singleValuedArgs TARGET TLIST) | ||
set(multiValuedArgs) | ||
|
||
## parse the arguments to the macro | ||
# parse the arguments to the macro | ||
cmake_parse_arguments(arg | ||
"${options}" "${singleValuedArgs}" "${multiValuedArgs}" ${ARGN}) | ||
|
||
# check for required arguments | ||
if(NOT DEFINED arg_TARGET) | ||
message(FATAL_ERROR "TARGET is a required parameter for the blt_convert_to_system_includes macro.") | ||
message(FATAL_ERROR "TARGET is a required parameter for the blt_find_target_dependencies macro") | ||
endif() | ||
|
||
# PGI does not support -isystem | ||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI") | ||
get_target_property(_include_dirs ${arg_TARGET} INTERFACE_INCLUDE_DIRECTORIES) | ||
# Don't copy if the target had no include directories | ||
if(_include_dirs) | ||
# Clear previous value in INTERFACE_INCLUDE_DIRECTORIES so it is not doubled | ||
# by target_include_directories | ||
set_property(TARGET ${arg_TARGET} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) | ||
target_include_directories(${arg_TARGET} SYSTEM INTERFACE ${_include_dirs}) | ||
if(NOT DEFINED arg_TLIST OR NOT DEFINED ${arg_TLIST}) | ||
message(FATAL_ERROR "TLIST is a required parameter for the blt_find_target_dependencies macro") | ||
endif() | ||
|
||
set(_depends_on "") | ||
|
||
# Get dependencies if BLT registered library | ||
string(TOUPPER ${arg_TARGET} _target_upper) | ||
if(_BLT_${_target_upper}_IS_REGISTERED_LIBRARY) | ||
list(APPEND _depends_on "${_BLT_${_target_upper}_DEPENDS_ON}") | ||
endif() | ||
unset(_target_upper) | ||
|
||
# Get dependencies if CMake target | ||
if(TARGET ${arg_TARGET}) | ||
get_property(_target_type TARGET ${arg_TARGET} PROPERTY TYPE) | ||
if(NOT "${_target_type}" STREQUAL "INTERFACE_LIBRARY") | ||
get_target_property(_propval ${arg_TARGET} LINK_LIBRARIES) | ||
if(_propval) | ||
list(APPEND _depends_on ${_propval}) | ||
endif() | ||
endif() | ||
|
||
# get interface link libraries | ||
get_target_property(_propval ${arg_TARGET} INTERFACE_LINK_LIBRARIES) | ||
if (_propval) | ||
list(APPEND _depends_on ${_propval}) | ||
endif() | ||
endif() | ||
|
||
blt_list_remove_duplicates(TO _depends_on) | ||
foreach(t ${_depends_on}) | ||
if (NOT "${t}" IN_LIST ${arg_TLIST}) | ||
list(APPEND ${arg_TLIST} ${t}) | ||
blt_find_target_dependencies(TARGET ${t} TLIST ${arg_TLIST}) | ||
endif() | ||
endforeach() | ||
|
||
unset(_depends_on) | ||
endmacro(blt_find_target_dependencies) | ||
|
||
|
||
##------------------------------------------------------------------------------ | ||
## blt_convert_to_system_includes(TARGET <target> | ||
## TARGETS [<target>...] | ||
## CHILDREN [TRUE|FALSE] | ||
## [QUIET]) | ||
## | ||
## Converts existing interface includes to system interface includes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that there was a discussion about not marking Can we still include a comment that |
||
## | ||
## Note: The argument ``TARGET`` will be deprecated in the near future. Until then, | ||
## if both ``TARGET`` and ``TARGETS`` is given, all given target include | ||
## directories will be converted. | ||
## | ||
##------------------------------------------------------------------------------ | ||
function(blt_convert_to_system_includes) | ||
set(options QUIET) | ||
set(singleValuedArgs CHILDREN TARGET) | ||
set(multiValuedArgs TARGETS) | ||
|
||
## parse the arguments to the macro | ||
cmake_parse_arguments(arg | ||
"${options}" "${singleValuedArgs}" "${multiValuedArgs}" ${ARGN}) | ||
|
||
if(NOT DEFINED arg_TARGET AND NOT DEFINED arg_TARGETS) | ||
message(FATAL_ERROR "Neither required TARGET or TARGETS parameters for the blt_convert_to_system_includes macro were provided.") | ||
endif() | ||
|
||
if(DEFINED arg_TARGET) | ||
list(APPEND arg_TARGETS ${arg_TARGET}) | ||
endif() | ||
|
||
if(NOT DEFINED arg_TARGETS) | ||
message(FATAL_ERROR "TARGETS is a required parameter for the blt_convert_to_system_includes macro.") | ||
endif() | ||
|
||
if(NOT DEFINED arg_CHILDREN) | ||
set(arg_CHILDREN FALSE) | ||
endif() | ||
|
||
unset(_include_dirs) | ||
endmacro() | ||
# PGI does not support -isystem | ||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI") | ||
set(_target_list "") | ||
|
||
foreach(_target ${arg_TARGETS}) | ||
adayton1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
string(TOUPPER ${_target} _target_upper) | ||
|
||
if(TARGET ${_target} OR _BLT_${_target_upper}_IS_REGISTERED_LIBRARY) | ||
if(${arg_CHILDREN}) | ||
blt_find_target_dependencies(TARGET ${_target} TLIST _target_list) | ||
adayton1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endif() | ||
|
||
list(APPEND _target_list ${_target}) | ||
elseif(NOT ${arg_QUIET) | ||
message(WARNING "${_target} does not exist!") | ||
endif() | ||
|
||
unset(_target_upper) | ||
endforeach() | ||
|
||
blt_list_remove_duplicates(TO _target_list) | ||
|
||
foreach(_target ${_target_list}) | ||
if(TARGET ${_target}) | ||
adayton1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Handle CMake target | ||
get_target_property(_interface_include_dirs | ||
${_target} | ||
INTERFACE_INCLUDE_DIRECTORIES) | ||
|
||
# Don't update properties if the target had no interface include directories | ||
if(_interface_include_dirs) | ||
# Clear previous value in INTERFACE_INCLUDE_DIRECTORIES | ||
# so it is not doubled by target_include_directories | ||
set_target_properties(${_target} | ||
PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "") | ||
|
||
target_include_directories(${_target} | ||
SYSTEM | ||
INTERFACE | ||
${_interface_include_dirs}) | ||
endif() | ||
|
||
unset(_interface_include_dirs) | ||
else() | ||
string(TOUPPER ${_target} _target_upper) | ||
|
||
if(_BLT_${_target_upper}_IS_REGISTERED_LIBRARY) | ||
# Handle BLT registered target | ||
set(_BLT_${_target_upper}_TREAT_INCLUDES_AS_SYSTEM TRUE) | ||
endif() | ||
|
||
unset(_target_upper) | ||
endif() | ||
endforeach() | ||
|
||
unset(_target_list) | ||
elseif(NOT ${arg_QUIET}) | ||
message(WARNING "PGI compiler does not support system includes") | ||
endif() | ||
endfunction(blt_convert_to_system_includes) | ||
|
||
|
||
##------------------------------------------------------------------------------ | ||
|
@@ -541,7 +670,7 @@ macro(blt_patch_target) | |
endif() | ||
|
||
if(${arg_TREAT_INCLUDES_AS_SYSTEM}) | ||
blt_convert_to_system_includes(TARGET ${arg_NAME}) | ||
blt_convert_to_system_includes(TARGETS ${arg_NAME}) | ||
endif() | ||
|
||
# FIXME: Is this all that's needed? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,21 +215,44 @@ command but doesn't throw an error if the list is empty or not defined. | |
set(mylist A B A) | ||
blt_list_remove_duplicates( TO mylist ) | ||
|
||
.. _blt_find_target_dependencies: | ||
|
||
blt_find_target_dependencies | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: cmake | ||
|
||
set(_target_list "") | ||
blt_find_target_dependencies(TARGET <target> TLIST _target_list) | ||
|
||
Recursively adds all link libraries and interface link libraries of the given | ||
target to the given list. Handles CMake targets and BLT registered libraries. | ||
|
||
.. _blt_convert_to_system_includes: | ||
|
||
blt_convert_to_system_includes | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: cmake | ||
|
||
blt_convert_to_system_includes(TARGET <target>) | ||
blt_convert_to_system_includes(TARGET <target> | ||
TARGETS [<target>...] | ||
CHILDREN [TRUE | FALSE (default)] | ||
[QUIET]) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs should also have a comment/note that |
||
Converts existing interface includes to system interface includes. | ||
Warns if a target does not exist unless ``QUIET`` is specified. | ||
Recurses through link libraries and interface link libraries if | ||
``CHILDREN TRUE`` is specified. | ||
|
||
.. note:: | ||
The argument ``TARGET`` will be deprecated in the near future. Until then, | ||
if both ``TARGET`` and ``TARGETS`` is given, all given target include | ||
directories will be converted. | ||
|
||
.. code-block:: cmake | ||
:caption: **Example** | ||
:linenos: | ||
|
||
## convert to system includes for the foo target | ||
blt_convert_to_system_includes(TARGET foo) | ||
blt_convert_to_system_includes(TARGETS foo) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did anything in
blt_find_target_dependencies
change? Or was it just moved to a new file?