Skip to content

Commit 06503f2

Browse files
lamb-jscchan
andcommitted
[Comgr][SPIRV] add check for LLVMSPIRVLib.h in cmake (#291)
Disable SPIRV support in Comgr if LLVMSPIRVLib.h is not detected Co-authored-by: Siu Chi Chan <[email protected]>
1 parent ebcae69 commit 06503f2

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

amd/comgr/CMakeLists.txt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.13.4)
22

3+
include(CheckIncludeFileCXX)
4+
35
file(READ "VERSION.txt" comgr_ver_file)
46

57
string(REGEX MATCH "#COMGR_VERSION_MAJOR\n([0-9]*)" _ ${comgr_ver_file})
@@ -166,17 +168,29 @@ set(AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS ${LLVM_DEFINITIONS})
166168
set(AMD_COMGR_PUBLIC_LINKER_OPTIONS)
167169
set(AMD_COMGR_PRIVATE_LINKER_OPTIONS)
168170

169-
option(COMGR_DISABLE_SPIRV "To disable SPIRV in Comgr" OFF)
170-
if(${COMGR_DISABLE_SPIRV})
171-
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS "COMGR_DISABLE_SPIRV")
172-
endif()
173-
174171
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS "AMD_COMGR_GIT_COMMIT=${AMD_COMGR_GIT_COMMIT}")
175172
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS "AMD_COMGR_GIT_BRANCH=${AMD_COMGR_GIT_BRANCH}")
176173
message("----COMGR_GIT_COMMIT: ${AMD_COMGR_GIT_COMMIT}")
177174
message("----COMGR_GIT_BRANCH: ${AMD_COMGR_GIT_BRANCH}")
178175
message("")
179176

177+
option(COMGR_DISABLE_SPIRV "To disable SPIRV in Comgr" OFF)
178+
179+
if (NOT COMGR_DISABLE_SPIRV)
180+
CHECK_INCLUDE_FILE_CXX(LLVMSPIRVLib/LLVMSPIRVLib.h HAVE_LLVMSPIRVLIB_H)
181+
if (NOT HAVE_LLVMSPIRVLIB_H)
182+
set(COMGR_DISABLE_SPIRV ON)
183+
endif()
184+
endif()
185+
186+
if(${COMGR_DISABLE_SPIRV})
187+
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS "COMGR_DISABLE_SPIRV")
188+
message("-- Comgr SPIRV Disabled")
189+
else()
190+
message("-- Comgr SPIRV Enabled")
191+
endif()
192+
193+
180194
if (UNIX)
181195
list(APPEND AMD_COMGR_PRIVATE_COMPILE_OPTIONS
182196
-fno-rtti -Wall -Wno-attributes -fms-extensions -fvisibility=hidden)
@@ -389,11 +403,9 @@ set(LLD_LIBS
389403
lldCommon)
390404

391405
if (${COMGR_DISABLE_SPIRV})
392-
message("-- Comgr SPIRV Disabled")
393406
set(SPIRV_DYNAMIC_LIB "")
394407
set(SPIRV_STATIC_LIB "")
395408
else()
396-
message("-- Comgr SPIRV Enabled")
397409
set(SPIRV_DYNAMIC_LIB "LLVMSPIRVAMDLib")
398410
set(SPIRV_STATIC_LIB "SPIRVAMDLib")
399411
endif()

0 commit comments

Comments
 (0)