| 59 | # Handle configure.cppflags, configure.optflags, configure.cflags, |
| 60 | # configure.cxxflags, configure.ldflags by setting the equivalent CMAKE_*_FLAGS. |
| 61 | # |
| 62 | # Be aware that a CMake script can always override these flags when it runs, as |
| 63 | # they are frequently set internally in function of other CMake build variables! |
| 64 | # |
| 65 | # Attention: If you want to be sure that no compiler flags are passed via |
| 66 | # configure.args, you have to set manually configure.optflags to "", as it is by |
| 67 | # default "-O2" and added to all language-specific flags. If you want to turn off |
| 68 | # optimization, explicitly set configue.optflags to "-O0". |
| 69 | if (${configure.cppflags} != "") { |
| 70 | # Add the preprocessor flags to the C/C++ compiler flags as CMake does not |
| 71 | # honor separately CPPFLAGS (it uses usually add_definitions() for that). |
| 72 | # We use the compiler flags for all build types, as they are usually empty. |
| 73 | # Cf. also to CMake upstream ticket #12928 "CMake silently ignores CPPFLAGS" |
| 74 | # <http://www.cmake.org/Bug/view.php?id=12928>. |
| 75 | configure.args-append -DCMAKE_C_FLAGS="${configure.cppflags}" |
| 76 | configure.args-append -DCMAKE_CXX_FLAGS="${configure.cppflags}" |
| 77 | } |
| 78 | if {${configure.cflags} != ""} { |
| 79 | # The configure.cflags contain configure.optflags by default. Therefore, we |
| 80 | # set the Release flags, which would otherwise overrule the optimization |
| 81 | # flags, as they are set by default to "-O3 -NDEBUG". Therefore, be sure |
| 82 | # to add "-NDEBUG" to the configure.cflags if you want to turn off |
| 83 | # assertions in release builds! |
| 84 | configure.args-append -DCMAKE_C_FLAGS_RELEASE="${configure.cflags}" |
| 85 | } |
| 86 | if {${configure.cxxflags} != ""} { |
| 87 | # The configure.cxxflags contain configure.optflags by default. Therefore, |
| 88 | # we set the Release flags, which would otherwise overrule the optimization |
| 89 | # flags, as they are set by default to "-O3 -NDEBUG". Therefore, be sure |
| 90 | # to add "-NDEBUG" to the configure.cflags if you want to turn off |
| 91 | # assertions in release builds! |
| 92 | configure.args-append -DCMAKE_CXX_FLAGS_RELEASE="${configure.cxxflags}" |
| 93 | } |
| 94 | if {${configure.ldflags} != ""} { |
| 95 | # CMake supports individual linker flags for executables, modules, and dlls. |
| 96 | # By default, they are empty. |
| 97 | configure.args-append -DCMAKE_EXE_LINKER_FLAGS="${configure.ldflags}" |
| 98 | configure.args-append -DCMAKE_SHARED_LINKER_FLAGS="${configure.ldflags}" |
| 99 | configure.args-append -DCMAKE_MODULE_LINKER_FLAGS="${configure.ldflags}" |
| 100 | } |
| 101 | |
| 102 | # TODO: Handle configure.objcflags (cf. to CMake upstream ticket #4756 |
| 103 | # "CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS" |
| 104 | # <http://public.kitware.com/Bug/view.php?id=4756>) |
| 105 | |
| 106 | # TODO: Handle the Fortran-specific configure.* variables: |
| 107 | # configure.fflags, configure.fcflags, configure.f90flags |
| 108 | |
| 109 | # TODO: Handle the Java-specific configure.classpath variable. |
| 110 | |