• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright JS Foundation and other contributors, http://js.foundation
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
15cmake_minimum_required (VERSION 2.8.12)
16set(JERRY_LIBM_NAME jerry-libm)
17project (${JERRY_LIBM_NAME} C)
18
19# Compiler / linker flags
20# TODO: Reduce the below list of warning/error disablings as much as possible
21set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-compare")
22set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-error=sign-conversion")
23set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-conversion")
24set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-sign-compare")
25set(COMPILE_FLAGS_LIBM "${COMPILE_FLAGS_LIBM} -Wno-strict-aliasing")
26
27# Include directories
28set(INCLUDE_LIBM "${CMAKE_CURRENT_SOURCE_DIR}/include")
29
30# Source directories
31file(GLOB SOURCE_LIBM *.c)
32
33# "Single" JerryScript libm source/header build.
34#  The process will create the following files:
35#   * jerryscript-libm.c
36#   * math.h
37if(ENABLE_ALL_IN_ONE_SOURCE)
38  file(GLOB HEADER_LIBM *.h)
39  set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/src/jerryscript-libm.c")
40  set(ALL_IN_FILE_H "${CMAKE_BINARY_DIR}/src/math.h")
41
42  add_custom_command(OUTPUT ${ALL_IN_FILE} ${ALL_IN_FILE_H} ${JERRYSCRIPT_CONFIG_H}
43                     COMMAND python ${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
44                             --jerry-libm
45                             --output-dir ${CMAKE_BINARY_DIR}/src
46                     DEPENDS ${SOURCE_LIBM}
47                             ${HEADER_LIBM}
48                             ${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
49                             ${CMAKE_SOURCE_DIR}/tools/srcmerger.py
50  )
51  add_custom_target(generate-single-source-libm DEPENDS ${ALL_IN_FILE} ${ALL_IN_FILE_H})
52  add_dependencies(generate-single-source generate-single-source-libm)
53
54  set(SOURCE_LIBM ${ALL_IN_FILE} ${ALL_IN_FILE_H})
55endif()
56
57add_library(${JERRY_LIBM_NAME} ${SOURCE_LIBM})
58set_property(TARGET ${JERRY_LIBM_NAME}
59             PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBM}")
60
61target_include_directories(${JERRY_LIBM_NAME} PUBLIC ${INCLUDE_LIBM})
62
63configure_file(libjerry-libm.pc.in libjerry-libm.pc @ONLY)
64
65install(TARGETS ${JERRY_LIBM_NAME} DESTINATION lib)
66install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjerry-libm.pc DESTINATION lib/pkgconfig)
67install(DIRECTORY ${INCLUDE_LIBM}/ DESTINATION include/jerry-libm)
68