-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: rework to be able to build outside LLVM
v2: convert to lower case
- Loading branch information
1 parent
622f3ae
commit 141c2c1
Showing
7 changed files
with
116 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.3) | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
# Name & Version | ||
PROJECT(LLVM_SPIRV | ||
VERSION 0.1.0.0 | ||
LANGUAGES CXX) | ||
include(GNUInstallDirs) | ||
|
||
message(STATUS "LLVM-SPIRV found at ${CMAKE_CURRENT_SOURCE_DIR}") | ||
set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
set(LLVM_SPIRV_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
project(LLVM_SPIRV | ||
VERSION | ||
0.1.0.0 | ||
LANGUAGES | ||
CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
SUBDIRS(lib/SPIRV tools/llvm-spirv test) | ||
find_package(LLVM 7.0.0 REQUIRED) | ||
set(CMAKE_MODULE_PATH | ||
${CMAKE_MODULE_PATH} | ||
${LLVM_CMAKE_DIR} | ||
) | ||
include(AddLLVM) | ||
|
||
message(STATUS "Found LLVM: ${LLVM_VERSION}") | ||
|
||
set(LLVM_SPIRV_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
subdirs( | ||
lib/SPIRV | ||
tools/llvm-spirv | ||
test | ||
) | ||
|
||
install( | ||
FILES | ||
${LLVM_SPIRV_INCLUDE_DIRS}/SPIRV.h | ||
DESTINATION | ||
${CMAKE_INSTALL_INCLUDEDIR}/llvm-spirv/ | ||
) | ||
|
||
configure_file(LLVMSPIRVLib.pc.in ${CMAKE_BINARY_DIR}/LLVMSPIRVLib.pc @ONLY) | ||
install( | ||
FILES | ||
${CMAKE_BINARY_DIR}/LLVMSPIRVLib.pc | ||
DESTINATION | ||
${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=@CMAKE_INSTALL_PREFIX@ | ||
exec_prefix=${prefix} | ||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ | ||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ | ||
|
||
Name: LLVMSPIRVLib | ||
Description: LLVM/SPIR-V bi-direction translator | ||
Version: @LLVM_SPIRV_VERSION@ | ||
URL: https://github.com/KhronosGroup/SPIRV-LLVM-Translator | ||
|
||
Libs: -L${libdir} -lLLVMSPIRVLib | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
# required by lit.site.cfg.py.in | ||
get_target_property(LLVM_SPIRV_DIR llvm-spirv BINARY_DIR) | ||
configure_lit_site_cfg( | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in | ||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py | ||
MAIN_CONFIG | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py | ||
) | ||
|
||
list(APPEND LLVM_SPIRV_TEST_DEPS | ||
FileCheck count not | ||
llvm-as | ||
llvm-dis | ||
llvm-spirv | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py | ||
) | ||
|
||
add_lit_testsuite(check-llvm-spirv "Running the LLVM-SPIRV regression tests" | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
DEPENDS ${LLVM_SPIRV_TEST_DEPS} | ||
) | ||
ARGS | ||
--verbose | ||
DEPENDS | ||
llvm-spirv | ||
) | ||
|
||
# to enable a custom test target on cmake below 3.11 | ||
# starting with 3.11 "test" is only reserved if ENABLE_TESTING(ON) | ||
cmake_policy(PUSH) | ||
if(POLICY CMP0037 AND ${CMAKE_VERSION} VERSION_LESS "3.11.0") | ||
CMAKE_POLICY(SET CMP0037 OLD) | ||
endif() | ||
add_custom_target(test | ||
DEPENDS | ||
check-llvm-spirv | ||
) | ||
cmake_policy(POP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
set(LLVM_LINK_COMPONENTS | ||
Analysis | ||
BitReader | ||
BitWriter | ||
Core | ||
SPIRVLib | ||
Support | ||
TransformUtils | ||
) | ||
|
||
include_directories(${LLVM_SPIRV_INCLUDE_DIRS}) | ||
|
||
add_llvm_tool(llvm-spirv | ||
llvm-spirv.cpp | ||
) | ||
add_executable(llvm-spirv | ||
llvm-spirv.cpp | ||
) | ||
|
||
target_include_directories(llvm-spirv | ||
PRIVATE | ||
${LLVM_INCLUDE_DIR} | ||
${LLVM_SPIRV_INCLUDE_DIRS} | ||
) | ||
|
||
target_link_libraries(llvm-spirv | ||
LLVMSPIRVLib | ||
) | ||
|
||
install( | ||
TARGETS | ||
llvm-spirv | ||
DESTINATION | ||
${CMAKE_INSTALL_PREFIX}/bin | ||
) |