| 1 |
# ***************************************************************************** |
| 2 |
# Copyright (c) 2017 Intel Corporation |
| 3 |
# |
| 4 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
# of this software and associated documentation files (the "Software"), to deal |
| 6 |
# in the Software without restriction, including without limitation the rights |
| 7 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 |
# copies of the Software, and to permit persons to whom the Software is |
| 9 |
# furnished to do so, subject to the following conditions: |
| 10 |
# |
| 11 |
# The above copyright notice and this permission notice shall be included in all |
| 12 |
# copies or substantial portions of the Software. |
| 13 |
# |
| 14 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 |
# SOFTWARE. |
| 21 |
# ***************************************************************************** |
| 22 |
|
| 23 |
# utility functions for cmake |
| 24 |
|
| 25 |
|
| 26 |
if(NOT DEFINED _bs_include_base_utils) |
| 27 |
|
| 28 |
set(_bs_include_base_utils TRUE) |
| 29 |
|
| 30 |
# bs_set_if_undefined - If not defined, assign value from env or arg |
| 31 |
macro(bs_set_if_undefined VAR_NAME VAR_VALUE) |
| 32 |
if(DEFINED ${VAR_NAME} AND NOT ${VAR_NAME} STREQUAL "") |
| 33 |
# Already defined - no action to take |
| 34 |
elseif(DEFINED ENV{VAR_NAME} AND NOT "$ENV{VAR_NAME}" STREQUAL "") |
| 35 |
set(${VAR_NAME} "$ENV{VAR_NAME}") |
| 36 |
else() |
| 37 |
set(${VAR_NAME} "${VAR_VALUE}") |
| 38 |
endif() |
| 39 |
endmacro() |
| 40 |
|
| 41 |
|
| 42 |
# function bs_check_build_type - Enforce build type variable consistency |
| 43 |
# |
| 44 |
# Ensure that deprecated variable UFO_BUILD_TYPE has the same value as |
| 45 |
# BUILD_TYPE. |
| 46 |
# |
| 47 |
# Ensure that the value of CMAKE_BUILD_TYPE is consistent with the value |
| 48 |
# of BUILD_TYPE. |
| 49 |
# |
| 50 |
# QuickBuild passes in BUILD_TYPE with per-word Caps. |
| 51 |
# The Linux makefiles force the value to lower-case. |
| 52 |
# For consistency, the same thing is done here. |
| 53 |
# |
| 54 |
function(bs_check_build_type) |
| 55 |
if(NOT DEFINED BUILD_TYPE OR "${BUILD_TYPE}" STREQUAL "") |
| 56 |
if(DEFINED UFO_BUILD_TYPE AND NOT "${UFO_BUILD_TYPE}" STREQUAL "") |
| 57 |
set(BUILD_TYPE "${UFO_BUILD_TYPE}") |
| 58 |
else() |
| 59 |
message("*BUILD_TYPE not defined, default to: release") |
| 60 |
set(BUILD_TYPE "release") |
| 61 |
endif() |
| 62 |
endif() |
| 63 |
string(TOLOWER "${BUILD_TYPE}" BUILD_TYPE) |
| 64 |
|
| 65 |
if ("${BUILD_TYPE}" STREQUAL "release") |
| 66 |
set(_val_cmake_build_type "Release") |
| 67 |
elseif ("${BUILD_TYPE}" STREQUAL "release-internal") |
| 68 |
set(_val_cmake_build_type "ReleaseInternal") |
| 69 |
elseif ("${BUILD_TYPE}" STREQUAL "debug") |
| 70 |
set(_val_cmake_build_type "Debug") |
| 71 |
else() |
| 72 |
set(_val_cmake_build_type "${BUILD_TYPE}") |
| 73 |
endif() |
| 74 |
|
| 75 |
if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") |
| 76 |
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "${_val_cmake_build_type}") |
| 77 |
# Would consider FATAL_ERROR, except for pre-existing condition |
| 78 |
# in Linux legacy build system: |
| 79 |
# In invocation of Source/instrumentation/instr.cmake : |
| 80 |
# Inconsistent: BUILD_TYPE="release-internal" vs CMAKE_BUILD_TYPE="Release" |
| 81 |
message(WARNING "Inconsistent: BUILD_TYPE=\"${BUILD_TYPE}\" vs CMAKE_BUILD_TYPE=\"${CMAKE_BUILD_TYPE}\"") |
| 82 |
endif() |
| 83 |
else() |
| 84 |
set(CMAKE_BUILD_TYPE "${_val_cmake_build_type}") |
| 85 |
endif() |
| 86 |
|
| 87 |
set(BUILD_TYPE "${BUILD_TYPE}" PARENT_SCOPE) |
| 88 |
set(UFO_BUILD_TYPE "${BUILD_TYPE}" PARENT_SCOPE) |
| 89 |
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" PARENT_SCOPE) |
| 90 |
|
| 91 |
endfunction(bs_check_build_type) |
| 92 |
|
| 93 |
|
| 94 |
endif(NOT DEFINED _bs_include_base_utils) |