Skip to content

Commit

Permalink
move conanfile and cmakefile to tests and example subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
hit9 committed May 19, 2024
1 parent 9fd3d8f commit e7d1b9f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
If:
PathMatch: blinker.h

CompileFlags:
Add: [-std=c++17]
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ jobs:
run: conan profile detect

- name: Install Requirements
working-directory: ./tests
run: >
conan install .
--output-folder=${{ runner.workspace }}/build
--output-folder=./build
--build=missing
-s build_type=Debug
- name: Configure CMake
working-directory: ${{runner.workspace}}
working-directory: ./tests
run: >
cmake -B ${{ runner.workspace }}/build -S ${{ github.workspace }}
cmake -B build -S .
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DBLINKER_TEST=1
- name: Build Tests
working-directory: ${{runner.workspace}}/build/tests
working-directory: ./tests/build
run: make

- name: Run Tests
working-directory: ${{runner.workspace}}/build
run: ctest --test-dir ./tests --output-on-failure
working-directory: ./tests/build
run: ctest --test-dir . --output-on-failure
13 changes: 4 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ cmake_minimum_required(VERSION 3.10)

project(blinker)

option(BLINKER_TEST "Enables testing" OFF)
set(CMAKE_CXX_STANDARD 17)

add_library(blinker INTERFACE)
set_target_properties(blinker PROPERTIES PUBLIC_HEADER "blinker.h")

if(BLINKER_TEST)
add_subdirectory(tests EXCLUDE_FROM_ALL)
add_subdirectory(example EXCLUDE_FROM_ALL)
endif()

install(
TARGETS blinker
LIBRARY DESTINATION ${CMAK_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
TARGETS blinker
LIBRARY DESTINATION ${CMAK_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
38 changes: 3 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
defalut: build

install-release:
conan install . --output-folder=build --build=missing -s build_type=Release

install-debug:
conan install . --output-folder=build --build=missing -s build_type=Debug

cmake-build-release:
cd build && cmake .. \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
cmake:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1

cmake-build-test:
cd build && cmake .. \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DBLINKER_TEST=1

build: cmake-build
cd build && make

build-example:
cd build/example && make

build-test:
cd build/tests && make

run-example: build-example
./build/example/blinker_example

run-tests: build-test
ctest --test-dir ./build/tests --output-on-failure

clean:
make -C build clean

lint:
cppcheck *.h --enable=warning,style,performance,portability --inline-suppr --language=c++

.PHONY: build build-test
.PHONY: build
17 changes: 17 additions & 0 deletions example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defalut: build

cmake:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1

build: cmake
cd build && make

run:
./build/blinker_example

clean:
make -C build clean

.PHONY: build
21 changes: 21 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defalut: build

install:
conan install . --output-folder=build --build=missing -s compiler.cppstd=20 -s build_type=Release

cmake:
cd build && cmake .. \
-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1

build: cmake
cd build && make

run:
ctest --test-dir ./build --output-on-failure

clean:
make -C build clean

.PHONY: build
File renamed without changes.

0 comments on commit e7d1b9f

Please sign in to comment.