+include(GNUInstallDirs)
+include(CheckLibraryExists)
+include(CheckFunctionExists)
+
+enable_testing()
+
+find_package(OpenSSL 1.1.1 REQUIRED)
+include_directories(${OPENSSL_INCLUDE_DIR})
+
+if (CMAKE_C_COMPILER_ID MATCHES "Clang")
+ add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb -Qunused-arguments)
+elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
+ add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb)
+elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
+ add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
+ add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115)
+endif()
+
+if (ASAN)
+ message(STATUS "address sanitizer enabled")
+ 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)
+if(HAVE_CLOCK_GETTIME_RT AND NOT HAVE_CLOCK_GETTIME_C)
+ set(CLOCK_GETTIME_LIB rt)
+endif()