Skip to content

Commit

Permalink
ENH: test action
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunner246 committed May 30, 2024
1 parent 8f415f7 commit 8c984bf
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 128 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ jobs:
- name: Checkout code
uses: actions/[email protected]

- name: Set up cache
id: cache-cpm
uses: actions/cache@v2
with:
path: ~/cpm-cache
key: ${{ runner.os }}-cpm-${{ hashFiles('**/') }}
restore-keys: |
${{ runner.os }}-cpm-
- name: Configure CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCPM_SOURCE_CACHE=~/cpm-cache
- name: Build
run: |
cmake --build build --config Release
cmake --build build --config Release -- -j2
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
cmake_minimum_required(VERSION 3.28)
project(raptorxx)
project(raptorxx VERSION 0.0.1)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_CXX_STANDARD LESS 23)
message(FATAL_ERROR "At least C++23 required but have ${CMAKE_CXX_STANDARD}")
endif ()

if(MSVC)
add_compile_options(/W4 /WX /std:c++latest)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wall -Wextra -pedantic -Werror -std=c++23)
else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with MSVC, GCC and Clang.")
endif()

configure_file (
"${PROJECT_SOURCE_DIR}/ProjectConfig.h.in"
"${PROJECT_BINARY_DIR}/ProjectConfig.h"
)



add_subdirectory(logging)
add_subdirectory(gtfs)
Expand Down
3 changes: 3 additions & 0 deletions ProjectConfig.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
21 changes: 1 addition & 20 deletions gtfs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
cmake_minimum_required(VERSION 3.28)

project(gtfs
project(gtfs
DESCRIPTION "C++ implementation of GTFS reader"
)

if (MSVC)
add_compile_options(/W4 /WX)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -Wextra -pedantic -Werror)
else ()
# neither MSVC nor GCC is being used
# TODO add compiler specific options
message(STATUS "Using another compiler")
endif ()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "At least C++20 required but have ${CMAKE_CXX_STANDARD}")
endif ()

add_library(${PROJECT_NAME} SHARED
src/TestObject.cpp
src/TestObject.h
Expand Down
47 changes: 5 additions & 42 deletions gtfs/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
cmake_minimum_required(VERSION 3.28)

project(benchmarks)

if (MSVC)
add_compile_options(/W4 /WX)
elseif (GCC)
add_compile_options(-Wall -Wextra -pedantic -Werror)
else ()
# neither MSVC nor GCC is being used
# TODO add compiler specific options
message(using another compiler)
endif ()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "At least C++20 required but have ${CMAKE_CXX_STANDARD}")
endif ()

include(FetchContent)
FetchContent_Declare(
benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG main
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(benchmark_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(benchmark)
include_directories(${benchmark_SOURCE_DIR}/include ${benchmark_SOURCE_DIR})

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include(${CMAKE_SOURCE_DIR}/cmake/CPM.cmake)
CPMAddPackage("gh:google/googletest#main")
CPMAddPackage("gh:google/benchmark#main")

file(GLOB CHAPTER_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h")

Expand All @@ -49,7 +14,5 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/gtfs/src)
target_include_directories(${PROJECT_NAME} PRIVATE ${benchmark_SOURCE_DIR}/include ${benchmark_SOURCE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

target_link_libraries(${PROJECT_NAME}
benchmark::benchmark
gtfs
)
target_link_libraries(${PROJECT_NAME} benchmark::benchmark)
target_link_libraries(${PROJECT_NAME} gtfs)
28 changes: 3 additions & 25 deletions gtfs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,18 @@ project("test"
DESCRIPTION "C++ implementation of GTFS reader"
)

if (MSVC)
add_compile_options(/W4 /WX)
elseif (GCC)
add_compile_options(-Wall -Wextra -pedantic -Werror)
else ()
message(using another compiler)
endif ()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "At least C++20 required but have ${CMAKE_CXX_STANDARD}")
endif ()

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(${CMAKE_SOURCE_DIR}/cmake/CPM.cmake)
CPMAddPackage("gh:google/googletest#main")

add_executable(${PROJECT_NAME}
test_addition.cpp
)

target_include_directories(${PROJECT_NAME} PRIVATE ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/gtfs/src)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR})

target_link_libraries(${PROJECT_NAME} gtest gtest_main)

target_link_libraries(${PROJECT_NAME} gtfs)


6 changes: 4 additions & 2 deletions gtfs/test/test_addition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//


#include "gtest/gtest.h"
#include "TestObject.h"
#include <gtest/gtest.h>
#include <TestObject.h>
#include <ProjectConfig.h>

auto add(const int a, const int b) {
return a + b;
Expand All @@ -14,6 +15,7 @@ auto add(const int a, const int b) {
TEST(MathTest, Addition) {
TestObject lTest = TestObject();
lTest.testFunction();
std::cout << "v" << PROJECT_VERSION_MAJOR << "." << PROJECT_VERSION_MINOR << "." << PROJECT_VERSION_PATCH << std::endl;
EXPECT_EQ(add(5, 8), 13);
EXPECT_EQ(add(5, -8), -3);
}
Expand Down
20 changes: 2 additions & 18 deletions logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,13 @@ cmake_minimum_required(VERSION 3.28)

project("logging")

if (MSVC)
add_compile_options(/W3)
elseif (GCC)
add_compile_options(-Wall -Wextra -pedantic -Werror)
else ()
# neither MSVC nor GCC is being used
# TODO add compiler specific options
message(using another compiler)
endif ()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(${CMAKE_SOURCE_DIR}/cmake/CPM.cmake)
CPMAddPackage("gh:gabime/spdlog#v1.x")

if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "At least C++20 required but have ${CMAKE_CXX_STANDARD}")
endif ()

add_library(${PROJECT_NAME}
LoggingPool.cpp
LoggingPool.h
)

include(../cmake/CPM.cmake)
CPMAddPackage("gh:gabime/spdlog#v1.x")

target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog)
18 changes: 0 additions & 18 deletions raptor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ project("raptor"
DESCRIPTION "C++ implementation of raptor algorithm"
)


if (MSVC)
add_compile_options(/W4 /WX)
elseif (GCC)
add_compile_options(-Wall -Wextra -pedantic -Werror)
else ()
# neither MSVC nor GCC is being used
# TODO add compiler specific options
message(using another compiler)
endif ()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_CXX_STANDARD LESS 20)
message(FATAL_ERROR "At least C++20 required but have ${CMAKE_CXX_STANDARD}")
endif ()

include_directories(${CMAKE_SOURCE_DIR}/common/logging/include)

add_library(${PROJECT_NAME}
Expand Down

0 comments on commit 8c984bf

Please sign in to comment.