From 705807aca7999d690f34d8bde89131994649f257 Mon Sep 17 00:00:00 2001 From: craftablescience Date: Sat, 8 Nov 2025 18:27:04 -0800 Subject: [PATCH 1/2] Add JetBrains IDE project folder to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4638838..5d38083 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps +/.idea /.vs *.user /debug From 971b9728eda28a4b4e1029876bfcceb6d89a896a Mon Sep 17 00:00:00 2001 From: craftablescience Date: Sat, 8 Nov 2025 18:30:49 -0800 Subject: [PATCH 2/2] Create CMake library and install rules --- CMakeLists.txt | 49 ++++++++++++++++-- cmake/bcdecConfig.cmake.in | 4 ++ bcdec.h => include/bcdec.h | 0 stb_image_write.h => test/stb_image_write.h | 0 test.c => test/test.c | 0 test_bcdec.bat => test/test_bcdec.bat | 0 .../test_images}/dice_bc3.dds | Bin .../test_images}/dice_bc4.dds | Bin .../test_images}/dice_bc5.dds | Bin .../test_images}/dice_bc7.dds | Bin .../test_images}/kodim23_bc1.dds | Bin .../lythwood_room_1k_bc6h_signed.dds | Bin .../test_images}/testcard_bc2.dds | Bin 13 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 cmake/bcdecConfig.cmake.in rename bcdec.h => include/bcdec.h (100%) rename stb_image_write.h => test/stb_image_write.h (100%) rename test.c => test/test.c (100%) rename test_bcdec.bat => test/test_bcdec.bat (100%) rename {test_images => test/test_images}/dice_bc3.dds (100%) rename {test_images => test/test_images}/dice_bc4.dds (100%) rename {test_images => test/test_images}/dice_bc5.dds (100%) rename {test_images => test/test_images}/dice_bc7.dds (100%) rename {test_images => test/test_images}/kodim23_bc1.dds (100%) rename {test_images => test/test_images}/lythwood_room_1k_bc6h_signed.dds (100%) rename {test_images => test/test_images}/testcard_bc2.dds (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c876c..15308af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,50 @@ # CMakeList.txt : CMake project for bcdec, include source and define # project specific logic here. # -cmake_minimum_required (VERSION 3.8) +cmake_minimum_required (VERSION 3.21) -project ("bcdec" LANGUAGES C) +project (bcdec VERSION "0.97" LANGUAGES C) -# Add source to this project's executable. -add_executable (bcdec "bcdec.h" "test.c") -# TODO: Add tests and install targets if needed. +# Create library. +add_library (bcdec INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/bcdec.h") + +target_include_directories (bcdec INTERFACE + $ + $) + + +# Create test executable. +option (BCDEC_TEST "Create the bcdec test executable" ${PROJECT_IS_TOP_LEVEL}) +if (BCDEC_TEST) + add_executable (bcdec_test "${CMAKE_CURRENT_SOURCE_DIR}/test/test.c") + target_link_libraries (bcdec_test PRIVATE bcdec) +endif () + + +# Add install rules. +option (BCDEC_INSTALL "Create install rules for bcdec header" ${PROJECT_IS_TOP_LEVEL}) +if (BCDEC_INSTALL) + include (CMakePackageConfigHelpers) + write_basic_package_version_file ( + "${PROJECT_BINARY_DIR}/bcdecConfigVersion.cmake" + VERSION "${PROJECT_VERSION}" + COMPATIBILITY AnyNewerVersion + ) + + install (TARGETS bcdec + EXPORT bcdecTargets + PUBLIC_HEADER DESTINATION include COMPONENT Development) + + include (CMakePackageConfigHelpers) + configure_package_config_file ( + "${PROJECT_SOURCE_DIR}/cmake/bcdecConfig.cmake.in" + "${PROJECT_BINARY_DIR}/bcdecConfig.cmake" + INSTALL_DESTINATION lib/cmake/bcdec) + + install(EXPORT bcdecTargets DESTINATION lib/cmake/bcdec) + install(FILES "${PROJECT_BINARY_DIR}/bcdecConfigVersion.cmake" + "${PROJECT_BINARY_DIR}/bcdecConfig.cmake" + DESTINATION lib/cmake/bcdec) + install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) +endif () diff --git a/cmake/bcdecConfig.cmake.in b/cmake/bcdecConfig.cmake.in new file mode 100644 index 0000000..c3d939d --- /dev/null +++ b/cmake/bcdecConfig.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/bcdecTargets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/bcdec.h b/include/bcdec.h similarity index 100% rename from bcdec.h rename to include/bcdec.h diff --git a/stb_image_write.h b/test/stb_image_write.h similarity index 100% rename from stb_image_write.h rename to test/stb_image_write.h diff --git a/test.c b/test/test.c similarity index 100% rename from test.c rename to test/test.c diff --git a/test_bcdec.bat b/test/test_bcdec.bat similarity index 100% rename from test_bcdec.bat rename to test/test_bcdec.bat diff --git a/test_images/dice_bc3.dds b/test/test_images/dice_bc3.dds similarity index 100% rename from test_images/dice_bc3.dds rename to test/test_images/dice_bc3.dds diff --git a/test_images/dice_bc4.dds b/test/test_images/dice_bc4.dds similarity index 100% rename from test_images/dice_bc4.dds rename to test/test_images/dice_bc4.dds diff --git a/test_images/dice_bc5.dds b/test/test_images/dice_bc5.dds similarity index 100% rename from test_images/dice_bc5.dds rename to test/test_images/dice_bc5.dds diff --git a/test_images/dice_bc7.dds b/test/test_images/dice_bc7.dds similarity index 100% rename from test_images/dice_bc7.dds rename to test/test_images/dice_bc7.dds diff --git a/test_images/kodim23_bc1.dds b/test/test_images/kodim23_bc1.dds similarity index 100% rename from test_images/kodim23_bc1.dds rename to test/test_images/kodim23_bc1.dds diff --git a/test_images/lythwood_room_1k_bc6h_signed.dds b/test/test_images/lythwood_room_1k_bc6h_signed.dds similarity index 100% rename from test_images/lythwood_room_1k_bc6h_signed.dds rename to test/test_images/lythwood_room_1k_bc6h_signed.dds diff --git a/test_images/testcard_bc2.dds b/test/test_images/testcard_bc2.dds similarity index 100% rename from test_images/testcard_bc2.dds rename to test/test_images/testcard_bc2.dds