diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 3c710d61..00000000 --- a/.gitmodules +++ /dev/null @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b014c4a..0eb8a9ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") + +########################################################################################### +# 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) - 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() + 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) diff --git a/external/Vulkan-Headers b/external/Vulkan-Headers deleted file mode 160000 index 320af06c..00000000 --- a/external/Vulkan-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 320af06cbdd29848e1d7100d9b8e4e517db1dfd5 diff --git a/external/fmt b/external/fmt deleted file mode 160000 index 7bdf0628..00000000 --- a/external/fmt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b diff --git a/external/googletest b/external/googletest deleted file mode 160000 index 703bd9ca..00000000 --- a/external/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e diff --git a/external/spdlog b/external/spdlog deleted file mode 160000 index 01b350de..00000000 --- a/external/spdlog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 01b350de96483cf00b267c6db4c25f3b739b3fee diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5f303698..cad7f4ff 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,5 +1,4 @@ -add_subdirectory(pybind11) pybind11_add_module(kp src/main.cpp) include_directories( diff --git a/python/pybind11 b/python/pybind11 deleted file mode 160000 index 06a54018..00000000 --- a/python/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 06a54018c8a9fd9a7be5f5b56414b5da9259f637 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9747694f..38889c33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,12 +4,6 @@ if(KOMPUTE_OPT_ANDROID_BUILD) find_library(android android) 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) # all shaders are compiled into cpp files kompute_make(build_shaders @@ -60,49 +54,20 @@ if(NOT KOMPUTE_OPT_ANDROID_BUILD) target_link_libraries( kompute Vulkan::Vulkan + fmt::fmt ) else() target_link_libraries( kompute + fmt::fmt ) 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 - $) -endif() - -##################################################### -#################### fmt ####################### -##################################################### - -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 ####################### +#################### 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( kompute spdlog::spdlog @@ -110,7 +75,7 @@ if(KOMPUTE_OPT_ENABLE_SPDLOG) endif() ##################################################### -#################### Android ####################### +#################### Android ######################## ##################################################### if(KOMPUTE_OPT_ANDROID_BUILD) @@ -132,7 +97,7 @@ if(KOMPUTE_OPT_BUILD_SHADERS) endif() ##################################################### -#################### Single Header ####################### +#################### Single Header ################## ##################################################### if(KOMPUTE_OPT_BUILD_SINGLE_HEADER) @@ -161,9 +126,3 @@ if(KOMPUTE_OPT_INSTALL) NAMESPACE kompute:: DESTINATION lib/cmake/kompute) endif() - -if(KOMPUTE_OPT_BUILD_PYTHON) - include_directories(${PROJECT_SOURCE_DIR}/python/pybind11/include) - find_package(PythonLibs REQUIRED) - include_directories(${PYTHON_INCLUDE_DIRS}) -endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 562f1890..d1d949bd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,15 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 ##################################################### -#################### GETEST ####################### +#################### GOOGLETEST ##################### ##################################################### 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 "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" @@ -23,20 +17,7 @@ target_include_directories( $ $ ) - -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) +target_link_libraries(test_kompute kompute GTest::GTest) add_test(NAME test_kompute COMMAND test_kompute)