• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This file is part of the openHiTLS project.
2#
3# openHiTLS is licensed under the Mulan PSL v2.
4# You can use this software according to the terms and conditions of the Mulan PSL v2.
5# You may obtain a copy of Mulan PSL v2 at:
6#
7#     http://license.coscl.org.cn/MulanPSL2
8#
9# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
10# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
11# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
12# See the Mulan PSL v2 for more details.
13cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
14
15project(demo)
16
17message(status "HITLS_ROOT: ${HITLS_ROOT}")
18set(HITLS_ROOT ../..)
19set(HITLS_INCLUDE ${HITLS_ROOT}/include/bsl
20                  ${HITLS_ROOT}/include/crypto
21                  ${HITLS_ROOT}/include/tls
22                  ${HITLS_ROOT}/include/pki
23                  ${HITLS_ROOT}/include/auth
24                  ${HITLS_ROOT}/config/macro_config
25                  ${HITLS_ROOT}/platform/Secure_C/include)
26
27if(CUSTOM_CFLAGS)
28    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CUSTOM_CFLAGS}")
29endif()
30
31if(ENABLE_GCOV)
32    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
33endif()
34
35if(ENABLE_ASAN)
36    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-stack-protector -fno-omit-frame-pointer")
37endif()
38
39add_library(DEMO_INTF INTERFACE)
40target_compile_options(DEMO_INTF INTERFACE -g)
41target_link_directories(DEMO_INTF INTERFACE ${HITLS_ROOT}/build
42                                            ${HITLS_ROOT}/platform/Secure_C/lib/)
43
44target_link_libraries(DEMO_INTF INTERFACE hitls_tls hitls_pki hitls_auth hitls_crypto hitls_bsl boundscheck pthread dl)
45target_include_directories(DEMO_INTF INTERFACE ${HITLS_INCLUDE})
46
47set(TESTS client.c server.c drbg.c ecdh.c pbkdf2.c sm2enc.c sm2sign.c sm4cbc.c hash.c privpass_token.c)
48foreach(testcase ${TESTS})
49    get_filename_component(testname ${testcase} NAME_WLE)
50    add_executable(${testname} ${testcase})
51    target_link_libraries(${testname} PRIVATE DEMO_INTF)
52endforeach()
53