Replaced .gitmodules with fetch_content
Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
parent
4869d94f8a
commit
50ffbbc01a
10 changed files with 83 additions and 107 deletions
|
|
@ -9,7 +9,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
# Enable or disable targets
|
||||
option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 0)
|
||||
option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" 1)
|
||||
option(KOMPUTE_OPT_CODE_COVERAGE "Enable if you want code coverage" 0)
|
||||
option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" 0)
|
||||
option(KOMPUTE_OPT_BUILD_SHADERS "Enable if you want to re-build all shader files" 0)
|
||||
|
|
@ -18,7 +18,14 @@ option(KOMPUTE_OPT_INSTALL "Enable if you want to enable installation" 0)
|
|||
# Build options
|
||||
option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0)
|
||||
option(KOMPUTE_OPT_ENABLE_SPDLOG "Enable to compile with spdlog as the internal logging framework" 0)
|
||||
option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0)
|
||||
|
||||
# option(KOMPUTE_OPT_REPO_SUBMODULE_BUILD "Use the submodule repos instead of external package manager" 0)
|
||||
option(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG "Use the build in version of Spdlog" 1)
|
||||
option(KOMPUTE_OPT_USE_BUILD_IN_FMT "Use the build in version of fmt" 1)
|
||||
option(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST "Use the build in version of GoogleTest" 1)
|
||||
option(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11 "Use the build in version of pybind11" 1)
|
||||
|
||||
|
||||
option(KOMPUTE_OPT_ANDROID_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_DEPENDENCIES_SHARED_LIBS "Whether to use shared libraries for dependencies for install" 0)
|
||||
|
|
@ -26,22 +33,77 @@ option(KOMPUTE_OPT_BUILD_AS_SHARED_LIB "Whether to build kompute as shared libra
|
|||
# Build flags
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list")
|
||||
|
||||
if(KOMPUTE_OPT_ENABLE_SPDLOG)
|
||||
set(KOMPUTE_EXTRA_CXX_FLAGS "${KOMPUTE_EXTRA_CXX_FLAGS} -DKOMPUTE_ENABLE_SPDLOG=1")
|
||||
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Enables external fmt as its current dep" FORCE)
|
||||
if(KOMPUTE_OPT_INSTALL)
|
||||
# Enable install parameters for spdlog (overrides parameters passed)
|
||||
set(SPDLOG_INSTALL ON CACHE BOOL "Enables install of spdlog" FORCE)
|
||||
|
||||
if(KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS)
|
||||
set(SPDLOG_BUILD_SHARED ON CACHE BOOL "Enables build of shared libraries" FORCE)
|
||||
endif()
|
||||
###########################################################################################
|
||||
# Dependencies
|
||||
###########################################################################################
|
||||
include(FetchContent)
|
||||
|
||||
# Vulkan
|
||||
# We don't import Vulkan library if Android build as its build dynamically
|
||||
# Otherwise it is expected that the Vulkan SDK and dependencies are installed
|
||||
if(NOT KOMPUTE_OPT_ANDROID_BUILD)
|
||||
find_package(Vulkan REQUIRED)
|
||||
endif()
|
||||
|
||||
# Spdlog
|
||||
if(KOMPUTE_OPT_ENABLE_SPDLOG)
|
||||
if(KOMPUTE_OPT_USE_BUILD_IN_SPDLOG)
|
||||
set(SPDLOG_INSTALL ${KOMPUTE_OPT_INSTALL})
|
||||
set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS})
|
||||
|
||||
FetchContent_Declare(spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git
|
||||
GIT_TAG v1.10.0) # Source: https://github.com/gabime/spdlog/releases
|
||||
FetchContent_MakeAvailable(spdlog)
|
||||
else()
|
||||
find_package(spdlog REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_INSTALL)
|
||||
# Enable install parameters for fmt (overrides parameters passed)
|
||||
set(FMT_INSTALL ON CACHE BOOL "Enables install of fmt" FORCE)
|
||||
# fmt
|
||||
if(KOMPUTE_OPT_USE_BUILD_IN_FMT)
|
||||
set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL})
|
||||
set(BUILD_SHARED_LIBS_BKP ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS})
|
||||
set(SPDLOG_BUILD_SHARED ${KOMPUTE_OPT_DEPENDENCIES_SHARED_LIBS})
|
||||
FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
||||
GIT_TAG 8.1.1) # Source: https://github.com/fmtlib/fmt/releases
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_BKP})
|
||||
else()
|
||||
find_package(fmt REQUIRED)
|
||||
endif()
|
||||
|
||||
# GoogleTest
|
||||
if(KOMPUTE_OPT_BUILD_TESTS)
|
||||
if(KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST)
|
||||
FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG release-1.11.0) # Source: https://github.com/google/googletest/releases
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
add_library(gtest_int INTERFACE)
|
||||
target_link_libraries(gtest_int INTERFACE gtest)
|
||||
target_include_directories(gtest_int INTERFACE ${googletest_SOURCE_DIR}/include)
|
||||
|
||||
add_library(GTest::GTest ALIAS gtest_int)
|
||||
|
||||
# Group under the "tests/gtest" project folder in IDEs such as Visual Studio.
|
||||
set_property(TARGET gtest PROPERTY FOLDER "tests/gtest")
|
||||
set_property(TARGET gtest_main PROPERTY FOLDER "tests/gtest")
|
||||
else()
|
||||
find_package(GTest CONFIG REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# pybind11
|
||||
if(KOMPUTE_OPT_BUILD_PYTHON)
|
||||
if(KOMPUTE_OPT_USE_BUILD_IN_PYBIND11)
|
||||
FetchContent_Declare(pybind GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
||||
GIT_TAG v2.9.2) # Source: https://github.com/pybind/pybind11/releases
|
||||
FetchContent_MakeAvailable(pybind)
|
||||
else()
|
||||
find_package(pybind11 REQUIRED)
|
||||
endif()
|
||||
find_package(PythonLibs REQUIRED)
|
||||
endif()
|
||||
|
||||
if(KOMPUTE_OPT_ANDROID_BUILD)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue