upgrade-apply-deltafs: Add possibility to build this binary on host by adding a cmake...
[platform/core/system/upgrade.git] / CMakeLists.txt
1 #
2 # upgrade-engine
3 #
4 # Copyright (c) 2022 Samsung Electronics Co., Ltd.
5 #
6 # Licensed under the Apache License, Version 2.0 (the License);
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 CMAKE_MINIMUM_REQUIRED(VERSION 2.82)
19 PROJECT(upgrade C)
20
21 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/)
22
23 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
24         SET(CMAKE_BUILD_TYPE "Release")
25 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
26 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
27
28 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -fPIE")
29 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
30 SET(CMAKE_C_FLAGS_RELEASE "-O2")
31
32 FIND_PROGRAM(UNAME NAMES uname)
33 IF("${ARCH}" STREQUAL "arm")
34         ADD_DEFINITIONS("-DTARGET")
35         MESSAGE("add -DTARGET")
36 ENDIF("${ARCH}" STREQUAL "arm")
37
38 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
39
40 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
41
42 # set this to ON if you want to build on host
43 OPTION(DEFINE_HOST_BUILD OFF)
44 IF(DEFINE_HOST_BUILD)
45         INCLUDE(CMakeLists.host-build)
46 ELSE()
47         INCLUDE(CMakeLists.target-build)
48 ENDIF()