Added options to build dependencies as shared or static lib

This commit is contained in:
Alejandro Saucedo 2021-03-14 09:41:17 +00:00
parent 282326e8b8
commit 6bab776b03
3 changed files with 24 additions and 4 deletions

View file

@ -20,6 +20,8 @@ option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD, "Use the submodule repos instead of ext
option(KOMPUTE_OPT_ANDOID_BUILD "Enable android compilation flags required" 0)
option(KOMPUTE_OPT_DISABLE_VK_DEBUG_LAYERS "Explicitly disable debug layers even on debug" 0)
option(KOMPUTE_OPT_DISABLE_SHADER_UTILS "Remove shader util code and dependencies including glslang" 0)
option(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" 0)
option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared library" 0)
# Build flags
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list")
@ -29,6 +31,10 @@ if(KOMPUTE_OPT_ENABLE_SPDLOG)
if(KOMPUTE_OPT_INSTALL)
# Enable install parameters for spdlog (overrides parameters passed)
set(SPDLOG_INSTALL ON CACHE BOOL "Enables install of spdlot" FORCE)
if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS)
set(SPDLOG_BUILD_SHARED ON CACHE BOOL "Enables build of shared libraries" FORCE)
endif()
endif()
endif()
@ -54,7 +60,11 @@ if(NOT KOMPUTE_OPT_DISABLE_SHADER_UTILS)
# Enable install parameters for glslang (overrides parameters passed)
# When install is enabled the glslang libraries become shared
set(ENABLE_GLSLANG_INSTALL ON CACHE BOOL "Enables install of glslang" FORCE)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Enables build of shared libraries" FORCE)
# By default we enable shared library based installation
if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Enables build of shared libraries" FORCE)
endif()
endif()
else()
set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_DISABLE_SHADER_UTILS=1")

View file

@ -33,6 +33,10 @@ This by default configures without any of the extra build tasks (such as buildin
- Disables the install step in the cmake file (useful for android build)
* - -DKOMPUTE_OPT_ANDROID_BUILD=1
- Enables android build which includes and excludes relevant libraries
* - -DKOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS=1
- Ensures dependencies are referenced as shared libraries for kompute install
* - -DKOMPUTE_OPT_BUILD_AS_SHARED_LIB=1
- Whether to build Kompute as shared lib instead of static
Compile Flags

View file

@ -39,9 +39,15 @@ if(KOMPUTE_OPT_ANDOID_BUILD)
${PROJECT_SOURCE_DIR}/vk_ndk_wrapper_include/kompute_vk_ndk_wrapper.cpp)
endif()
add_library(
kompute STATIC
${kompute_CPP})
if(NOT KOMPUTE_OPT_BUILD_AS_SHARED_LIB)
add_library(
kompute STATIC
${kompute_CPP})
else()
add_library(
kompute SHARED
${kompute_CPP})
endif()
target_include_directories(
kompute PUBLIC