Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame^] | 1 | cmake_minimum_required (VERSION 2.8.10) |
| 2 | |
| 3 | project (BoringSSL) |
| 4 | |
| 5 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 6 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -ggdb -fvisibility=hidden") |
| 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -ggdb -std=c++0x -fvisibility=hidden") |
| 8 | elseif(MSVC) |
| 9 | set(MSVC_DISABLED_WARNINGS_LIST |
| 10 | "C4100" # 'exarg' : unreferenced formal parameter |
| 11 | "C4127" # conditional expression is constant |
| 12 | "C4200" # nonstandard extension used : zero-sized array in |
| 13 | # struct/union. |
| 14 | "C4242" # 'function' : conversion from 'int' to 'uint8_t', |
| 15 | # possible loss of data |
| 16 | "C4244" # 'function' : conversion from 'int' to 'uint8_t', |
| 17 | # possible loss of data |
| 18 | "C4245" # 'initializing' : conversion from 'long' to |
| 19 | # 'unsigned long', signed/unsigned mismatch |
| 20 | "C4296" # '>=' : expression is always true |
| 21 | "C4350" # behavior change: 'std::_Wrap_alloc...' |
| 22 | "C4365" # '=' : conversion from 'size_t' to 'int', |
| 23 | # signed/unsigned mismatch |
| 24 | "C4389" # '!=' : signed/unsigned mismatch |
| 25 | "C4510" # 'argument' : default constructor could not be generated |
| 26 | "C4512" # 'argument' : assignment operator could not be generated |
| 27 | "C4514" # 'function': unreferenced inline function has been removed |
| 28 | "C4548" # expression before comma has no effect; expected expression with |
| 29 | # side-effect" caused by FD_* macros. |
| 30 | "C4610" # struct 'argument' can never be instantiated - user defined |
| 31 | # constructor required. |
| 32 | "C4701" # potentially uninitialized local variable 'mdlen' used |
| 33 | "C4706" # assignment within conditional expression |
| 34 | "C4710" # 'function': function not inlined |
| 35 | "C4711" # function 'function' selected for inline expansion |
| 36 | "C4800" # 'int' : forcing value to bool 'true' or 'false' |
| 37 | # (performance warning) |
| 38 | "C4820" # 'bytes' bytes padding added after construct 'member_name' |
| 39 | "C4996" # 'read': The POSIX name for this item is deprecated. Instead, |
| 40 | # use the ISO C++ conformant name: _read. |
| 41 | ) |
| 42 | string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR |
| 43 | ${MSVC_DISABLED_WARNINGS_LIST}) |
| 44 | set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}") |
| 45 | set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}") |
| 46 | add_definitions(-D_HAS_EXCEPTIONS=0) |
| 47 | add_definitions(-DWIN32_LEAN_AND_MEAN) |
| 48 | endif() |
| 49 | |
| 50 | if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.5.99") OR |
| 51 | CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 52 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow") |
| 53 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") |
| 54 | endif() |
| 55 | |
| 56 | add_definitions(-DBORINGSSL_IMPLEMENTATION) |
| 57 | |
| 58 | if (BUILD_SHARED_LIBS) |
| 59 | add_definitions(-DBORINGSSL_SHARED_LIBRARY) |
| 60 | # Enable position-independent code globally. This is needed because |
| 61 | # some library targets are OBJECT libraries. |
| 62 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 63 | endif() |
| 64 | |
| 65 | if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") |
| 66 | set(ARCH "x86_64") |
| 67 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64") |
| 68 | set(ARCH "x86_64") |
| 69 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") |
| 70 | # cmake reports AMD64 on Windows, but we might be building for 32-bit. |
| 71 | if (CMAKE_CL_64) |
| 72 | set(ARCH "x86_64") |
| 73 | else() |
| 74 | set(ARCH "x86") |
| 75 | endif() |
| 76 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86") |
| 77 | set(ARCH "x86") |
| 78 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386") |
| 79 | set(ARCH "x86") |
| 80 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686") |
| 81 | set(ARCH "x86") |
| 82 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm") |
| 83 | set(ARCH "arm") |
| 84 | elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64") |
| 85 | set(ARCH "aarch64") |
| 86 | else() |
| 87 | message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR}) |
| 88 | endif() |
| 89 | |
| 90 | if (${ARCH} STREQUAL "x86" AND APPLE) |
| 91 | # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X, |
| 92 | # but clang defaults to 64-bit builds on OS X unless otherwise told. |
| 93 | # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3. |
| 94 | set(ARCH "x86_64") |
| 95 | endif() |
| 96 | |
| 97 | add_subdirectory(crypto) |
| 98 | add_subdirectory(ssl) |
| 99 | add_subdirectory(ssl/test) |
| 100 | add_subdirectory(tool) |