You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

144 lines
5.7 KiB

  1. cmake_minimum_required (VERSION 2.8.10)
  2. project (BoringSSL)
  3. if(ANDROID)
  4. # Android-NDK CMake files reconfigure the path and so Go and Perl won't be
  5. # found. However, ninja will still find them in $PATH if we just name them.
  6. set(PERL_EXECUTABLE "perl")
  7. set(GO_EXECUTABLE "go")
  8. else()
  9. find_package(Perl REQUIRED)
  10. find_program(GO_EXECUTABLE go)
  11. endif()
  12. if (NOT GO_EXECUTABLE)
  13. message(FATAL_ERROR "Could not find Go")
  14. endif()
  15. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  16. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -ggdb -fvisibility=hidden")
  17. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -ggdb -std=c++0x -fvisibility=hidden")
  18. elseif(MSVC)
  19. set(MSVC_DISABLED_WARNINGS_LIST
  20. "C4100" # 'exarg' : unreferenced formal parameter
  21. "C4127" # conditional expression is constant
  22. "C4200" # nonstandard extension used : zero-sized array in
  23. # struct/union.
  24. "C4210" # nonstandard extension used : function given file scope
  25. "C4242" # 'function' : conversion from 'int' to 'uint8_t',
  26. # possible loss of data
  27. "C4244" # 'function' : conversion from 'int' to 'uint8_t',
  28. # possible loss of data
  29. "C4245" # 'initializing' : conversion from 'long' to
  30. # 'unsigned long', signed/unsigned mismatch
  31. "C4267" # conversion from 'size_t' to 'int', possible loss of data
  32. "C4371" # layout of class may have changed from a previous version of the
  33. # compiler due to better packing of member '...'
  34. "C4388" # signed/unsigned mismatch
  35. "C4296" # '>=' : expression is always true
  36. "C4350" # behavior change: 'std::_Wrap_alloc...'
  37. "C4365" # '=' : conversion from 'size_t' to 'int',
  38. # signed/unsigned mismatch
  39. "C4389" # '!=' : signed/unsigned mismatch
  40. "C4510" # 'argument' : default constructor could not be generated
  41. "C4512" # 'argument' : assignment operator could not be generated
  42. "C4514" # 'function': unreferenced inline function has been removed
  43. "C4548" # expression before comma has no effect; expected expression with
  44. # side-effect" caused by FD_* macros.
  45. "C4610" # struct 'argument' can never be instantiated - user defined
  46. # constructor required.
  47. "C4625" # copy constructor could not be generated because a base class
  48. # copy constructor is inaccessible or deleted
  49. "C4626" # assignment operator could not be generated because a base class
  50. # assignment operator is inaccessible or deleted
  51. "C4706" # assignment within conditional expression
  52. "C4710" # 'function': function not inlined
  53. "C4711" # function 'function' selected for inline expansion
  54. "C4800" # 'int' : forcing value to bool 'true' or 'false'
  55. # (performance warning)
  56. "C4820" # 'bytes' bytes padding added after construct 'member_name'
  57. "C4996" # 'read': The POSIX name for this item is deprecated. Instead,
  58. # use the ISO C++ conformant name: _read.
  59. )
  60. string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR
  61. ${MSVC_DISABLED_WARNINGS_LIST})
  62. set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}")
  63. set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR}")
  64. add_definitions(-D_HAS_EXCEPTIONS=0)
  65. add_definitions(-DWIN32_LEAN_AND_MEAN)
  66. add_definitions(-DNOMINMAX)
  67. endif()
  68. if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.7.99") OR
  69. CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  70. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
  71. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
  72. endif()
  73. if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR
  74. CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  75. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_XOPEN_SOURCE=700")
  76. endif()
  77. add_definitions(-DBORINGSSL_IMPLEMENTATION)
  78. if (BUILD_SHARED_LIBS)
  79. add_definitions(-DBORINGSSL_SHARED_LIBRARY)
  80. # Enable position-independent code globally. This is needed because
  81. # some library targets are OBJECT libraries.
  82. set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
  83. endif()
  84. if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
  85. set(ARCH "x86_64")
  86. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
  87. set(ARCH "x86_64")
  88. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
  89. # cmake reports AMD64 on Windows, but we might be building for 32-bit.
  90. if (CMAKE_CL_64)
  91. set(ARCH "x86_64")
  92. else()
  93. set(ARCH "x86")
  94. endif()
  95. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
  96. set(ARCH "x86")
  97. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
  98. set(ARCH "x86")
  99. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
  100. set(ARCH "x86")
  101. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
  102. set(ARCH "arm")
  103. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a")
  104. set(ARCH "arm")
  105. elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
  106. set(ARCH "aarch64")
  107. else()
  108. message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
  109. endif()
  110. if (ANDROID AND ${ARCH} STREQUAL "arm")
  111. # The Android-NDK CMake files somehow fail to set the -march flag for
  112. # assembly files. Without this flag, the compiler believes that it's
  113. # building for ARMv5.
  114. set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=armv7-a")
  115. endif()
  116. if (${ARCH} STREQUAL "x86" AND APPLE)
  117. # With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
  118. # but clang defaults to 64-bit builds on OS X unless otherwise told.
  119. # Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
  120. set(ARCH "x86_64")
  121. endif()
  122. if (OPENSSL_NO_ASM)
  123. add_definitions(-DOPENSSL_NO_ASM)
  124. set(ARCH "generic")
  125. endif()
  126. add_subdirectory(crypto)
  127. add_subdirectory(ssl)
  128. add_subdirectory(ssl/test)
  129. add_subdirectory(tool)
  130. add_subdirectory(decrepit)