1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14cmake_minimum_required(VERSION 3.10) 15 16project(securec) 17 18set(SOURCES 19 ${SECUREC_ROOT}/src/securec/vsprintf_s.c 20 ${SECUREC_ROOT}/src/securec/wmemmove_s.c 21 ${SECUREC_ROOT}/src/securec/strncat_s.c 22 ${SECUREC_ROOT}/src/securec/vsnprintf_s.c 23 ${SECUREC_ROOT}/src/securec/fwscanf_s.c 24 ${SECUREC_ROOT}/src/securec/scanf_s.c 25 ${SECUREC_ROOT}/src/securec/strcat_s.c 26 ${SECUREC_ROOT}/src/securec/sscanf_s.c 27 ${SECUREC_ROOT}/src/securec/secureprintoutput_w.c 28 ${SECUREC_ROOT}/src/securec/wmemcpy_s.c 29 ${SECUREC_ROOT}/src/securec/wcsncat_s.c 30 ${SECUREC_ROOT}/src/securec/secureprintoutput_a.c 31 ${SECUREC_ROOT}/src/securec/secureinput_w.c 32 ${SECUREC_ROOT}/src/securec/memcpy_s.c 33 ${SECUREC_ROOT}/src/securec/fscanf_s.c 34 ${SECUREC_ROOT}/src/securec/vswscanf_s.c 35 ${SECUREC_ROOT}/src/securec/secureinput_a.c 36 ${SECUREC_ROOT}/src/securec/sprintf_s.c 37 ${SECUREC_ROOT}/src/securec/memmove_s.c 38 ${SECUREC_ROOT}/src/securec/swscanf_s.c 39 ${SECUREC_ROOT}/src/securec/snprintf_s.c 40 ${SECUREC_ROOT}/src/securec/vscanf_s.c 41 ${SECUREC_ROOT}/src/securec/vswprintf_s.c 42 ${SECUREC_ROOT}/src/securec/wcscpy_s.c 43 ${SECUREC_ROOT}/src/securec/vfwscanf_s.c 44 ${SECUREC_ROOT}/src/securec/memset_s.c 45 ${SECUREC_ROOT}/src/securec/wscanf_s.c 46 ${SECUREC_ROOT}/src/securec/vwscanf_s.c 47 ${SECUREC_ROOT}/src/securec/strtok_s.c 48 ${SECUREC_ROOT}/src/securec/wcsncpy_s.c 49 ${SECUREC_ROOT}/src/securec/vfscanf_s.c 50 ${SECUREC_ROOT}/src/securec/vsscanf_s.c 51 ${SECUREC_ROOT}/src/securec/wcstok_s.c 52 ${SECUREC_ROOT}/src/securec/securecutil.c 53 ${SECUREC_ROOT}/src/securec/gets_s.c 54 ${SECUREC_ROOT}/src/securec/swprintf_s.c 55 ${SECUREC_ROOT}/src/securec/strcpy_s.c 56 ${SECUREC_ROOT}/src/securec/wcscat_s.c 57 ${SECUREC_ROOT}/src/securec/strncpy_s.c 58) 59 60add_library(c_secshared ${PANDA_DEFAULT_LIB_TYPE} ${SOURCES}) 61target_include_directories(c_secshared PUBLIC ${SECUREC_ROOT}/include) 62target_compile_definitions(c_secshared PRIVATE NDEBUG SECUREC_SUPPORT_STRTOLD=1) 63if (PANDA_TARGET_WINDOWS) 64 target_compile_definitions(c_secshared PUBLIC _CRTBLD __LIBMSVCRT__) 65endif() 66target_compile_options(c_secshared PRIVATE -Wall -O1) 67 68if(HOST_TOOLS) 69 set_target_properties(c_secshared 70 PROPERTIES 71 ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/third_party/libc_sec 72 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/third_party/libc_sec 73 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/third_party/libc_sec 74 ) 75endif() 76 77 78if (PANDA_ENABLE_AFL) 79 add_library(c_secshared_fuzz ${PANDA_DEFAULT_LIB_TYPE} ${SOURCES}) 80 target_include_directories(c_secshared_fuzz PUBLIC ${SECUREC_ROOT}/include) 81 target_compile_definitions(c_secshared_fuzz PRIVATE NDEBUG SECUREC_SUPPORT_STRTOLD=1) 82 if (PANDA_TARGET_WINDOWS) 83 target_compile_definitions(c_secshared_fuzz PUBLIC _CRTBLD __LIBMSVCRT__) 84 endif() 85 86 if(NOT PANDA_AFL_COVERAGE) 87 set(AFL_NOOPT "--afl_noopt") 88 endif() 89 target_compile_options(c_secshared_fuzz PRIVATE -Wall -O1 ${AFL_NOOPT}) 90endif() 91