Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ on:
- synchronize

jobs:
# test:
# runs-on: ubuntu-latest
test:
runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4
steps:
- uses: actions/checkout@v4

# - name: Install dependencies
# run: sudo apt-get install -y build-essential gcc-multilib g++-multilib
- name: Install dependencies
run: sudo apt-get install -y build-essential gcc-multilib g++-multilib

# - name: Install gcovr
# run: pip install gcovr
- name: Install gcovr
run: pip install gcovr

# - name: Setup project
# run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug
- name: Setup project
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug

# - name: Build
# run: cmake --build ${BUILD_DIR}
- name: Build
run: cmake --build build

# # - name: Test
# # working-directory: build
# # run: ctest -V
- name: Test
working-directory: build
run: ctest -V

# - name: Test with Coverage
# working-directory: build
# run: cmake --build ${BUILD_DIR} --target os_test_coverage
# - name: Test with Coverage
# working-directory: build
# run: cmake --build ${BUILD_DIR} --target os_test_coverage

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
secrets: inherit

needs:
# - test
- test
- lint

permissions:
Expand Down
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"all"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
}
]
}
25 changes: 7 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Support folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Testing only available for top level projects. It calls enable_testing
# which must be in the main CMakeLists.
include(CTest)
if(WAVEFRONT_BUILD_TESTS)
# Testing only available for top level projects. It calls enable_testing
# which must be in the main CMakeLists.
include(CTest)
endif()

if(WAVEFRONT_BUILD_DOCS)
# Generate documentation using Doxygen
Expand All @@ -36,23 +38,10 @@ endif()
include(GNUInstallDirs)

# Create config.h with project version numbers
configure_File(cmake/config.h.in include/config.h)
configure_file(cmake/config.h.in include/config.h)
include_directories(PRIVATE ${CMAKE_BINARY_DIR}/include)

find_package(glm REQUIRED CONFIG)

if(WAVEFRONT_BUILD_TESTS)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()
add_subdirectory(external)

add_subdirectory(src)

Expand Down
32 changes: 14 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@

CC=/usr/bin/gcc
CXX=/usr/bin/g++
CONFIG=Debug
TARGET=all

all: config build
all: setup build

config:
cmake --no-warn-unused-cli \
-DCMAKE_BUILD_TYPE=${CONFIG} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE \
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-S${PWD} \
-B${PWD}/build \
-G Ninja
setup:
cmake -S . -B build -DCMAKE_BUILD_TYPE=${CONFIG}

build:
cmake --build ${PWD}/build --config ${CONFIG} --target ${TARGET}
cmake --build build --config ${CONFIG}

install:
cmake --install ${PWD}/build --config ${CONFIG}
cmake --install build --config ${CONFIG}

lint:
@find src include tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format --dry-run --Werror --sort-includes
@find src include tests -name '*.cpp' -or -name '*.hpp' | xargs clang-format --dry-run --Werror --sort-includes

format:
@find src include tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format -i --Werror --sort-includes
@find src include tests -name '*.cpp' -or -name '*.hpp' | xargs clang-format -i --Werror --sort-includes

.PHONY: config build install lint format
test: build
cd build && GTEST_COLOR=1 ctest --output-on-failure

test-ci: build
cd build && GTEST_COLOR=1 ctest -V

.PHONY: setup build install lint format test test-ci
5 changes: 5 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(${CMAKE_CURRENT_LIST_DIR}/glm.cmake)

if(WAVEFRONT_BUILD_TESTS)
include(${CMAKE_CURRENT_LIST_DIR}/gtest.cmake)
endif()
20 changes: 20 additions & 0 deletions external/glm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include(FetchContent)

FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.2
)

set(USE_SYSTEM_GLM ON)

FetchContent_MakeAvailable(glm)
install(
TARGETS glm
EXPORT ${PROJECT_NAME}Targets
)
install(
TARGETS glm-header-only
EXPORT ${PROJECT_NAME}Targets
)

14 changes: 14 additions & 0 deletions external/gtest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include(FetchContent)

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
)

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(googletest)
11 changes: 6 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
set(TARGET tests)

enable_testing()

set(TARGET tests)

add_executable(${TARGET}
parser_tests.cpp
)
target_link_libraries(${TARGET}
gtest_main
Wavefront
target_link_libraries(${TARGET} PRIVATE gtest gtest_main Wavefront)

add_test(
NAME ${TARGET}
COMMAND $<TARGET_FILE:${TARGET}>
)

include(GoogleTest)
Expand Down