Skip to content

Commit

Permalink
Add support for CMAKE_BUILD_TYPE as the major flag
Browse files Browse the repository at this point in the history
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. #70
    2. #86
  • Loading branch information
johnmach committed Jun 2, 2022
1 parent 0f0d3bf commit 1996301
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 9 additions & 8 deletions Source/GmmLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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 "")
Expand Down
2 changes: 1 addition & 1 deletion Source/GmmLib/inc/External/Common/GmmResourceInfoCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
101 changes: 72 additions & 29 deletions Tools/bldsys/include/bs_base_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}}")
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()
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)

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)
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()

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()

endfunction(bs_check_build_type)
endif(NOT DEFINED _bs_include_base_utils)

0 comments on commit 1996301

Please sign in to comment.