]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - CMakeLists.txt
gosthash2012: Provide cmake test for _addcarry_u64
[openssl-gost/engine.git] / CMakeLists.txt
index 0538af546a0a25bfc5e51341053acf02f5246600..5d6da65729cab1fa0d0dd5a81c5be0d8c4cdd85c 100644 (file)
@@ -4,6 +4,7 @@ project(gost-engine LANGUAGES C)
 include(GNUInstallDirs)
 include(CheckLibraryExists)
 include(CheckFunctionExists)
+include(CheckCSourceRuns)
 
 enable_testing()
 
@@ -26,6 +27,11 @@ if (ASAN)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g3 -fno-omit-frame-pointer")
 endif()
 
+# DEPRECATEDIN_3_0 CMAC
+set_source_files_properties(gost_omac.c PROPERTIES COMPILE_FLAGS -Wno-error=deprecated-declarations)
+# DEPRECATEDIN_3_0 HMAC
+set_source_files_properties(gost_keyexpimp.c PROPERTIES COMPILE_FLAGS -Wno-error=deprecated-declarations)
+
 set(CMAKE_C_STANDARD 90)
 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME_C)
 CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME_RT)
@@ -42,8 +48,28 @@ else()
  add_definitions(-DL_ENDIAN)
 endif()
 
+check_c_source_runs("
+  #ifdef _MSC_VER
+  # include <intrin.h>
+  #else
+  # include <x86intrin.h>
+  #endif
+  int main(void) {
+  unsigned long long x = -1, y = 1, r;
+    unsigned char cf;
+    cf = _addcarry_u64(1, (unsigned long)x, y, &r);
+    return !(cf == 1 && r == 1);
+  }
+  " ADDCARRY_U64)
+if (ADDCARRY_U64)
+  add_definitions(-DHAVE_ADDCARRY_U64)
+endif()
+
 set(BIN_DIRECTORY bin)
 
+# Same soversion as OpenSSL
+set(GOST_SOVERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}")
+
 set(OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BIN_DIRECTORY})
 
 #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
@@ -135,6 +161,11 @@ set(GOST_ENGINE_SOURCE_FILES
         gost_omac_acpkm.c
         )
 
+add_executable(test_digest test_digest.c)
+target_link_libraries(test_digest gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME digest
+       COMMAND test_digest)
+
 add_executable(test_curves test_curves.c)
 target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 add_test(NAME curves
@@ -150,6 +181,11 @@ target_link_libraries(test_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 add_test(NAME sign/verify
        COMMAND test_sign)
 
+add_executable(test_tls test_tls.c)
+target_link_libraries(test_tls gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
+add_test(NAME TLS
+       COMMAND test_tls)
+
 add_executable(test_context test_context.c)
 target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 add_test(NAME context
@@ -176,7 +212,7 @@ add_test(NAME engine
        COMMAND perl run_tests
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
 set_tests_properties(engine PROPERTIES ENVIRONMENT
-       "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY}")
+       "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf")
 endif()
 
 add_executable(sign benchmark/sign.c)
@@ -184,6 +220,7 @@ target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLO
 
 # All that may need to load just built engine will have path to it defined.
 set(BINARY_TESTS_TARGETS
+        test_digest
         test_curves
         test_params
         test_sign
@@ -191,14 +228,16 @@ set(BINARY_TESTS_TARGETS
         test_grasshopper
         test_keyexpimp
         test_gost89
+       test_tls
         )
 set_property(TARGET ${BINARY_TESTS_TARGETS} APPEND PROPERTY COMPILE_DEFINITIONS ENGINE_DIR="${OUTPUT_DIRECTORY}")
 
 add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES})
 set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
 
-add_library(gost_engine MODULE ${GOST_ENGINE_SOURCE_FILES})
+add_library(gost_engine SHARED ${GOST_ENGINE_SOURCE_FILES})
 set_target_properties(gost_engine PROPERTIES PREFIX "" OUTPUT_NAME "gost")
+set_target_properties(gost_engine PROPERTIES VERSION ${GOST_SOVERSION} SOVERSION ${GOST_SOVERSION})
 target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
 
 set(GOST_SUM_SOURCE_FILES
@@ -220,6 +259,10 @@ add_custom_target(tags
     COMMAND ctags -R . ${OPENSSL_ROOT_DIR}
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
+add_custom_target(tcl_tests
+    COMMAND ENGINE_DIR=${OUTPUT_DIRECTORY} sh ./runtest.sh
+    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tcl_tests)
+
 add_executable(test_tlstree test_tlstree.c)
 target_link_libraries(test_tlstree PUBLIC ${OPENSSL_CRYPTO_LIBRARY})