]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - CMakeLists.txt
Add native Visual Studio 2015-2017 build support.
[openssl-gost/engine.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
2 project(gost-engine LANGUAGES C)
3
4 include(GNUInstallDirs)
5
6 find_package(OpenSSL 1.1 REQUIRED)
7 include_directories(${OPENSSL_INCLUDE_DIR})
8
9 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
10  add_compile_options(-Qunused-arguments)
11 elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
12  add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb)
13 elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
14  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
15  add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS)
16  add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
17  add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115)
18 endif()
19
20 set(CMAKE_C_STANDARD 90)
21
22 include (TestBigEndian)
23 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
24 if(IS_BIG_ENDIAN)
25  message(STATUS "BIG_ENDIAN")
26 else()
27  message(STATUS "LITTLE_ENDIAN")
28  add_definitions(-DL_ENDIAN)
29 endif()
30
31 set(BIN_DIRECTORY bin)
32
33 set(OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/${BIN_DIRECTORY})
34
35 #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
36 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
37 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY})
38
39 set(GOST_89_SOURCE_FILES
40         gost89.c
41         gost89.h
42         )
43
44 set(GOST_HASH_SOURCE_FILES
45         gosthash.c
46         gosthash.h
47         )
48
49 set(GOST_HASH_2012_SOURCE_FILES
50         gosthash2012.c
51         gosthash2012.h
52         gosthash2012_const.h
53         gosthash2012_precalc.h
54         gosthash2012_ref.h
55         gosthash2012_sse2.h
56         )
57
58 set(GOST_GRASSHOPPER_SOURCE_FILES
59         gost_grasshopper.h
60         gost_grasshopper_core.h
61         gost_grasshopper_core.c
62         gost_grasshopper_defines.h
63         gost_grasshopper_defines.c
64         gost_grasshopper_math.h
65         gost_grasshopper_galois_precompiled.c
66         gost_grasshopper_precompiled.c
67         gost_grasshopper_cipher.h
68         gost_grasshopper_cipher.c
69         gost_grasshopper_mac.h
70         gost_grasshopper_mac.c
71         )
72
73 set(GOST_CORE_SOURCE_FILES
74         e_gost_err.c
75         e_gost_err.h
76         gost_asn1.c
77         gost_crypt.c
78         gost_ctl.c
79         gost_eng.c
80         gost_keywrap.c
81         gost_keywrap.h
82         gost_lcl.h
83         gost_params.c
84         )
85
86 set(GOST_EC_SOURCE_FILES
87         gost_ec_keyx.c
88         gost_ec_sign.c
89         )
90
91 set(GOST_LIB_SOURCE_FILES
92         ${GOST_89_SOURCE_FILES}
93         ${GOST_HASH_SOURCE_FILES}
94         ${GOST_HASH_2012_SOURCE_FILES}
95         ${GOST_GRASSHOPPER_SOURCE_FILES}
96         ${GOST_EC_SOURCE_FILES}
97         )
98
99 set(GOST_ENGINE_SOURCE_FILES
100         ${GOST_CORE_SOURCE_FILES}
101         gost_ameth.c
102         gost_md.c
103         gost_md2012.c
104         gost_pmeth.c
105         )
106
107 add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES})
108 set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
109
110 add_library(gost_engine MODULE ${GOST_ENGINE_SOURCE_FILES})
111 set_target_properties(gost_engine PROPERTIES PREFIX "" OUTPUT_NAME "gost")
112 target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY})
113
114 set(GOST_SUM_SOURCE_FILES
115         gostsum.c
116         )
117
118 add_executable(gostsum ${GOST_SUM_SOURCE_FILES})
119 target_link_libraries(gostsum gost_core)
120
121 set(GOST_12_SUM_SOURCE_FILES
122         gost12sum.c
123         )
124
125 add_executable(gost12sum ${GOST_12_SUM_SOURCE_FILES})
126 target_link_libraries(gost12sum gost_core)
127
128 # install
129 set(OPENSSL_ENGINES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/engines-${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR})
130 set(OPENSSL_MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1)
131
132 install(TARGETS gost_engine gostsum gost12sum EXPORT GostEngineConfig
133         LIBRARY  DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR}
134         RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR})
135 install(FILES gostsum.1 gost12sum.1 DESTINATION ${OPENSSL_MAN_INSTALL_DIR})
136 if (MSVC)
137  install(FILES $<TARGET_PDB_FILE:gost_engine> DESTINATION ${OPENSSL_ENGINES_INSTALL_DIR} OPTIONAL)
138  install(FILES $<TARGET_PDB_FILE:gostsum> $<TARGET_PDB_FILE:gost12sum> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
139 endif()