diff --git a/CMakeLists.txt b/CMakeLists.txt index 48f552b..e7d4563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -ftrapv \ -fsanitize=undefined -g -Og -fno-omit-frame-pointer") +include_directories(${PROJECT_SOURCE_DIR}/src) Include_directories(${PROJECT_BINARY_DIR}) include_directories(${CURLPP_INCLUDE_DIRS}) @@ -53,5 +54,8 @@ if (WITH_MAN) endif() if(WITH_TESTS) + add_library(${PROJECT_NAME}_testlib SHARED ${sources}) + target_link_libraries(${PROJECT_NAME}_testlib + ${CURLPP_LIBRARIES} ${JSONCPP_LIBRARIES}) include(tests.CMakeLists.txt) endif() diff --git a/src/gitea2rss.cpp b/src/gitea2rss.cpp new file mode 100644 index 0000000..2e77607 --- /dev/null +++ b/src/gitea2rss.cpp @@ -0,0 +1,19 @@ +/* This file is part of gitea2rss. + * Copyright © 2019 tastytea + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gitea2rss.hpp" + +bool cgi = false; diff --git a/src/main.cpp b/src/main.cpp index 18aa48e..d4209bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,8 +27,6 @@ using std::endl; using std::string; using std::chrono::system_clock; -bool cgi = false; - int main(int argc, char *argv[]) { const char *envquery = std::getenv("QUERY_STRING"); diff --git a/tests.CMakeLists.txt b/tests.CMakeLists.txt index ce26c37..164eb2d 100644 --- a/tests.CMakeLists.txt +++ b/tests.CMakeLists.txt @@ -1,12 +1,11 @@ include(CTest) file(GLOB sources_tests tests/test_*.cpp) -include_directories(${PROJECT_SOURCE_DIR}/src) find_package(Catch2) if(Catch2_FOUND) # Catch 2.x include(Catch) add_executable(all_tests tests/main.cpp ${sources_tests}) - target_link_libraries(all_tests Catch2::Catch2) + target_link_libraries(all_tests Catch2::Catch2 ${PROJECT_NAME}_testlib) target_include_directories(all_tests PRIVATE "/usr/include/catch2") catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}") else() # Catch 1.x @@ -15,6 +14,7 @@ else() # Catch 1.x foreach(src ${sources_tests}) get_filename_component(bin ${src} NAME_WE) add_executable(${bin} tests/main.cpp ${src}) + target_link_libraries(${bin} ${PROJECT_NAME}_testlib) add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}") endforeach() else() diff --git a/tests/main.cpp b/tests/main.cpp index 308997c..cf46664 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -17,5 +17,3 @@ #define CATCH_CONFIG_MAIN #include -#include "strings.cpp" -#include "time.cpp"