From 7d6f15b7e615106e5e258785e1152c7cd8eb44ef Mon Sep 17 00:00:00 2001 From: Leo Sulzbacher Date: Sun, 15 Mar 2026 00:27:54 +0100 Subject: [PATCH 1/3] build: add cmake install --- CMakeLists.txt | 50 ++++++++++++++++++------- Config.cmake.in | 5 +++ tests/CMakeLists.txt | 8 ++++ {libs => tests}/unity/CMakeLists.txt | 0 {libs => tests}/unity/unity.c | 0 {libs => tests}/unity/unity.h | 0 {libs => tests}/unity/unity_internals.h | 0 7 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 Config.cmake.in create mode 100644 tests/CMakeLists.txt rename {libs => tests}/unity/CMakeLists.txt (100%) rename {libs => tests}/unity/unity.c (100%) rename {libs => tests}/unity/unity.h (100%) rename {libs => tests}/unity/unity_internals.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f48ad..7de7efb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,18 @@ cmake_minimum_required(VERSION 3.10) project(curtle VERSION 0.1.1 LANGUAGES C) -add_library(curtle - src/vector.c -) +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +add_library(curtle STATIC src/vector.c) target_include_directories(curtle PUBLIC - $ - $ + $ + $ ) find_library(MATH_LIB m) @@ -18,17 +22,35 @@ endif () install(TARGETS curtle EXPORT curtleTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install(DIRECTORY include/ DESTINATION include) +install(FILES include/curtle/curtle.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -add_subdirectory(libs/unity) +install(EXPORT curtleTargets + FILE curtleTargets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/curtle +) + +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/curtleConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/curtleConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/curtle +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/curtleConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/curtleConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/curtle +) enable_testing() - -add_executable(test_vector tests/test_vector.c) -target_link_libraries(test_vector PRIVATE curtle Unity) - -add_test(NAME vector_test COMMAND test_vector) \ No newline at end of file +add_subdirectory(tests) \ No newline at end of file diff --git a/Config.cmake.in b/Config.cmake.in new file mode 100644 index 0000000..8d644fd --- /dev/null +++ b/Config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/curtleTargets.cmake") + +check_required_components(curtle) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..73d1caa --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.10) + +add_subdirectory(unity) + +add_executable(test_vector test_vector.c) +target_link_libraries(test_vector PRIVATE curtle Unity) + +add_test(NAME vector_test COMMAND test_vector) \ No newline at end of file diff --git a/libs/unity/CMakeLists.txt b/tests/unity/CMakeLists.txt similarity index 100% rename from libs/unity/CMakeLists.txt rename to tests/unity/CMakeLists.txt diff --git a/libs/unity/unity.c b/tests/unity/unity.c similarity index 100% rename from libs/unity/unity.c rename to tests/unity/unity.c diff --git a/libs/unity/unity.h b/tests/unity/unity.h similarity index 100% rename from libs/unity/unity.h rename to tests/unity/unity.h diff --git a/libs/unity/unity_internals.h b/tests/unity/unity_internals.h similarity index 100% rename from libs/unity/unity_internals.h rename to tests/unity/unity_internals.h -- 2.49.1 From b2910437a5ec3875449e9ce0d9f8dc4ef5286d54 Mon Sep 17 00:00:00 2001 From: Leo Sulzbacher Date: Sun, 15 Mar 2026 00:45:37 +0100 Subject: [PATCH 2/3] fix: expose all required headers --- CMakeLists.txt | 7 +++++-- src/vector.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7de7efb..9f9e9e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(curtle STATIC src/vector.c) target_include_directories(curtle PUBLIC - $ + $ $ ) @@ -28,7 +28,10 @@ install(TARGETS curtle INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install(FILES include/curtle/curtle.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) install(EXPORT curtleTargets FILE curtleTargets.cmake diff --git a/src/vector.c b/src/vector.c index dd8b221..7c2bf58 100644 --- a/src/vector.c +++ b/src/vector.c @@ -1,4 +1,4 @@ -#include "curtle/vector.h" +#include "curtle.h" #include struct vec2 vec2_add(const struct vec2 a, const struct vec2 b) -- 2.49.1 From bff1f24f0cf7245d096c7f8025860c9c2f4f2794 Mon Sep 17 00:00:00 2001 From: Leo Sulzbacher Date: Sun, 15 Mar 2026 00:48:44 +0100 Subject: [PATCH 3/3] fix: apply new fix path to src --- src/vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector.c b/src/vector.c index 7c2bf58..dd8b221 100644 --- a/src/vector.c +++ b/src/vector.c @@ -1,4 +1,4 @@ -#include "curtle.h" +#include "curtle/vector.h" #include struct vec2 vec2_add(const struct vec2 a, const struct vec2 b) -- 2.49.1