1# 2# Copyright (c) 2019, The OpenThread Authors. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 3. Neither the name of the copyright holder nor the 13# names of its contributors may be used to endorse or promote products 14# derived from this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26# POSSIBILITY OF SUCH DAMAGE. 27# 28 29set(COMMON_INCLUDES 30 ${OT_PUBLIC_INCLUDES} 31 ${PROJECT_SOURCE_DIR}/src 32 ${PROJECT_SOURCE_DIR}/src/core 33 ${PROJECT_SOURCE_DIR}/src/posix/platform 34 ${PROJECT_SOURCE_DIR}/src/posix/platform/include 35) 36 37ot_option(OT_PLATFORM_POSIX_CONFIG_FILE OPENTHREAD_POSIX_CONFIG_CONFIGURATION_FILE_ENABLE "posix config file") 38 39set(OT_READLINE_VALUES 40 "readline" 41 "edit" 42) 43 44set(OT_READLINE "" CACHE STRING "set readline library name") 45set_property(CACHE OT_READLINE PROPERTY STRINGS ${OT_READLINE_VALUES}) 46 47if(OT_READLINE STREQUAL "") 48 foreach(X IN LISTS OT_READLINE_VALUES) 49 find_library(READLINE ${X}) 50 if (READLINE) 51 set(OT_READLINE ${X}) 52 break() 53 endif() 54 endforeach() 55elseif(OT_READLINE) 56 find_library(READLINE ${OT_READLINE}) 57 58 if (NOT READLINE) 59 message(FATAL_ERROR "Failed to find ${OT_READLINE}") 60 endif() 61endif() 62 63if (READLINE) 64 message(STATUS "Readline: ${OT_READLINE}") 65 66 find_library(NCURSES ncurses) 67 if (NOT NCURSES) 68 message(FATAL_ERROR "Failed to find ncurses") 69 endif() 70 71 list(APPEND READLINE_LINK_LIBRARIES "${READLINE}" "${NCURSES}") 72endif() 73 74if(OT_DAEMON) 75 include(daemon.cmake) 76 77 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 78 set(CPACK_PACKAGE_NAME "openthread-daemon") 79 endif() 80elseif(OT_APP_CLI) 81 include(cli.cmake) 82 83 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 84 set(CPACK_PACKAGE_NAME "openthread-standalone") 85 endif() 86endif() 87 88set(OT_POSIX_FACTORY_CONFIG "" CACHE STRING "OpenThread factory config file") 89set(OT_POSIX_PRODUCT_CONFIG "" CACHE STRING "OpenThread product config file") 90 91if (OT_POSIX_FACTORY_CONFIG) 92 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_POSIX_CONFIG_FACTORY_CONFIG_FILE=\"${OT_POSIX_FACTORY_CONFIG}\"") 93 message(STATUS "OT_POSIX_FACTORY_CONFIG=\"${OT_POSIX_FACTORY_CONFIG}\"") 94endif() 95 96if (OT_POSIX_PRODUCT_CONFIG) 97 target_compile_definitions(ot-config INTERFACE "OPENTHREAD_POSIX_CONFIG_PRODUCT_CONFIG_FILE=\"${OT_POSIX_PRODUCT_CONFIG}\"") 98 message(STATUS "OT_POSIX_PRODUCT_CONFIG=\"${OT_POSIX_PRODUCT_CONFIG}\"") 99endif() 100 101if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 102 set(CPACK_GENERATOR "DEB") 103 set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenThread Authors (https://github.com/openthread/openthread)") 104 set(CPACK_PACKAGE_CONTACT "OpenThread Authors (https://github.com/openthread/openthread)") 105 include(CPack) 106endif() 107