diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..10474a6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +# [submodule "external/Unity"] +# path = external/Unity +# url = https://github.com/ThrowTheSwitch/Unity.git +[submodule "external/cmocka"] + path = external/cmocka + url = https://git.cryptomilk.org/projects/cmocka.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 987d5c6..5e8207b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,16 @@ add_subdirectory(src/core) add_subdirectory(src) +# Testing +include(CTest) +include(cmake/OptionsCMocka.cmake) +add_subdirectory(external/cmocka) +add_subdirectory(test) + +install( + TARGETS zbbs-server +) + install( TARGETS zbbs-client-tui ) \ No newline at end of file diff --git a/cmake/OptionsCMocka.cmake b/cmake/OptionsCMocka.cmake new file mode 100644 index 0000000..fc1260c --- /dev/null +++ b/cmake/OptionsCMocka.cmake @@ -0,0 +1,7 @@ +# Disable things we don't need from CMocka +set(WITH_EXAMPLES OFF CACHE BOOL "Build examples" FORCE) +set(UNIT_TESTING OFF CACHE BOOL "Build CMocka's own tests" FORCE) +set(WITH_CMOCKERY_SUPPORT OFF CACHE BOOL "" FORCE) + +# Force static library (easier for most projects) +set(WITH_STATIC_LIB ON CACHE BOOL "Build static library" FORCE) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 7e52439..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project("My Awesome Tested Project" C) -cmake_minimum_required(VERSION 3.0) # Let's tell it a bit about our environment -SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) # We declare a variable to select what to build -set (TARGET_GROUP production CACHE STRING "What Should I Build?") # Modules that exist in both our release and our unit tests, are added now -add_subdirectory(src) if(TARGET_GROUP STREQUAL release) # If we had any files that ONLY were compiled into our release, for example startup code, -# it's really handy to put it here. -elseif(TARGET_GROUP STREQUAL test) # Our tests need to let CTest know we're running tests -include(CTest) # It also needs to understand we have code in source and test directories -add_subdirectory(unity) -add_subdirectory(test) -else() -message(FATAL_ERROR "I don't know the TARGET_GROUP you gave me!") -endif() \ No newline at end of file