blob: c0bdc73e6ebc898a6feee1cad580e4a20d29d76d [file] [log] [blame]
Adam Langley07100c62015-01-16 15:20:54 -08001cmake_minimum_required (VERSION 2.8.10)
Adam Langley95c29f32014-06-20 12:00:00 -07002
3project (BoringSSL)
4
Brian Smith1d75c8b2015-01-23 17:25:44 -08005if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Adam Langley4a0f0c42015-01-28 16:37:10 -08006 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")
Adam Langley95c29f32014-06-20 12:00:00 -07008elseif(MSVC)
Brian Smithefed2212015-01-28 16:20:02 -08009 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.
David Benjamin3673be72015-02-11 15:12:05 -050014 "C4210" # nonstandard extension used : function given file scope
Brian Smithefed2212015-01-28 16:20:02 -080015 "C4242" # 'function' : conversion from 'int' to 'uint8_t',
16 # possible loss of data
17 "C4244" # 'function' : conversion from 'int' to 'uint8_t',
18 # possible loss of data
19 "C4245" # 'initializing' : conversion from 'long' to
20 # 'unsigned long', signed/unsigned mismatch
David Benjamin3673be72015-02-11 15:12:05 -050021 "C4267" # conversion from 'size_t' to 'int', possible loss of data
22 "C4311" # 'type cast' : pointer truncation from 'uint8_t *' to 'long'
23 # TODO(davidben): Fix the s3_pkt.c's alignment code to avoid this.
24 "C4371" # layout of class may have changed from a previous version of the
25 # compiler due to better packing of member '...'
26 "C4388" # signed/unsigned mismatch
Brian Smithefed2212015-01-28 16:20:02 -080027 "C4296" # '>=' : expression is always true
28 "C4350" # behavior change: 'std::_Wrap_alloc...'
29 "C4365" # '=' : conversion from 'size_t' to 'int',
30 # signed/unsigned mismatch
31 "C4389" # '!=' : signed/unsigned mismatch
32 "C4510" # 'argument' : default constructor could not be generated
33 "C4512" # 'argument' : assignment operator could not be generated
34 "C4514" # 'function': unreferenced inline function has been removed
35 "C4548" # expression before comma has no effect; expected expression with
36 # side-effect" caused by FD_* macros.
37 "C4610" # struct 'argument' can never be instantiated - user defined
38 # constructor required.
David Benjamin3673be72015-02-11 15:12:05 -050039 "C4625" # copy constructor could not be generated because a base class
40 # copy constructor is inaccessible or deleted
41 "C4626" # assignment operator could not be generated because a base class
42 # assignment operator is inaccessible or deleted
Brian Smithefed2212015-01-28 16:20:02 -080043 "C4701" # potentially uninitialized local variable 'mdlen' used
44 "C4706" # assignment within conditional expression
45 "C4710" # 'function': function not inlined
46 "C4711" # function 'function' selected for inline expansion
47 "C4800" # 'int' : forcing value to bool 'true' or 'false'
48 # (performance warning)
49 "C4820" # 'bytes' bytes padding added after construct 'member_name'
50 "C4996" # 'read': The POSIX name for this item is deprecated. Instead,
51 # use the ISO C++ conformant name: _read.
52 )
53 string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
54 ${MSVC_DISABLED_WARNINGS_LIST})
55 set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}")
56 set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}")
Adam Langley4a0f0c42015-01-28 16:37:10 -080057 add_definitions(-D_HAS_EXCEPTIONS=0)
Brian Smitha87de9b2015-01-28 20:34:47 -080058 add_definitions(-DWIN32_LEAN_AND_MEAN)
Adam Langley95c29f32014-06-20 12:00:00 -070059endif()
60
Brian Smith1d75c8b2015-01-23 17:25:44 -080061if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.5.99") OR
62 CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Adam Langley4a0f0c42015-01-28 16:37:10 -080063 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
Adam Langley07100c62015-01-16 15:20:54 -080065endif()
66
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070067add_definitions(-DBORINGSSL_IMPLEMENTATION)
68
David Benjamin507c1ee2015-01-28 00:50:21 -050069if (BUILD_SHARED_LIBS)
Adam Langley4a0f0c42015-01-28 16:37:10 -080070 add_definitions(-DBORINGSSL_SHARED_LIBRARY)
71 # Enable position-independent code globally. This is needed because
72 # some library targets are OBJECT libraries.
73 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
David Benjamin507c1ee2015-01-28 00:50:21 -050074endif()
75
Adam Langley95c29f32014-06-20 12:00:00 -070076if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080077 set(ARCH "x86_64")
Piotr Sikora1d8adf12014-07-31 03:09:49 -070078elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080079 set(ARCH "x86_64")
Adam Langley95c29f32014-06-20 12:00:00 -070080elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080081 # cmake reports AMD64 on Windows, but we might be building for 32-bit.
82 if (CMAKE_CL_64)
83 set(ARCH "x86_64")
84 else()
85 set(ARCH "x86")
86 endif()
Adam Langley95c29f32014-06-20 12:00:00 -070087elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
Adam Langley4a0f0c42015-01-28 16:37:10 -080088 set(ARCH "x86")
Piotr Sikora1d8adf12014-07-31 03:09:49 -070089elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
Adam Langley4a0f0c42015-01-28 16:37:10 -080090 set(ARCH "x86")
Lukas Tribusd83f38c2014-08-11 13:27:44 -070091elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
Adam Langley4a0f0c42015-01-28 16:37:10 -080092 set(ARCH "x86")
Adam Langley95c29f32014-06-20 12:00:00 -070093elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
Adam Langley4a0f0c42015-01-28 16:37:10 -080094 set(ARCH "arm")
Adam Langley3e652652015-01-09 15:44:37 -080095elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
Adam Langley4a0f0c42015-01-28 16:37:10 -080096 set(ARCH "aarch64")
Adam Langley95c29f32014-06-20 12:00:00 -070097else()
Adam Langley4a0f0c42015-01-28 16:37:10 -080098 message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
Adam Langley95c29f32014-06-20 12:00:00 -070099endif()
100
Nico Weberdeb52842014-11-18 12:14:46 -0800101if (${ARCH} STREQUAL "x86" AND APPLE)
Adam Langley4a0f0c42015-01-28 16:37:10 -0800102 # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
103 # but clang defaults to 64-bit builds on OS X unless otherwise told.
104 # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
105 set(ARCH "x86_64")
Nico Weberdeb52842014-11-18 12:14:46 -0800106endif()
107
Adam Langley95c29f32014-06-20 12:00:00 -0700108add_subdirectory(crypto)
109add_subdirectory(ssl)
110add_subdirectory(ssl/test)
111add_subdirectory(tool)