From 973898b4207ed4eddfe417d039565541e882d6d7 Mon Sep 17 00:00:00 2001 From: cullvox Date: Mon, 24 Jun 2024 12:06:11 -0400 Subject: [PATCH 1/5] CMake, Windows fixes, Fix compilation of conversion test Added a basic cmake lists script. Fixed the overload template usage in the conversion test, was causing a compiler error when using AppleClang. Added header include that shouldn't need to be included . The standard says that including it does nothing but on Windows MSVC when using the header as a standalone file it gave me an issue. --- .gitignore | 5 +++++ CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ include/qoixx.hpp | 1 + src/qoiconv.cpp | 8 ++++---- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9ff802 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# cmake build +/build/* + +# clangd +/.cache/* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..d85811d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.14) +project(qoixx LANGUAGES CXX) + +option(QOIXX_USE_TABLES "If qoixx should store tables." ON) +option(QOIXX_BUILD_TESTS "Will build qoixx tests." ON) + +add_library(qoixx INTERFACE) +add_library(qoixx::qoixx ALIAS qoixx) +target_include_directories(qoixx INTERFACE $) +target_compile_definitions(qoixx INTERFACE QOIXX_DECODE_WITH_TABLES=${QOIXX_USE_TABLES}) +set_target_properties(qoixx PROPERTIES CXX_STANDARD 20) + +if (QOIXX_BUILD_TESTS) + set(STB ".dependencies/stb") + set(QOI ".dependencies/qoi") + set(DOCTEST ".dependencies/doctest/doctest") + + add_executable(qoibench "src/qoibench.cpp") + target_link_libraries(qoibench qoixx::qoixx) + target_include_directories(qoibench PUBLIC ${STB} ${QOI}) + set_target_properties(qoibench PROPERTIES CXX_STANDARD 20) + + add_executable(qoiconv "src/qoiconv.cpp") + target_link_libraries(qoiconv qoixx::qoixx) + target_include_directories(qoiconv PUBLIC ${STB} ${QOI}) + set_target_properties(qoiconv PROPERTIES CXX_STANDARD 20) + + add_executable(qoitest "src/test.cpp") + target_link_libraries(qoitest qoixx::qoixx) + target_include_directories(qoitest PUBLIC ${DOCTEST}) + set_target_properties(qoitest PROPERTIES CXX_STANDARD 20) +endif() \ No newline at end of file diff --git a/include/qoixx.hpp b/include/qoixx.hpp index ea24d3e..a0e47db 100644 --- a/include/qoixx.hpp +++ b/include/qoixx.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/src/qoiconv.cpp b/src/qoiconv.cpp index 3f7819c..c202954 100644 --- a/src/qoiconv.cpp +++ b/src/qoiconv.cpp @@ -82,7 +82,7 @@ struct overloaded : Fs...{ template overloaded(Fs...) -> overloaded; static inline void write_png(const std::filesystem::path& file_path, const image& image){ - auto [ptr, w, h, c] = std::visit(overloaded( + auto [ptr, w, h, c] = std::visit(overloaded{ [](const stbi_png& image){ return std::make_tuple(reinterpret_cast(image.pixels.get()), image.width, image.height, image.channels); }, @@ -94,13 +94,13 @@ static inline void write_png(const std::filesystem::path& file_path, const image static_cast(image.second.channels) ); } - ), image); + }, image); if(!::stbi_write_png(file_path.string().c_str(), w, h, c, ptr, 0)) throw std::runtime_error("write_png: Couldn't write/encode " + file_path.string()); } static inline void write_qoi(const std::filesystem::path& file_path, const image& image){ - auto [ptr, size, desc] = std::visit(overloaded( + auto [ptr, size, desc] = std::visit(overloaded{ [](const stbi_png& image){ return std::make_tuple( reinterpret_cast(image.pixels.get()), @@ -116,7 +116,7 @@ static inline void write_qoi(const std::filesystem::path& file_path, const image [](const std::pair, qoixx::qoi::desc>& image){ return std::make_tuple(image.first.data(), image.first.size(), image.second); } - ), image); + }, image); const auto encoded = qoixx::qoi::encode>(ptr, size, desc); save_file(file_path, encoded); } From 36966ff3e0078cc33eafd3cff4b2721dcc9d9240 Mon Sep 17 00:00:00 2001 From: cullvox Date: Mon, 24 Jun 2024 13:10:33 -0400 Subject: [PATCH 2/5] Remove new header, I'll test on windows later. --- include/qoixx.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/qoixx.hpp b/include/qoixx.hpp index a0e47db..ea24d3e 100644 --- a/include/qoixx.hpp +++ b/include/qoixx.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include From 570ef6fbfb811114289c282fb176bdb06384bd2b Mon Sep 17 00:00:00 2001 From: cullvox Date: Mon, 24 Jun 2024 13:16:54 -0400 Subject: [PATCH 3/5] Make the cmake variable string more clear. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d85811d..a4faa3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.14) project(qoixx LANGUAGES CXX) -option(QOIXX_USE_TABLES "If qoixx should store tables." ON) -option(QOIXX_BUILD_TESTS "Will build qoixx tests." ON) +option(QOIXX_USE_TABLES "QOIXX will use precomputed tables to increase runtime preformance." ON) +option(QOIXX_BUILD_TESTS "QOIXX will build samples and tests." ON) add_library(qoixx INTERFACE) add_library(qoixx::qoixx ALIAS qoixx) From bce289d56236239b6bde6821ce678d7de2e3af07 Mon Sep 17 00:00:00 2001 From: Caden Miller Date: Tue, 16 Jul 2024 08:36:39 -0400 Subject: [PATCH 4/5] remove gitignore, add newline at eof --- .gitignore | 5 ----- CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a9ff802..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# cmake build -/build/* - -# clangd -/.cache/* diff --git a/CMakeLists.txt b/CMakeLists.txt index a4faa3b..aa2d232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,4 +29,4 @@ if (QOIXX_BUILD_TESTS) target_link_libraries(qoitest qoixx::qoixx) target_include_directories(qoitest PUBLIC ${DOCTEST}) set_target_properties(qoitest PROPERTIES CXX_STANDARD 20) -endif() \ No newline at end of file +endif() From 61972d94a51fabac0b8f234b144242a9b95e4324 Mon Sep 17 00:00:00 2001 From: Caden Miller Date: Tue, 24 Sep 2024 11:52:39 -0400 Subject: [PATCH 5/5] Working on adding installs. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa2d232..f7137f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,4 +29,7 @@ if (QOIXX_BUILD_TESTS) target_link_libraries(qoitest qoixx::qoixx) target_include_directories(qoitest PUBLIC ${DOCTEST}) set_target_properties(qoitest PROPERTIES CXX_STANDARD 20) + + install(TARGETS qoibench qoiconv + RUNTIME DESTINATION "${PROJECT_SOURCE_DIR}/bin") endif()