From 0d4a81cfe5c01dd0046026fe196f30c55574db80 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sat, 29 Aug 2020 09:14:40 +0100 Subject: [PATCH] Added vcpkg file and unix build commands --- CMakeLists.txt | 5 +-- Makefile | 100 +++++++++++++++++++++++++++++++------------- test/TestTensor.cpp | 1 + vcpkg.json | 10 +++++ 4 files changed, 84 insertions(+), 32 deletions(-) create mode 100644 vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index bf7f43ee1..de329317f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18.0) +cmake_minimum_required(VERSION 3.17.0) project(kompute VERSION 0.1.0) set(CMAKE_CXX_STANDARD 17) @@ -13,8 +13,6 @@ set(CMAKE_VERBOSE_MAKEFILE on) option(KOMPUTE_OPT_BUILD_TESTS "Enable if you want to build tests" ON) option(KOMPUTE_OPT_BUILD_DOCS "Enable if you want to build documentation" ON) -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/config" ${CMAKE_MODULE_PATH}) - # Allow scripts to call main kompute Makefile function(kompute_make KOMPUTE_MAKE_TARGET) add_custom_target(${KOMPUTE_MAKE_TARGET} @@ -24,6 +22,7 @@ endfunction() add_subdirectory(src) if(KOMPUTE_OPT_BUILD_DOCS) + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/config" ${CMAKE_MODULE_PATH}) add_subdirectory(docs) endif() diff --git a/Makefile b/Makefile index 9296a0ca7..4675f4952 100755 --- a/Makefile +++ b/Makefile @@ -1,57 +1,99 @@ +# This makefile is optimized to be run from WSL and to interact with the +# Windows host as there are limitations when building GPU programs. This +# makefile contains the commands for interacting with the visual studio +# build via command line for faster iterations, as the intention is to +# support other editors (optimised for vim). There are also commands that +# support the builds for linux-native compilations and these are the commands +# starting with mk_. + +VCPKG_WIN_PATH ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" +VCPKG_UNIX_PATH ?= "/c/Users/axsau/Programming/lib/vcpkg/scripts/buildsystems/vcpkg.cmake" + ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... CMAKE_BIN ?= "C:\Program Files\CMake\bin\cmake.exe" SCMP_BIN="C:\\VulkanSDK\\1.2.141.2\\Bin32\\glslangValidator.exe" MSBUILD_BIN ?= "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" - VCPKG_CMAKE ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" else CLANG_FORMAT_BIN ?= "/home/alejandro/Programming/lib/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang-format" CMAKE_BIN ?= "/c/Program Files/CMake/bin/cmake.exe" SCMP_BIN ?= "/c/VulkanSDK/1.2.141.2/Bin32/glslangValidator.exe" MSBUILD_BIN ?= "/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe" - VCPKG_CMAKE ?= "C:\\Users\\axsau\\Programming\\lib\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" endif ####### Main Target Rules ####### -run_cmake: - $(CMAKE_BIN) \ - -Bbuild \ - -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_CMAKE) \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -G "Visual Studio 16 2019" - push_docs_to_ghpages: GIT_DEPLOY_DIR="build/docs/sphinx/" \ GIT_DEPLOY_BRANCH="gh-pages" \ GIT_DEPLOY_REPO="origin" \ ./scripts/push_folder_to_branch.sh -####### Visual studio build shortcut commands ####### - -build_all: - $(MSBUILD_BIN) build/kompute.sln - -build_docs: - $(MSBUILD_BIN) build/docs/gendocsall.vcxproj - -build_kompute: - $(MSBUILD_BIN) build/src/kompute.vcxproj - -build_tests: - $(MSBUILD_BIN) build/test/test_kompute.vcxproj - -run_docs: build_docs - (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) - -run_tests: build_tests - ./build/test/Debug/test_kompute.exe +####### CMAKE quickstart commands ####### clean_cmake: rm -rf build/ +####### Visual studio build shortcut commands ####### + +mk_cmake: + $(CMAKE_BIN) \ + -Bbuild \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_UNIX_PATH) \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ + -G "Unix Makefiles" + +mk_build_all: + make -C build/ + +mk_build_docs: + make -C build/ docs + +mk_build_kompute: + make -C build/ kompute + +mk_build_tests: + make -C build/ test_kompute + +mk_run_docs: mk_build_docs + (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) + +mk_run_tests: mk_build_tests + ./build/test/test_kompute + + +####### Visual studio build shortcut commands ####### + +vs_cmake: + $(CMAKE_BIN) \ + -Bbuild \ + -DCMAKE_TOOLCHAIN_FILE=$(VCPKG_WIN_PATH) \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -G "Visual Studio 16 2019" + +vs_build_all: + $(MSBUILD_BIN) build/kompute.sln + +vs_build_docs: + $(MSBUILD_BIN) build/docs/gendocsall.vcxproj + +vs_build_kompute: + $(MSBUILD_BIN) build/src/kompute.vcxproj + +vs_build_tests: + $(MSBUILD_BIN) build/test/test_kompute.vcxproj + +vs_run_docs: vs_build_docs + (cd build/docs/sphinx && python2.7 -m SimpleHTTPServer) + +vs_run_tests: vs_build_tests + ./build/test/Debug/test_kompute.exe + +####### General project commands ####### + install_python_reqs: python -m pip install -r scripts/requirements.txt diff --git a/test/TestTensor.cpp b/test/TestTensor.cpp index 5db4fe86d..6d54163ad 100644 --- a/test/TestTensor.cpp +++ b/test/TestTensor.cpp @@ -6,6 +6,7 @@ TEST_CASE("Tensor should have same vector as initialised") { std::vector vec{0,1,2}; kp::Tensor tensor(vec); + REQUIRE( tensor.size() == vec.size() ); REQUIRE( tensor.data() == vec ); } diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..e60b5f8cd --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "example", + "version-string": "0.0.1", + "dependencies": [ + "fmt", + "spdlog", + "vulkan", + "catch2" + ] +}