Add support for CMAKE_BUILD_TYPE as the major flag

This makes the CMAKE_BUILD_TYPE as the major flag for compilation.
The CMAKE_BUILD_TYPE has the higher priority than BUILD_TYPE.
BUILD_TYPE will be retained as few clients are using this flag but,
is subject to deprecation in future.

Also includes the project(igfx_gmmumd) in the top cmake file.

This commit resolves:
    1. https://github.com/intel/gmmlib/issues/70
    2. https://github.com/intel/gmmlib/issues/86
This commit is contained in:
John Machado 2022-06-02 22:47:14 +05:30 committed by GitHub
parent 0f0d3bfa0c
commit 19963011a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 38 deletions

View File

@ -4,4 +4,6 @@ if (NOT DEFINED RUN_TEST_SUITE)
option (RUN_TEST_SUITE "run test suite after install" ON)
endif (NOT DEFINED RUN_TEST_SUITE)
project(igfx_gmmumd)
add_subdirectory(Source/GmmLib)

View File

@ -144,6 +144,15 @@ if(CMAKE_CONFIGURATION_TYPES)
set( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
else()
if("${BUILD_TYPE}" STREQUAL "release")
set(CMAKE_BUILD_TYPE "Release")
elseif("${BUILD_TYPE}" STREQUAL "release-internal")
set(CMAKE_BUILD_TYPE "ReleaseInternal")
elseif("${BUILD_TYPE}" STREQUAL "debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
endif()
set(GMMLIB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@ -153,14 +162,6 @@ else()
set (GMMLIB_ARCH "32")
endif()
if ("${BUILD_TYPE}" STREQUAL "release")
set(CMAKE_BUILD_TYPE "Release")
elseif ("${BUILD_TYPE}" STREQUAL "release-internal")
set(CMAKE_BUILD_TYPE "ReleaseInternal")
elseif ("${BUILD_TYPE}" STREQUAL "debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch")
set(GMMLIB_MARCH "armv8-a+fp+simd")
elseif("${GMMLIB_MARCH}" STREQUAL "")

View File

@ -1377,7 +1377,7 @@ namespace GmmLib
{
if (GetResFlags().Info.TiledYf || GMM_IS_64KB_TILE(GetResFlags()))
{
HAlign = 1; // Ignored, but we'll retrun valid encoding nonetheless.
HAlign = 1; // Ignored, but we'll return valid encoding nonetheless.
}
else
{

View File

@ -33,6 +33,22 @@ if(NOT DEFINED _bs_include_base_utils)
endif()
endmacro()
macro(bs_compare_build_type _bs_compare_var)
if ("${_bs_compare_var}" STREQUAL "Release" OR "${_bs_compare_var}" STREQUAL "release")
set(T_CMAKE_BUILD_TYPE "Release")
set(BUILD_TYPE "release")
elseif ("${_bs_compare_var}" STREQUAL "ReleaseInternal" OR "${_bs_compare_var}" STREQUAL "release-internal" OR
"${_bs_compare_var}" STREQUAL "Release-Internal")
set(T_CMAKE_BUILD_TYPE "ReleaseInternal")
set(BUILD_TYPE "release-internal")
elseif ("${_bs_compare_var}" STREQUAL "Debug" OR "${_bs_compare_var}" STREQUAL "debug")
set(T_CMAKE_BUILD_TYPE "Debug")
set(BUILD_TYPE "debug")
else()
message(FATAL_ERROR "Build Type: ${_bs_compare_var} is undefined, Please enter correct value - exiting!")
endif()
endmacro()
set(_bs_check_build_type_done 0)
# function bs_check_build_type
@ -43,38 +59,65 @@ if(NOT DEFINED _bs_include_base_utils)
# Note: Despite the similarity of name, CMAKE_BUILD_TYPE is not analogous
# to UFO_BUILD_TYPE and BUILD_TYPE.
function(bs_check_build_type)
if(NOT ${_bs_check_build_type_done})
set(_bs_check_build_type_done 1 PARENT_SCOPE)
set(_bs_bt_var_names UFO_BUILD_TYPE BUILD_TYPE)
foreach(_bs_bt_var_a ${_bs_bt_var_names})
foreach(_bs_bt_var_b ${_bs_bt_var_names})
if(NOT _bs_bt_var_a STREQUAL _bs_bt_var_b)
if(DEFINED ${_bs_bt_var_a} AND DEFINED ${_bs_bt_var_b} AND NOT ${_bs_bt_var_a} STREQUAL ${_bs_bt_var_b})
message(FATAL_ERROR "Conflict: ${_bs_bt_var_a}=${${_bs_bt_var_a}} vs ${_bs_bt_var_b=${${_bs_bt_var_b}}}")
if(DEFINED CMAKE_BUILD_TYPE AND NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(_bs_check_build_type_done 1 PARENT_SCOPE)
bs_compare_build_type("${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE "${T_CMAKE_BUILD_TYPE}" PARENT_SCOPE) #set in parent scope
set(CMAKE_BUILD_TYPE "${T_CMAKE_BUILD_TYPE}") #set in current scope
set(BUILD_TYPE "${BUILD_TYPE}" PARENT_SCOPE)
message(STATUS "Single-configuration generator. Build type : ${CMAKE_BUILD_TYPE}")
elseif(DEFINED BUILD_TYPE AND NOT "${BUILD_TYPE}" STREQUAL "")
set(_bs_check_build_type_done 1 PARENT_SCOPE)
bs_compare_build_type("${BUILD_TYPE}")
set(CMAKE_BUILD_TYPE "${T_CMAKE_BUILD_TYPE}" PARENT_SCOPE) #set in parent scope
set(CMAKE_BUILD_TYPE "${T_CMAKE_BUILD_TYPE}") #set in current scope
set(BUILD_TYPE "${BUILD_TYPE}" PARENT_SCOPE)
message(STATUS "Single-configuration generator. Build type : ${CMAKE_BUILD_TYPE}")
else()
# If Build Type is not passed, Set as release builds as default
if(NOT ${_bs_check_build_type_done})
set(_bs_check_build_type_done 1 PARENT_SCOPE)
set(_bs_bt_var_names UFO_BUILD_TYPE BUILD_TYPE)
foreach(_bs_bt_var_a ${_bs_bt_var_names})
foreach(_bs_bt_var_b ${_bs_bt_var_names})
if(NOT _bs_bt_var_a STREQUAL _bs_bt_var_b)
if(DEFINED ${_bs_bt_var_a} AND DEFINED ${_bs_bt_var_b} AND NOT ${_bs_bt_var_a} STREQUAL ${_bs_bt_var_b})
message(FATAL_ERROR "Conflict: ${_bs_bt_var_a}=${${_bs_bt_var_a}} vs ${_bs_bt_var_b=${${_bs_bt_var_b}}}")
endif()
endif()
endforeach()
endforeach()
set(_bs_bt_value "")
foreach(_bs_bt_var_a ${_bs_bt_var_names})
if(DEFINED ${_bs_bt_var_a})
set(_bs_bt_value ${${_bs_bt_var_a}})
break()
endif()
endforeach()
if(_bs_bt_value STREQUAL "")
message("*BUILD_TYPE not defined, default to: release")
set(_bs_bt_value "release")
endif()
endif()
endforeach()
endforeach()
set(_bs_bt_value "")
foreach(_bs_bt_var_a ${_bs_bt_var_names})
if(DEFINED ${_bs_bt_var_a})
set(_bs_bt_value ${${_bs_bt_var_a}})
break()
endif()
endforeach()
if(_bs_bt_value STREQUAL "")
message("*BUILD_TYPE not defined, default to: release")
set(_bs_bt_value "release")
endif()
foreach(_bs_bt_var_a ${_bs_bt_var_names})
if(NOT DEFINED ${_bs_bt_var_a})
set(${_bs_bt_var_a} "${_bs_bt_value}" PARENT_SCOPE)
foreach(_bs_bt_var_a ${_bs_bt_var_names})
if(NOT DEFINED ${_bs_bt_var_a})
set(${_bs_bt_var_a} "${_bs_bt_value}" PARENT_SCOPE)
endif()
endforeach()
endif()
endforeach()
endif()
endfunction(bs_check_build_type)
endif(NOT DEFINED _bs_include_base_utils)