Add SPIRV_SPIRV_COMPRESSION option to cmake

The option is off by default.
cmake -DSPIRV_BUILD_COMPRESSION=ON ..
enables the compression lib, executable, and test build.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/834
This commit is contained in:
Andrey Tuganov 2017-09-25 12:45:48 -04:00 committed by David Neto
parent cf6c20ee06
commit c25b5bea35
8 changed files with 44 additions and 29 deletions

View File

@ -36,7 +36,7 @@ build:
build_script:
- mkdir build && cd build
- cmake ..
- cmake -DSPIRV_BUILD_COMPRESSION=ON ..
- cmake --build . --config %CONFIGURATION%
test_script:

View File

@ -61,9 +61,10 @@ script:
-DANDROID_NATIVE_API_LEVEL=android-9
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a with NEON"
-DSPIRV_BUILD_COMPRESSION=ON
-DSPIRV_SKIP_TESTS=ON ..;
else
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..;
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DSPIRV_BUILD_COMPRESSION=ON ..;
fi
# Due to the limitation of Travis platform, we cannot start too many concurrent jobs.
# Otherwise GCC will panic with internal error, possibility because of memory issues.

View File

@ -10,6 +10,7 @@ v2017.1-dev 2017-09-01
- Fixes:
#798: spirv-as should fail when given unrecognized long option
#800: Inliner: Fix inlining function into header of multi-block loop
#834: Add Cmake option to build the compressing codec. Off by default.
v2017.0 2017-09-01
- Update README to describe that assembler, disassembler, and binary parser support

View File

@ -54,7 +54,9 @@ option(SKIP_SPIRV_TOOLS_INSTALL "Skip installation" ${SKIP_SPIRV_TOOLS_INSTALL})
if(NOT ${SKIP_SPIRV_TOOLS_INSTALL})
set(ENABLE_SPIRV_TOOLS_INSTALL ON)
endif()
option(SPIRV_BUILD_COMPRESSION "Build SPIR-V compressing codec" OFF)
option(SPIRV_WERROR "Enable error on warning" ON)
if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
set(COMPILER_IS_LIKE_GNU TRUE)

View File

@ -197,6 +197,8 @@ The following CMake options are supported:
the command line tools. This will prevent the tests from being built.
* `SPIRV_SKIP_EXECUTABLES={ON|OFF}`, default `OFF`- Build only the library, not
the command line tools and tests.
* `SPIRV_BUILD_COMPRESSION={ON|OFF}`, default `OFF`- Build SPIR-V compressing
codec.
* `SPIRV_USE_SANITIZER=<sanitizer>`, default is no sanitizing - On UNIX
platforms with an appropriate version of `clang` this option enables the use
of the sanitizers documented [here][clang-sanitizers].

View File

@ -12,23 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
add_library(SPIRV-Tools-comp markv_codec.cpp markv_autogen.cpp)
if(SPIRV_BUILD_COMPRESSION)
add_library(SPIRV-Tools-comp markv_codec.cpp markv_autogen.cpp)
spvtools_default_compile_options(SPIRV-Tools-comp)
target_include_directories(SPIRV-Tools-comp
PUBLIC ${spirv-tools_SOURCE_DIR}/include
PUBLIC ${SPIRV_HEADER_INCLUDE_DIR}
PRIVATE ${spirv-tools_BINARY_DIR}
)
spvtools_default_compile_options(SPIRV-Tools-comp)
target_include_directories(SPIRV-Tools-comp
PUBLIC ${spirv-tools_SOURCE_DIR}/include
PUBLIC ${SPIRV_HEADER_INCLUDE_DIR}
PRIVATE ${spirv-tools_BINARY_DIR}
)
target_link_libraries(SPIRV-Tools-comp
PUBLIC ${SPIRV_TOOLS})
target_link_libraries(SPIRV-Tools-comp
PUBLIC ${SPIRV_TOOLS})
set_property(TARGET SPIRV-Tools-comp PROPERTY FOLDER "SPIRV-Tools libraries")
set_property(TARGET SPIRV-Tools-comp PROPERTY FOLDER "SPIRV-Tools libraries")
if(ENABLE_SPIRV_TOOLS_INSTALL)
install(TARGETS SPIRV-Tools-comp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(ENABLE_SPIRV_TOOLS_INSTALL)
if(ENABLE_SPIRV_TOOLS_INSTALL)
install(TARGETS SPIRV-Tools-comp
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(ENABLE_SPIRV_TOOLS_INSTALL)
endif(SPIRV_BUILD_COMPRESSION)

View File

@ -17,7 +17,9 @@ set(VAL_TEST_COMMON_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/../unit_spirv.h
)
add_spvtools_unittest(TARGET markv_codec
SRCS markv_codec_test.cpp ${VAL_TEST_COMMON_SRCS}
LIBS SPIRV-Tools-comp ${SPIRV_TOOLS}
)
if(SPIRV_BUILD_COMPRESSION)
add_spvtools_unittest(TARGET markv_codec
SRCS markv_codec_test.cpp ${VAL_TEST_COMMON_SRCS}
LIBS SPIRV-Tools-comp ${SPIRV_TOOLS}
)
endif(SPIRV_BUILD_COMPRESSION)

View File

@ -42,8 +42,6 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES})
add_spvtools_tool(TARGET spirv-dis SRCS dis/dis.cpp LIBS ${SPIRV_TOOLS})
add_spvtools_tool(TARGET spirv-val SRCS val/val.cpp LIBS ${SPIRV_TOOLS})
add_spvtools_tool(TARGET spirv-opt SRCS opt/opt.cpp LIBS SPIRV-Tools-opt ${SPIRV_TOOLS})
add_spvtools_tool(TARGET spirv-markv SRCS comp/markv.cpp
LIBS SPIRV-Tools-comp ${SPIRV_TOOLS})
add_spvtools_tool(TARGET spirv-stats
SRCS stats/stats.cpp
stats/stats_analyzer.cpp
@ -57,11 +55,17 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES})
${SPIRV_HEADER_INCLUDE_DIR})
target_include_directories(spirv-stats PRIVATE ${spirv-tools_SOURCE_DIR}
${SPIRV_HEADER_INCLUDE_DIR})
target_include_directories(spirv-markv PRIVATE ${spirv-tools_SOURCE_DIR}
${SPIRV_HEADER_INCLUDE_DIR})
set(SPIRV_INSTALL_TARGETS spirv-as spirv-dis spirv-val spirv-opt spirv-stats spirv-cfg
spirv-markv)
set(SPIRV_INSTALL_TARGETS spirv-as spirv-dis spirv-val spirv-opt spirv-stats spirv-cfg)
if(SPIRV_BUILD_COMPRESSION)
add_spvtools_tool(TARGET spirv-markv SRCS comp/markv.cpp
LIBS SPIRV-Tools-comp ${SPIRV_TOOLS})
target_include_directories(spirv-markv PRIVATE ${spirv-tools_SOURCE_DIR}
${SPIRV_HEADER_INCLUDE_DIR})
set(SPIRV_INSTALL_TARGETS ${SPIRV_INSTALL_TARGETS} spirv-markv)
endif(SPIRV_BUILD_COMPRESSION)
if(ENABLE_SPIRV_TOOLS_INSTALL)
install(TARGETS ${SPIRV_INSTALL_TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}