From 119af7a20a7f7e1b6e8ffe894266180ab18ca845 Mon Sep 17 00:00:00 2001 From: Mineplay5780 Date: Fri, 28 Nov 2025 23:59:06 +0100 Subject: [PATCH] fix(build): fixed cmake file and added some files for testing it --- .gitignore | 2 +- CMakeLists.txt | 16 ++++++++-------- include/cosms-core/file.h | 7 +++++++ src/file.c | 11 +++++++++++ tests/main.c | 6 ++++++ 5 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 include/cosms-core/file.h create mode 100644 src/file.c create mode 100644 tests/main.c diff --git a/.gitignore b/.gitignore index 15d65d9..0ef0814 100644 --- a/.gitignore +++ b/.gitignore @@ -66,4 +66,4 @@ CTestTestfile.cmake _deps CMakeUserPresets.json -./build +build diff --git a/CMakeLists.txt b/CMakeLists.txt index 45587e5..83aacc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,17 @@ project(cosms-core C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) -include_directories(${PROJECT_SOURCE_DIR}/include) file(GLOB_RECURSE SRC_FILES "${PROJECT_SOURCE_DIR}/src/*.c") - add_library(cosms-core STATIC ${SRC_FILES}) +target_include_directories(cosms-core PUBLIC ${PROJECT_SOURCE_DIR}/include) + +if (MSVC) + target_compile_options(cosms-core PRIVATE /W4) +else() + target_compile_options(cosms-core PRIVATE -wall -Wextra -pedantic) +endif() + add_executable(cosms-core-test ${PROJECT_SOURCE_DIR}/tests/main.c) target_include_directories(cosms-core-test PRIVATE ${PROJECT_SOURCE_DIR}/tests) target_link_libraries(cosms-core-test cosms-core) - -if (MSVC) - target_compile_options(cosms-core PRIVATE /W4 /Zl) -else() - target_compile_options(cosms-core PRIVATE -wall -Wextra -pedantic) -endif() diff --git a/include/cosms-core/file.h b/include/cosms-core/file.h new file mode 100644 index 0000000..d29be8b --- /dev/null +++ b/include/cosms-core/file.h @@ -0,0 +1,7 @@ +#ifndef COSMS_CORE_FILE +#define COSMS_CORE_FILE + +void cosms_core_file_read(char *path); +void cosms_core_file_write(char *path); + +#endif diff --git a/src/file.c b/src/file.c new file mode 100644 index 0000000..fedd69d --- /dev/null +++ b/src/file.c @@ -0,0 +1,11 @@ +#include "../include/cosms-core/file.h" + +#include + +void cosms_core_file_read(char *path) { + printf("Hello, World!"); +} + +void cosms_core_file_write(char *path) { + printf("Hello, World"); +} diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..e6e6793 --- /dev/null +++ b/tests/main.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + cosms_core_file_read("test.txt"); + return 0; +}