Replaced .gitmodules with fetch_content

Signed-off-by: Fabian Sauter <sauter.fabian@mailbox.org>
This commit is contained in:
Fabian Sauter 2022-05-10 09:31:30 +02:00
parent 4869d94f8a
commit 50ffbbc01a
10 changed files with 83 additions and 107 deletions

20
.gitmodules vendored
View file

@ -1,20 +0,0 @@
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest
branch = release-1.10.0
[submodule "external/Vulkan-Headers"]
path = external/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers
branch = v1.2.158
[submodule "external/spdlog"]
path = external/spdlog
url = https://github.com/gabime/spdlog
branch = v1.8.1
[submodule "python/pybind11"]
path = python/pybind11
url = https://github.com/pybind/pybind11
branch = v2.6.1
[submodule "external/fmt"]
path = external/fmt
url = https://github.com/fmtlib/fmt
branch = 7.1.3

View file

@ -9,7 +9,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_VERBOSE_MAKEFILE on)
# Enable or disable targets # 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_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_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) 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 # Build options
option(KOMPUTE_OPT_BUILD_PYTHON "Enable if you want to build python bindings" 0) 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_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_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_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) 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 # Build flags
set(KOMPUTE_EXTRA_CXX_FLAGS "" CACHE STRING "Extra compile flags for Kompute, see docs for full list") 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) # Dependencies
endif() ###########################################################################################
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()
endif() endif()
if(KOMPUTE_OPT_INSTALL) # fmt
# Enable install parameters for fmt (overrides parameters passed) if(KOMPUTE_OPT_USE_BUILD_IN_FMT)
set(FMT_INSTALL ON CACHE BOOL "Enables install of fmt" FORCE) 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() endif()
if(KOMPUTE_OPT_ANDROID_BUILD) if(KOMPUTE_OPT_ANDROID_BUILD)

@ -1 +0,0 @@
Subproject commit 320af06cbdd29848e1d7100d9b8e4e517db1dfd5

1
external/fmt vendored

@ -1 +0,0 @@
Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b

1
external/googletest vendored

@ -1 +0,0 @@
Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e

1
external/spdlog vendored

@ -1 +0,0 @@
Subproject commit 01b350de96483cf00b267c6db4c25f3b739b3fee

View file

@ -1,5 +1,4 @@
add_subdirectory(pybind11)
pybind11_add_module(kp src/main.cpp) pybind11_add_module(kp src/main.cpp)
include_directories( include_directories(

@ -1 +0,0 @@
Subproject commit 06a54018c8a9fd9a7be5f5b56414b5da9259f637

View file

@ -4,12 +4,6 @@ if(KOMPUTE_OPT_ANDROID_BUILD)
find_library(android android) find_library(android android)
endif() endif()
# 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()
if(KOMPUTE_OPT_BUILD_SHADERS) if(KOMPUTE_OPT_BUILD_SHADERS)
# all shaders are compiled into cpp files # all shaders are compiled into cpp files
kompute_make(build_shaders kompute_make(build_shaders
@ -60,49 +54,20 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD)
target_link_libraries( target_link_libraries(
kompute kompute
Vulkan::Vulkan Vulkan::Vulkan
fmt::fmt
) )
else() else()
target_link_libraries( target_link_libraries(
kompute kompute
fmt::fmt
) )
endif() endif()
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
# Override the default Vulkan::Vulkan headers
# In this case we only use the build interface due to https://github.com/KhronosGroup/Vulkan-Headers/issues/157
add_subdirectory(${PROJECT_SOURCE_DIR}/external/Vulkan-Headers ${CMAKE_CURRENT_BINARY_DIR}/kompute_vulkan_headers)
get_target_property(VULKAN_HEADERS_INCLUDES Vulkan-Headers INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(
kompute PUBLIC
$<BUILD_INTERFACE:${VULKAN_HEADERS_INCLUDES}>)
endif()
##################################################### #####################################################
#################### fmt ####################### #################### SPDLOG #########################
#####################################################
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/fmt ${CMAKE_CURRENT_BINARY_DIR}/kompute_fmt)
else()
find_package(fmt REQUIRED)
endif()
target_link_libraries(
kompute
fmt::fmt
)
#####################################################
#################### SPDLOG #######################
##################################################### #####################################################
if(KOMPUTE_OPT_ENABLE_SPDLOG) if(KOMPUTE_OPT_ENABLE_SPDLOG)
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/spdlog ${CMAKE_CURRENT_BINARY_DIR}/kompute_spdlog)
else()
find_package(spdlog REQUIRED)
endif()
target_link_libraries( target_link_libraries(
kompute kompute
spdlog::spdlog spdlog::spdlog
@ -110,7 +75,7 @@ if(KOMPUTE_OPT_ENABLE_SPDLOG)
endif() endif()
##################################################### #####################################################
#################### Android ####################### #################### Android ########################
##################################################### #####################################################
if(KOMPUTE_OPT_ANDROID_BUILD) if(KOMPUTE_OPT_ANDROID_BUILD)
@ -132,7 +97,7 @@ if(KOMPUTE_OPT_BUILD_SHADERS)
endif() endif()
##################################################### #####################################################
#################### Single Header ####################### #################### Single Header ##################
##################################################### #####################################################
if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) if(KOMPUTE_OPT_BUILD_SINGLE_HEADER)
@ -161,9 +126,3 @@ if(KOMPUTE_OPT_INSTALL)
NAMESPACE kompute:: NAMESPACE kompute::
DESTINATION lib/cmake/kompute) DESTINATION lib/cmake/kompute)
endif() endif()
if(KOMPUTE_OPT_BUILD_PYTHON)
include_directories(${PROJECT_SOURCE_DIR}/python/pybind11/include)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
endif()

View file

@ -1,15 +1,9 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
##################################################### #####################################################
#################### GETEST ####################### #################### GOOGLETEST #####################
##################################################### #####################################################
enable_testing() enable_testing()
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/googletest EXCLUDE_FROM_ALL
${CMAKE_CURRENT_BINARY_DIR}/kompute_googletest)
else()
find_package(GTest CONFIG REQUIRED)
endif()
file(GLOB test_kompute_CPP file(GLOB test_kompute_CPP
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
@ -23,20 +17,7 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compiled_shaders_include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compiled_shaders_include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils>
) )
target_link_libraries(test_kompute kompute GTest::GTest)
if(KOMPUTE_OPT_REPO_SUBMODULE_BUILD)
target_include_directories(
test_kompute PRIVATE
${gtest_SOURCE_DIR}/include)
target_link_libraries(test_kompute
gtest_main)
else()
target_link_libraries(test_kompute
GTest::gtest)
endif()
target_link_libraries(test_kompute kompute)
add_test(NAME test_kompute COMMAND test_kompute) add_test(NAME test_kompute COMMAND test_kompute)