• 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-ext C)
17
18set(INCLUDE_UNIT_EXT ${CMAKE_CURRENT_SOURCE_DIR})
19
20# Unit tests main modules
21file(GLOB SOURCE_UNIT_TEST_EXT_MODULES *.c)
22
23# Disable test-ext-autorelease.c if compiler is MSVC, because MSVC doesn't support cleanup attribute.
24if(USING_MSVC)
25  list(REMOVE_ITEM SOURCE_UNIT_TEST_EXT_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test-ext-autorelease.c)
26endif()
27
28# Unit tests declaration
29add_custom_target(unittests-ext)
30
31foreach(SOURCE_UNIT_TEST_EXT ${SOURCE_UNIT_TEST_EXT_MODULES})
32  get_filename_component(TARGET_NAME ${SOURCE_UNIT_TEST_EXT} NAME_WE)
33  set(TARGET_NAME unit-${TARGET_NAME})
34
35  add_executable(${TARGET_NAME} ${SOURCE_UNIT_TEST_EXT})
36  set_property(TARGET ${TARGET_NAME} PROPERTY LINK_FLAGS "${LINKER_FLAGS_COMMON}")
37  set_property(TARGET ${TARGET_NAME} PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
38
39  target_link_libraries(${TARGET_NAME} jerry-ext jerry-core jerry-port-default-minimal)
40
41  add_dependencies(unittests-ext ${TARGET_NAME})
42endforeach()
43
44file(GLOB CONTENTS_UNIT_TEST_EXT *)
45foreach(CONTENT_UNIT_TEST_EXT ${CONTENTS_UNIT_TEST_EXT})
46  if(IS_DIRECTORY ${CONTENT_UNIT_TEST_EXT})
47    add_subdirectory(${CONTENT_UNIT_TEST_EXT})
48  endif()
49endforeach()
50