jerryscript/jerry-libc/CMakeLists.txt
Akos Kiss f959ba95a4 Refactoring the build system
* Removed unused or unnecessary parts from various make files
* Eliminated lots of duplications from Makefile with the help of
  macros.
* Split tools/precommit.sh to its independent components:
  * the part that checks the existence of the "signed off" text in
    commit messages
    (this on got factored out to tools/check-signed-off.sh),
  * the part that uses vera++ for style checking (this one got
    factored out to tools/check-vera.sh),
  * the part that invokes targets in the cmake-generated build
    directory, and
  * the part that performs various tests (these latter two got
    moved into the Makefile).
* Moved the functionality of precommit-full-testing.sh into the
  Makefile, too.
* Added ninja build system support (e.g., `make NINJA=1`).
* Updated leading documentation comments (they were somewhat
  stale).
* Tried to keep the target names exactly the same as they were --
  almost succeeded... (some changes are intentional, and are
  subject to personal preferences).
* Simplified console output of `make precommit`
* Unified test runner scripts and their output format
  * Eliminated nothing-to-stdout everything-to-log-file policy:
    info is printed to stdout and it is the caller's
    responsibility to redirect it to a file if needed.
  * Also applied some renaming and coding style unification to
    the scripts.
* Merged the functionality of tools/runners/run-test-suite-jerry*.sh
  into the Makefile
* Merged everything related to a test suite execution in a single
  script.
  * The new script also allows to specify pass and xfail tests in
    a single list file, which was not possible hitherto.
  * Also, the paths of the test cases given in a file are
    interpreted relative to their container files.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-02-15 18:05:01 +01:00

153 lines
5.8 KiB
CMake

# Copyright 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required (VERSION 2.8.12)
project (Jerry_LibC C ASM)
# Compiler / linker flags
set(COMPILE_FLAGS_LIBC "${COMPILE_FLAGS_JERRY} ${C_FLAGS_JERRY}")
# Definitions
set(DEFINES_LIBC )
# Debug
set(DEFINES_LIBC_DEBUG )
# Release
set(DEFINES_LIBC_RELEASE LIBC_NDEBUG)
# Architecture-specific
# x86_64
set(DEFINES_LIBC_X86_64 __TARGET_HOST_x64)
# ARMv7-hf
set(DEFINES_LIBC_ARMV7_HF __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
# ARMv7-el
set(DEFINES_LIBC_ARMV7_EL __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
# x86
set(DEFINES_LIBC_X86 __TARGET_HOST_x86)
# Platform-specific
# Linux
set(DEFINES_LIBC_LINUX __TARGET_HOST)
# Darwin
set(DEFINES_LIBC_DARWIN __TARGET_HOST)
# MCU
set(DEFINES_LIBC_MCU __TARGET_MCU)
# stm32f3
set(DEFINES_LIBC_MCU_STM32F3 __TARGET_MCU_STM32F3)
# stm32f4
set(DEFINES_LIBC_MCU_STM32F4 __TARGET_MCU_STM32F4)
# Include directories
set(INCLUDE_LIBC ${CMAKE_SOURCE_DIR}/jerry-libc)
set(INCLUDE_LIBC_INTERFACE ${CMAKE_SOURCE_DIR}/jerry-libc/include)
set(INCLUDE_LIBC_INTERFACE ${INCLUDE_LIBC_INTERFACE} PARENT_SCOPE)
# Third-party
# Platform-specific
# Linux
set(INCLUDE_THIRD_PARTY_LINUX )
# Darwin
set(INCLUDE_THIRD_PARTY_DARWIN )
# MCU
# STM32F3
set(INCLUDE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
# STM32F4
set(INCLUDE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include)
# Sources
file(GLOB SOURCE_LIBC *.c)
# Platform-specific
# Linux
file(GLOB SOURCE_LIBC_LINUX target/linux/*.c target/linux/*.S)
# Darwin
file(GLOB SOURCE_LIBC_DARWIN target/darwin/*.c target/darwin/*.S)
# MCU
# stm32f3
file(GLOB SOURCE_LIBC_MCU_STM32F3 target/mcu-stubs/*.c target/mcu-stubs/*.S)
# stm32f4
file(GLOB SOURCE_LIBC_MCU_STM32F4 target/mcu-stubs/*.c target/mcu-stubs/*.S)
# Third-party
# Platform-specific
# MCU
# stm32f3
set(SOURCE_THIRD_PARTY_MCU_STM32F3
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c
${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/gcc_ride7/startup_stm32f30x.s)
# stm32f4
set(SOURCE_THIRD_PARTY_MCU_STM32F4
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s)
# Architecture-specific configuration
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86_64})
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-hf")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_HF})
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_ARMV7_EL})
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_X86})
else()
message(FATAL_ERROR "Unsupported machine architecture")
endif()
# Platform-specific configuration
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${PLATFORM}})
# Targets declaration
add_custom_target (jerry-libc-all)
string(TOLOWER ${PLATFORM_EXT} PLATFORM_L)
set(TARGET_NAME jerry-libc.${PLATFORM_L})
function(declare_targets_for_build_mode BUILD_MODE)
set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME})
set(DEFINES_LIBC ${DEFINES_LIBC} ${DEFINES_LIBC_${BUILD_MODE}})
set(INCLUDE_LIBC ${INCLUDE_LIBC} ${INCLUDE_LIBC_${PLATFORM_EXT}})
# Jerry
add_library(${TARGET_NAME}.lib STATIC ${SOURCE_LIBC} ${SOURCE_LIBC_${PLATFORM_EXT}})
set_property(TARGET ${TARGET_NAME}.lib
PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_LIBC} ${FLAGS_COMMON_${BUILD_MODE}}")
target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_LIBC})
target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_LIBC})
target_include_directories(${TARGET_NAME}.lib SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
add_dependencies(jerry-libc-all ${TARGET_NAME}.lib)
# Third-party MCU library
if(DEFINED SOURCE_THIRD_PARTY_${PLATFORM_EXT})
add_library(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} STATIC ${SOURCE_THIRD_PARTY_${PLATFORM_EXT}})
set_property(TARGET ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB}
PROPERTY COMPILE_FLAGS "${FLAGS_COMMON_${BUILD_MODE}}")
target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} PRIVATE ${INCLUDE_THIRD_PARTY_${PLATFORM_EXT}})
target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE})
target_link_libraries(${TARGET_NAME}.lib ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB})
endif()
endfunction()
declare_targets_for_build_mode(DEBUG)
declare_targets_for_build_mode(RELEASE)
declare_targets_for_build_mode(UNITTESTS)