diff options
Diffstat (limited to 'project/cmake/scripts/common/addoptions.cmake')
| -rw-r--r-- | project/cmake/scripts/common/addoptions.cmake | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/project/cmake/scripts/common/addoptions.cmake b/project/cmake/scripts/common/addoptions.cmake deleted file mode 100644 index 0ebb823..0000000 --- a/project/cmake/scripts/common/addoptions.cmake +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | # - Add options without repeating them on the command line | ||
| 2 | # | ||
| 3 | # Synopsis: | ||
| 4 | # | ||
| 5 | # add_options (lang build opts) | ||
| 6 | # | ||
| 7 | # where: | ||
| 8 | # | ||
| 9 | # lang Name of the language whose compiler should receive the | ||
| 10 | # options, e.g. CXX. If a comma-separated list is received | ||
| 11 | # then the option is added for all those languages. Use the | ||
| 12 | # special value ALL_LANGUAGES for these languages: CXX, C | ||
| 13 | # and Fortran | ||
| 14 | # | ||
| 15 | # build Kind of build to which this options should apply, | ||
| 16 | # such as DEBUG and RELEASE. This can also be a comma- | ||
| 17 | # separated list. Use the special value ALL_BUILDS to apply | ||
| 18 | # to all builds. | ||
| 19 | # | ||
| 20 | # opts List of options to add. Each should be quoted. | ||
| 21 | # | ||
| 22 | # Example: | ||
| 23 | # | ||
| 24 | # add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall") | ||
| 25 | |||
| 26 | function (add_options langs builds) | ||
| 27 | # special handling of empty language specification | ||
| 28 | if ("${langs}" STREQUAL "ALL_LANGUAGES") | ||
| 29 | set (langs CXX C Fortran) | ||
| 30 | endif ("${langs}" STREQUAL "ALL_LANGUAGES") | ||
| 31 | foreach (lang IN LISTS langs) | ||
| 32 | # prepend underscore if necessary | ||
| 33 | foreach (build IN LISTS builds) | ||
| 34 | if (NOT ("${build}" STREQUAL "ALL_BUILDS")) | ||
| 35 | set (_bld "_${build}") | ||
| 36 | string (TOUPPER "${_bld}" _bld) | ||
| 37 | else (NOT ("${build}" STREQUAL "ALL_BUILDS")) | ||
| 38 | set (_bld "") | ||
| 39 | endif (NOT ("${build}" STREQUAL "ALL_BUILDS")) | ||
| 40 | foreach (_opt IN LISTS ARGN) | ||
| 41 | set (_var "CMAKE_${lang}_FLAGS${_bld}") | ||
| 42 | #message (STATUS "Adding \"${_opt}\" to \${${_var}}") | ||
| 43 | # remove it first | ||
| 44 | string (REPLACE "${_opt}" "" _without "${${_var}}") | ||
| 45 | string (STRIP "${_without}" _without) | ||
| 46 | # we need to strip this one as well, so they are comparable | ||
| 47 | string (STRIP "${${_var}}" _stripped) | ||
| 48 | # if it wasn't there, then add it at the end | ||
| 49 | if ("${_without}" STREQUAL "${_stripped}") | ||
| 50 | # don't add any extra spaces if no options yet are set | ||
| 51 | if (NOT ${_stripped} STREQUAL "") | ||
| 52 | set (${_var} "${_stripped} ${_opt}") | ||
| 53 | else (NOT ${_stripped} STREQUAL "") | ||
| 54 | set (${_var} "${_opt}") | ||
| 55 | endif (NOT ${_stripped} STREQUAL "") | ||
| 56 | set (${_var} "${${_var}}" PARENT_SCOPE) | ||
| 57 | endif ("${_without}" STREQUAL "${_stripped}") | ||
| 58 | endforeach (_opt) | ||
| 59 | endforeach (build) | ||
| 60 | endforeach (lang) | ||
| 61 | endfunction (add_options lang build) | ||
| 62 | |||
| 63 | # set varname to flag unless user has specified something that matches regex | ||
| 64 | function (set_default_option varname flag regex) | ||
| 65 | if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" | ||
| 66 | AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" | ||
| 67 | AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") | ||
| 68 | set (${varname} ${flag} PARENT_SCOPE) | ||
| 69 | else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" | ||
| 70 | AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" | ||
| 71 | AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") | ||
| 72 | set (${varname} PARENT_SCOPE) | ||
| 73 | endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" | ||
| 74 | AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" | ||
| 75 | AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") | ||
| 76 | endfunction (set_default_option) | ||
| 77 | |||
| 78 | # note: this must be called before project() | ||
| 79 | macro (no_default_options) | ||
| 80 | # prevent the platform probe to set options | ||
| 81 | set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE) | ||
| 82 | endmacro (no_default_options) | ||
