diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a317c68e..8f23fc622 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/docs/overview/build-system.rst b/docs/overview/build-system.rst index 620711cc4..cb6933ba4 100644 --- a/docs/overview/build-system.rst +++ b/docs/overview/build-system.rst @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 950f95896..102d9527d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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