Home | History | Annotate | Download | only in crypto
      1 include_directories(../include)
      2 
      3 if(APPLE)
      4   if (${ARCH} STREQUAL "x86")
      5     set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
      6   endif()
      7   set(PERLASM_STYLE macosx)
      8   set(ASM_EXT S)
      9   enable_language(ASM)
     10 elseif(UNIX)
     11   if (${ARCH} STREQUAL "aarch64")
     12     # The "armx" Perl scripts look for "64" in the style argument
     13     # in order to decide whether to generate 32- or 64-bit asm.
     14     set(PERLASM_STYLE linux64)
     15   elseif (${ARCH} STREQUAL "arm")
     16     set(PERLASM_STYLE linux32)
     17   elseif (${ARCH} STREQUAL "x86")
     18     set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
     19     set(PERLASM_STYLE elf)
     20   elseif (${ARCH} STREQUAL "ppc64le")
     21     set(PERLASM_STYLE ppc64le)
     22   else()
     23     set(PERLASM_STYLE elf)
     24   endif()
     25   set(ASM_EXT S)
     26   enable_language(ASM)
     27   set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,--noexecstack")
     28 else()
     29   if (CMAKE_CL_64)
     30     message("Using nasm")
     31     set(PERLASM_STYLE nasm)
     32   else()
     33     message("Using win32n")
     34     set(PERLASM_STYLE win32n)
     35     set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
     36   endif()
     37 
     38   # On Windows, we use the NASM output, specifically built with Yasm.
     39   set(ASM_EXT asm)
     40   enable_language(ASM_NASM)
     41 endif()
     42 
     43 function(perlasm dest src)
     44   add_custom_command(
     45     OUTPUT ${dest}
     46     COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest}
     47     DEPENDS
     48     ${src}
     49     ${PROJECT_SOURCE_DIR}/crypto/perlasm/arm-xlate.pl
     50     ${PROJECT_SOURCE_DIR}/crypto/perlasm/ppc-xlate.pl
     51     ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86_64-xlate.pl
     52     ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86asm.pl
     53     ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86gas.pl
     54     ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86masm.pl
     55     ${PROJECT_SOURCE_DIR}/crypto/perlasm/x86nasm.pl
     56     WORKING_DIRECTORY .
     57   )
     58 endfunction()
     59 
     60 # Level 0.1 - depends on nothing outside this set.
     61 add_subdirectory(stack)
     62 add_subdirectory(lhash)
     63 add_subdirectory(err)
     64 add_subdirectory(buf)
     65 add_subdirectory(base64)
     66 add_subdirectory(bytestring)
     67 add_subdirectory(pool)
     68 
     69 # Level 0.2 - depends on nothing but itself
     70 add_subdirectory(sha)
     71 add_subdirectory(md4)
     72 add_subdirectory(md5)
     73 add_subdirectory(modes)
     74 add_subdirectory(aes)
     75 add_subdirectory(des)
     76 add_subdirectory(rc4)
     77 add_subdirectory(conf)
     78 add_subdirectory(chacha)
     79 add_subdirectory(poly1305)
     80 add_subdirectory(curve25519)
     81 
     82 # Level 1, depends only on 0.*
     83 add_subdirectory(digest)
     84 add_subdirectory(cipher)
     85 add_subdirectory(rand)
     86 add_subdirectory(bio)
     87 add_subdirectory(bn)
     88 add_subdirectory(obj)
     89 add_subdirectory(asn1)
     90 
     91 # Level 2
     92 add_subdirectory(engine)
     93 add_subdirectory(dh)
     94 add_subdirectory(dsa)
     95 add_subdirectory(rsa)
     96 add_subdirectory(ec)
     97 add_subdirectory(ecdh)
     98 add_subdirectory(ecdsa)
     99 add_subdirectory(hmac)
    100 
    101 # Level 3
    102 add_subdirectory(cmac)
    103 add_subdirectory(evp)
    104 add_subdirectory(hkdf)
    105 add_subdirectory(pem)
    106 add_subdirectory(x509)
    107 add_subdirectory(x509v3)
    108 
    109 # Level 4
    110 add_subdirectory(pkcs8)
    111 
    112 # Test support code
    113 add_subdirectory(test)
    114 
    115 add_library(
    116   crypto
    117 
    118   cpu-aarch64-linux.c
    119   cpu-arm.c
    120   cpu-arm-linux.c
    121   cpu-intel.c
    122   cpu-ppc64le.c
    123   crypto.c
    124   ex_data.c
    125   mem.c
    126   refcount_c11.c
    127   refcount_lock.c
    128   thread.c
    129   thread_none.c
    130   thread_pthread.c
    131   thread_win.c
    132 
    133   $<TARGET_OBJECTS:stack>
    134   $<TARGET_OBJECTS:lhash>
    135   $<TARGET_OBJECTS:err>
    136   $<TARGET_OBJECTS:base64>
    137   $<TARGET_OBJECTS:bytestring>
    138   $<TARGET_OBJECTS:pool>
    139   $<TARGET_OBJECTS:sha>
    140   $<TARGET_OBJECTS:md4>
    141   $<TARGET_OBJECTS:md5>
    142   $<TARGET_OBJECTS:digest>
    143   $<TARGET_OBJECTS:cipher>
    144   $<TARGET_OBJECTS:modes>
    145   $<TARGET_OBJECTS:aes>
    146   $<TARGET_OBJECTS:des>
    147   $<TARGET_OBJECTS:rc4>
    148   $<TARGET_OBJECTS:conf>
    149   $<TARGET_OBJECTS:chacha>
    150   $<TARGET_OBJECTS:poly1305>
    151   $<TARGET_OBJECTS:curve25519>
    152   $<TARGET_OBJECTS:buf>
    153   $<TARGET_OBJECTS:bn>
    154   $<TARGET_OBJECTS:bio>
    155   $<TARGET_OBJECTS:rand>
    156   $<TARGET_OBJECTS:obj>
    157   $<TARGET_OBJECTS:asn1>
    158   $<TARGET_OBJECTS:engine>
    159   $<TARGET_OBJECTS:dh>
    160   $<TARGET_OBJECTS:dsa>
    161   $<TARGET_OBJECTS:rsa>
    162   $<TARGET_OBJECTS:ec>
    163   $<TARGET_OBJECTS:ecdh>
    164   $<TARGET_OBJECTS:ecdsa>
    165   $<TARGET_OBJECTS:hmac>
    166   $<TARGET_OBJECTS:cmac>
    167   $<TARGET_OBJECTS:evp>
    168   $<TARGET_OBJECTS:hkdf>
    169   $<TARGET_OBJECTS:pem>
    170   $<TARGET_OBJECTS:x509>
    171   $<TARGET_OBJECTS:x509v3>
    172   $<TARGET_OBJECTS:pkcs8_lib>
    173 )
    174 
    175 if(NOT MSVC AND NOT ANDROID)
    176   target_link_libraries(crypto pthread)
    177 endif()
    178 
    179 add_executable(
    180   thread_test
    181 
    182   thread_test.c
    183 
    184   $<TARGET_OBJECTS:test_support>
    185 )
    186 
    187 target_link_libraries(thread_test crypto)
    188 add_dependencies(all_tests thread_test)
    189 
    190 add_executable(
    191   refcount_test
    192 
    193   refcount_test.cc
    194 )
    195 
    196 target_link_libraries(refcount_test crypto)
    197 add_dependencies(all_tests refcount_test)
    198 
    199 # TODO(davidben): Convert the remaining tests to GTest.
    200 add_executable(
    201   crypto_test
    202 
    203   asn1/asn1_test.cc
    204   bio/bio_test.cc
    205   chacha/chacha_test.cc
    206   constant_time_test.cc
    207   curve25519/x25519_test.cc
    208   dh/dh_test.cc
    209   dsa/dsa_test.cc
    210   ec/ec_test.cc
    211   err/err_test.cc
    212   evp/evp_extra_test.cc
    213   rsa/rsa_test.cc
    214 
    215   $<TARGET_OBJECTS:gtest_main>
    216   $<TARGET_OBJECTS:test_support>
    217 )
    218 
    219 target_link_libraries(crypto_test crypto gtest)
    220 if (WIN32)
    221   target_link_libraries(crypto_test ws2_32)
    222 endif()
    223 add_dependencies(all_tests crypto_test)
    224