• 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)
16project (unit-core C)
17
18if (NOT IS_ABSOLUTE ${FEATURE_PROFILE})
19  set(FEATURE_PROFILE "${CMAKE_SOURCE_DIR}/jerry-core/profiles/${FEATURE_PROFILE}.profile")
20endif()
21
22if(${FEATURE_PROFILE} STREQUAL "${CMAKE_SOURCE_DIR}/jerry-core/profiles/minimal.profile")
23  message(FATAL_ERROR "minimal profile isn't supported in unit-core")
24endif()
25
26# Unit tests main modules
27file(GLOB SOURCE_UNIT_TEST_MAIN_MODULES *.c)
28
29# jerry_heap_stats_t.size == 0 if system allocator is used.
30if(JERRY_SYSTEM_ALLOCATOR)
31  list(REMOVE_ITEM SOURCE_UNIT_TEST_MAIN_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test-mem-stats.c)
32endif()
33
34# Unit tests declaration
35add_custom_target(unittests-core)
36
37foreach(SOURCE_UNIT_TEST_MAIN ${SOURCE_UNIT_TEST_MAIN_MODULES})
38  get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_MAIN} NAME_WE)
39  set(TARGET_NAME unit-${TARGET_NAME})
40
41  add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_MAIN})
42  target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_PRIVATE})
43  set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON}")
44  set_property(TARGET ${TARGET_NAME} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
45  target_link_libraries(${TARGET_NAME} jerry-core jerry-port-default-minimal)
46
47  add_dependencies(unittests-core ${TARGET_NAME})
48endforeach()
49