| | 126 | |
|---|
| | 127 | |
|---|
| | 128 | |
|---|
| | 129 | |
|---|
| | 130 | ############################################################################### |
|---|
| | 131 | # This is for an advanced option to give aggressive warnings |
|---|
| | 132 | # under different compilers. If yours is not implemented, this option |
|---|
| | 133 | # will not be made available. |
|---|
| | 134 | IF(CMAKE_COMPILER_IS_GNUCXX) |
|---|
| | 135 | # To be complete, we might also do GNUCC flags, |
|---|
| | 136 | # but everything here is C++ code. |
|---|
| | 137 | # # FYI, if we do implement GNUCC, then -Wmissing-prototypes in another |
|---|
| | 138 | # interesting C-specific flag. |
|---|
| | 139 | SET(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wnewline-eof -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -Wshadow -Woverloaded-virtual") |
|---|
| | 140 | ELSE(CMAKE_COMPILER_IS_GNUCXX) |
|---|
| | 141 | IF(MSVC) |
|---|
| | 142 | # FIXME: What are good aggressive warning flags for Visual Studio? |
|---|
| | 143 | # And do we need to further subcase this for different versions of VS? |
|---|
| | 144 | # CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005 |
|---|
| | 145 | SET(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS "/Wall /W4") |
|---|
| | 146 | ELSE(MSVC) |
|---|
| | 147 | # CMake lacks an elseif, so other non-gcc, non-VS compilers need |
|---|
| | 148 | # to be listed below. If unhandled, OPENTHREADS_AGGRESSIVE_WARNING_FLAGS should |
|---|
| | 149 | # remain unset. |
|---|
| | 150 | ENDIF(MSVC) |
|---|
| | 151 | ENDIF(CMAKE_COMPILER_IS_GNUCXX) |
|---|
| | 152 | |
|---|
| | 153 | # This part is for the CMake menu option to toggle the warnings on/off. |
|---|
| | 154 | # This will only be made available if we set values for OPENTHREADS_AGGRESSIVE_WARNING_FLAGS. |
|---|
| | 155 | IF(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS) |
|---|
| | 156 | OPTION(OPENTHREADS_USE_AGGRESSIVE_WARNINGS "Enable to activate aggressive warnings" OFF) |
|---|
| | 157 | MARK_AS_ADVANCED(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) |
|---|
| | 158 | |
|---|
| | 159 | IF(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) |
|---|
| | 160 | IF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
|---|
| | 161 | SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "Old CXX flags") |
|---|
| | 162 | SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 1 CACHE INTERNAL "Old CXX flags was set") |
|---|
| | 163 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENTHREADS_AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
|---|
| | 164 | ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
|---|
| | 165 | ELSE(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) |
|---|
| | 166 | # FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was |
|---|
| | 167 | # set. The better way would be to parse the string and remove each |
|---|
| | 168 | # option explicitly. |
|---|
| | 169 | IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
|---|
| | 170 | SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
|---|
| | 171 | SET(OLD_CMAKE_CXX_FLAGS_WAS_SET 0 CACHE INTERNAL "Old CXX flags was set") |
|---|
| | 172 | ENDIF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}") |
|---|
| | 173 | ENDIF(OPENTHREADS_USE_AGGRESSIVE_WARNINGS) |
|---|
| | 174 | ENDIF(OPENTHREADS_AGGRESSIVE_WARNING_FLAGS) |
|---|
| | 175 | |
|---|
| | 176 | |
|---|
| | 177 | ############################################################################### |
|---|
| | 178 | # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 |
|---|
| | 179 | # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. |
|---|
| | 180 | IF(APPLE) |
|---|
| | 181 | # These are just defaults/recommendations, but how we want to build |
|---|
| | 182 | # out of the box. But the user needs to be able to change these options. |
|---|
| | 183 | # So we must only set the values the first time CMake is run, or we |
|---|
| | 184 | # will overwrite any changes the user sets. |
|---|
| | 185 | # FORCE is used because the options are not reflected in the UI otherwise. |
|---|
| | 186 | IF(NOT "${OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE}") |
|---|
| | 187 | # This is really fragile, but CMake doesn't provide the OS system |
|---|
| | 188 | # version information we need. (Darwin versions can be changed |
|---|
| | 189 | # independently of OS X versions.) |
|---|
| | 190 | # It does look like CMake handles the CMAKE_OSX_SYSROOT automatically. |
|---|
| | 191 | IF(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| | 192 | SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) |
|---|
| | 193 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
|---|
| | 194 | ELSE(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| | 195 | IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| | 196 | SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE) |
|---|
| | 197 | #SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE) |
|---|
| | 198 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE) |
|---|
| | 199 | ELSE(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| | 200 | # No Universal Binary support |
|---|
| | 201 | ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) |
|---|
| | 202 | ENDIF(EXISTS /Developer/SDKs/10.5.sdk) |
|---|
| | 203 | ENDIF(NOT "${OPENTHREADS_CONFIG_HAS_BEEN_RUN_BEFORE}") |
|---|
| | 204 | ENDIF(APPLE) |
|---|
| | 205 | |
|---|