Skip to content

Commit 291d625

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

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})
@@ -167,17 +169,29 @@ set(AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS ${LLVM_DEFINITIONS})
167169
set(AMD_COMGR_PUBLIC_LINKER_OPTIONS)
168170
set(AMD_COMGR_PRIVATE_LINKER_OPTIONS)
169171

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

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

392406
if (${COMGR_DISABLE_SPIRV})
393-
message("-- Comgr SPIRV Disabled")
394407
set(SPIRV_DYNAMIC_LIB "")
395408
set(SPIRV_STATIC_LIB "")
396409
else()
397-
message("-- Comgr SPIRV Enabled")
398410
set(SPIRV_DYNAMIC_LIB "LLVMSPIRVAMDLib")
399411
set(SPIRV_STATIC_LIB "SPIRVAMDLib")
400412
endif()

0 commit comments

Comments
 (0)