| # Copyright (C) 2016 The Android Open Source Project |
| # |
| # 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. |
| |
| # Config is called once the project is initialized to configure the build. |
| |
| # Apply the options and environment to build controls |
| if(NO_CXX OR NOT CMAKE_CXX_COMPILER_WORKS) |
| set(DISABLED_CXX ON) |
| endif() |
| if(NO_GO OR ANDROID OR NOT CMAKE_Go_COMPILER_WORKS) |
| set(DISABLED_GO ON) |
| endif() |
| if(NO_CODE_GENERATION OR BUILDBOT OR CMAKE_CROSSCOMPILING) |
| set(DISABLED_CODE_GENERATION ON) |
| endif() |
| if(HOST_ONLY OR CMAKE_CROSSCOMPILING OR ANDROID OR NOT DEVICE_BUILDS OR DISABLED_CXX) |
| set(DISABLE_DEVICE_BUILDS ON) |
| endif() |
| if(NOT CMAKE_CROSSCOMPILING) |
| enable_testing() |
| endif() |
| |
| if(UNIX AND NOT (APPLE OR ANDROID OR WIN32)) |
| set(LINUX TRUE) |
| endif() |
| |
| # Support functions |
| include(Glob) |
| include(UseGo) |
| include(UseGradle) |
| include(UseCMake) |
| |
| # Global settings |
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| set(CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test) |
| |
| string(TOLOWER "${TARGET_OS}" PlatformSourcePath) |
| |
| # Standard compile options |
| set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
| set(CXX_STANDARD_REQUIRED ON) |
| add_definitions(-DTARGET_OS_${TARGET_OS}) |
| if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| add_definitions(-DLOG_LEVEL=3) |
| endif() |
| |
| #compile_options(${name} PUBLIC |
| #-Werror |
| #-Wall |
| #-Wextra |
| #-Wno-unused-variable |
| #) |