Update Iot.js
[platform/upstream/iotjs.git] / cmake / http-parser.cmake
1 # Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 cmake_minimum_required(VERSION 2.8)
16
17 if("${TARGET_OS}" MATCHES "NUTTX|TIZENRT")
18   set(HTTPPARSER_NUTTX_ARG -DNUTTX_HOME=${TARGET_SYSTEMROOT})
19 endif()
20
21 set(DEPS_HTTPPARSER deps/http-parser)
22 set(DEPS_HTTPPARSER_SRC ${ROOT_DIR}/${DEPS_HTTPPARSER}/)
23 ExternalProject_Add(http-parser
24   PREFIX ${DEPS_HTTPPARSER}
25   SOURCE_DIR ${DEPS_HTTPPARSER_SRC}
26   BUILD_IN_SOURCE 0
27   BINARY_DIR ${DEPS_HTTPPARSER}
28   INSTALL_COMMAND
29     ${CMAKE_COMMAND} -E copy
30     ${CMAKE_BINARY_DIR}/${DEPS_HTTPPARSER}/libhttpparser.a
31     ${CMAKE_BINARY_DIR}/lib/
32   CMAKE_ARGS
33     -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
34     -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
35     -DBUILDTYPE=${CMAKE_BUILD_TYPE} # TODO: use CMAKE_BUILD_TYPE in sub-project
36     -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
37     -DOS=${TARGET_OS}
38     ${HTTPPARSER_NUTTX_ARG}
39 )
40 add_library(libhttp-parser STATIC IMPORTED)
41 add_dependencies(libhttp-parser http-parser)
42 set_property(TARGET libhttp-parser PROPERTY
43   IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib/libhttpparser.a)
44 set_property(DIRECTORY APPEND PROPERTY
45   ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/lib/libhttpparser.a)
46
47 set(HTTPPARSER_INCLUDE_DIR ${DEPS_HTTPPARSER_SRC})