diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e46243 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~* +*\#* +build +.cache diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9e8c22c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.29) + +project(skopy) + +set(CMAKE_INSTALL_PREFIX /usr) +set(CMAKE_EXPORT_COMPILE_COMMANDS On) + +add_subdirectory(tests) +add_subdirectory(lib) +add_subdirectory(cli) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ffefaa2 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: build tests install + +build: + cmake -B build + cmake --build build + +tests: build + build/tests/skopy-tests \ + && echo -e "\e[32m--- all tests passed ---\e[0m" \ + || echo -e "\e[31m--- some tests failed ---\e[0m" + +install: tests + sudo cmake --install build + +check: + @cppcheck --enable=all -q lib tests cli \ + --suppress=missingIncludeSystem diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt new file mode 100644 index 0000000..3e5ee4b --- /dev/null +++ b/cli/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.29) + +project(skopy-cli) + +add_executable(skopy + main.c +) + +set_property(TARGET skopy PROPERTY C_STANDARD 99) +add_dependencies(skopy skopy-lib) +install(TARGETS skopy) + +target_link_libraries(skopy + PUBLIC skopy-lib +) diff --git a/cli/main.c b/cli/main.c new file mode 100644 index 0000000..059c5a0 --- /dev/null +++ b/cli/main.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + printf("Hello World!\n"); + return 0; +} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..e1adc96 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.29) + +project(skopy-lib) + +add_library(skopy-lib SHARED + src/commons.c +) + +file(GLOB_RECURSE + includes + include/*.h +) + +install(TARGETS skopy-lib) + +install( + FILES ${includes} + DESTINATION "${CMAKE_INSTALL_PREFIX}/include/skopy" +) + +set_property(TARGET skopy-lib PROPERTY C_STANDARD 99) + +target_include_directories(skopy-lib + PUBLIC ${CMAKE_SOURCE_DIR}/lib/include +) + +target_compile_options(skopy-lib + PUBLIC -Wall -Wextra -g +) diff --git a/lib/include/commons.h b/lib/include/commons.h new file mode 100644 index 0000000..31a435e --- /dev/null +++ b/lib/include/commons.h @@ -0,0 +1,5 @@ +#ifndef SK_COMMONS_H +#define SK_COMMONS_H + + +#endif diff --git a/lib/src/commons.c b/lib/src/commons.c new file mode 100644 index 0000000..3d2400e --- /dev/null +++ b/lib/src/commons.c @@ -0,0 +1 @@ +#include "commons.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..d4f6ca3 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.29) + +project(skopy-tests) + +add_executable(skopy-tests + main.c +) + +set_property(TARGET skopy-tests PROPERTY C_STANDARD 99) +add_dependencies(skopy-tests skopy-lib) + +find_package(PkgConfig) +pkg_check_modules(CUNIT cunit REQUIRED IMPORTED_TARGET) + +target_link_libraries(skopy-tests + PUBLIC skopy-lib + PRIVATE PkgConfig::CUNIT +) diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..b8f0245 --- /dev/null +++ b/tests/main.c @@ -0,0 +1,24 @@ +#include +#include + +void test_trivial() +{ + CU_ASSERT(1 + 1 == 2); +} + +int main() +{ + CU_initialize_registry(); + + CU_pSuite suite = CU_add_suite("First suite", 0, 0); + CU_add_test(suite, "Trivial", test_trivial); + + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + + + int status = CU_get_number_of_failures(); + CU_cleanup_registry(); + + return status; +}