Skip to content

Commit c3c8cd1

Browse files
pguo-igcgfxbot
authored andcommitted
Refactoring IGC cmake files on detecting CPU size
Change-Id: I862c9e41018990c65ea4c0faa7c489e95e75c57d
1 parent 9d6a75a commit c3c8cd1

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

IGC/BiFModule/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
add_executable(IGC_TARGET__TOOLS_CLANG IMPORTED)
3939

4040
# Detect CPU architecture
41-
igc_arch_get_cpu(_cpuSuffix "${IGC_OPTION__ARCHITECTURE_TARGET}")
41+
igc_arch_get_cpu(_cpuSuffix)
4242
if(NOT _cpuSuffix MATCHES "^32$|^64$")
4343
message(STATUS "Unknown host CPU architecture ('" ${_cpuSuffix} "'), defaulting to using 64-bit Clang")
4444
set(_cpuSuffix "64")

IGC/CMakeLists.txt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,11 @@ function(igc_arch_get_os retVarName arch)
961961
endif()
962962
endfunction()
963963

964-
965-
# Gets CPU platform used in specified architecture. If it cannot be determined
966-
# the "Unknown-NOTFOUND" will be returned.
967-
#
968-
# @param retValName Name of variable placeholder where result will be returned.
969-
# @param arch Architecture name to get info from.
970-
function(igc_arch_get_cpu retVarName arch)
971-
if(arch MATCHES "${_os_detect_list}")
972-
set("${retVarName}" "${CMAKE_MATCH_2}" PARENT_SCOPE)
964+
function(igc_arch_get_cpu retVarName)
965+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
966+
set("${retVarName}" "64" PARENT_SCOPE)
973967
else()
974-
message(WARNING "oops, unable to get CPU platform for '${arch}'")
975-
set("${retVarName}" "Unknown-NOTFOUND" PARENT_SCOPE)
968+
set("${retVarName}" "32" PARENT_SCOPE)
976969
endif()
977970
endfunction()
978971

@@ -1219,7 +1212,7 @@ function(igc_tool_get_activity_commandline retVarName targetName activityName)
12191212

12201213
# Select most matching activity (with most matching architecture - most specific first, most generic last).
12211214
igc_arch_get_os(_archOs "${${__hostArchVarName}}")
1222-
igc_arch_get_cpu(_archCpu "${${__hostArchVarName}}")
1215+
igc_arch_get_cpu(_archCpu)
12231216

12241217
string(REPLACE ";" "\;" _activityName "${activityName}")
12251218
set(_activityPropNames
@@ -2101,7 +2094,7 @@ set(IGC_OPTION__BUILD_IGC_OPT ON CACHE BOOL "Build project igc_opt.")
21012094
set(IGC_OPTION__USCLAUNCHER_TOOL OFF CACHE BOOL
21022095
"Building USCLauncher tool for ILAdapter")
21032096

2104-
igc_arch_get_cpu(_cpuSuffix "${IGC_OPTION__ARCHITECTURE_TARGET}")
2097+
igc_arch_get_cpu(_cpuSuffix)
21052098
if(NOT DEFINED IGC_OPTION__OUTPUT_DIR)
21062099
set(IGC_OPTION__OUTPUT_DIR "${IGC_SOURCE_DIR}/../../dump${_cpuSuffix}/igc" CACHE PATH "Output directory path where the final libraries will be stored.")
21072100
endif()
@@ -3094,19 +3087,17 @@ set(IGC_BUID__VISA_COMPILE_DEFINITIONS
30943087
DLL_MODE
30953088
)
30963089

3097-
igc_arch_get_cpu(_cpuSuffix "${IGC_OPTION__ARCHITECTURE_TARGET}")
3098-
if(_cpuSuffix MATCHES "^64$")
3090+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
30993091
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
31003092
_AMD64_
31013093
AMD64
31023094
)
3103-
elseif(_cpuSuffix MATCHES "^32$")
3095+
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
31043096
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
31053097
_X86_=1
31063098
i386=1
31073099
)
31083100
endif()
3109-
unset(_cpuSuffix)
31103101

31113102
if(LLVM_ON_WIN32)
31123103
# NOTE: _WIN32 should be defined by compiler.
@@ -3120,7 +3111,7 @@ if(LLVM_ON_WIN32)
31203111
)
31213112

31223113
# NOTE: _WIN64 should be defined by compiler.
3123-
if(IGC_OPTION__ARCHITECTURE_TARGET MATCHES "^Windows64$")
3114+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
31243115
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
31253116
_WIN64
31263117
WIN64
@@ -3572,7 +3563,8 @@ endif()
35723563
if(LLVM_ON_UNIX)
35733564
set(_cpuSuffix "")
35743565
else()
3575-
igc_arch_get_cpu(_cpuSuffix "${IGC_OPTION__ARCHITECTURE_TARGET}")
3566+
3567+
igc_arch_get_cpu(_cpuSuffix)
35763568
endif()
35773569
set_target_properties("${IGC_BUILD__PROJ__igc_dll}" PROPERTIES OUTPUT_NAME "${IGC_LIBRARY_NAME}${_cpuSuffix}")
35783570
unset(_cpuSuffix)
@@ -3581,7 +3573,7 @@ unset(_cpuSuffix)
35813573
if(LLVM_ON_UNIX)
35823574
set(_cpuSuffix "")
35833575
else()
3584-
igc_arch_get_cpu(_cpuSuffix "${IGC_OPTION__ARCHITECTURE_TARGET}")
3576+
igc_arch_get_cpu(_cpuSuffix)
35853577
endif()
35863578
set_target_properties("${IGC_BUILD__PROJ__fcl_dll}" PROPERTIES OUTPUT_NAME "${FCL_LIBRARY_NAME}${_cpuSuffix}")
35873579
unset(_cpuSuffix)

0 commit comments

Comments
 (0)