Created
August 4, 2015 12:25
-
-
Save autosquid/e6078a7964d31d0f52a7 to your computer and use it in GitHub Desktop.
cmake get compiler options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro(get_gcc_compile_flags target flags) | |
| string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" name) | |
| set(flags "${${name}} ${CMAKE_CXX_COMPILER_ARG1}") | |
| get_target_property(value ${target} COMPILE_FLAGS) | |
| if (value) | |
| list(APPEND flags ${value}) | |
| endif() | |
| get_target_property(value ${target} TYPE) | |
| get_target_property(value ${target} COMPILE_DEFINITIONS) | |
| if (value) | |
| foreach(item ${value}) | |
| list(APPEND flags "-D${item}") | |
| endforeach() | |
| endif() | |
| STRING(TOUPPER "COMPILE_DEFINITIONS_${CMAKE_BUILD_TYPE}" name) | |
| get_target_property(value ${target} ${name}) | |
| if (value) | |
| foreach(item ${value}) | |
| list(APPEND flags "-D${item}") | |
| endforeach() | |
| endif() | |
| get_directory_property(value DEFINITIONS) | |
| if (value) | |
| set( value_list ${value} ) | |
| separate_arguments(value_list) | |
| foreach (item ${value_list}) | |
| list(APPEND flags ${item}) | |
| endforeach() | |
| endif() | |
| get_directory_property(value INCLUDE_DIRECTORIES) | |
| if (value) | |
| foreach(item ${value}) | |
| list(APPEND flags "-I${item}") | |
| endforeach() | |
| endif() | |
| #separate_arguments(flags) | |
| endmacro() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment