Skip to content

Commit

Permalink
Merge pull request #37 from R3mmurd/v2.0.0
Browse files Browse the repository at this point in the history
V2.0.0
  • Loading branch information
R3mmurd authored Dec 9, 2023
2 parents 42d323e + 51d20d8 commit 367e6d1
Show file tree
Hide file tree
Showing 153 changed files with 17,068 additions and 17,101 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build_library.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: C/C++ CI

on: [push, pull_request]

jobs:
build_with_clang:
name: Build with Clang
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Cmake
run:
mkdir build && cd build && cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang ../
- name: Build Library
run: cd build && make all
- name: Run tests
run: cd build && make test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.vscode
.vs
doc
doxyfile
build/
*~
samples/bin/*
tests/bin/*
bin/*
include/*~
lib/*.a
Expand Down
72 changes: 72 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
cmake_minimum_required(VERSION 3.20)
project(Designar VERSION 2.0.0)

# Set C++ Required version
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED true)

# Use -std=c++XX instead of -std=gnu++XX
set(CMAKE_CXX_EXTENSIONS OFF)

# Append macro directory to CMake Path
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake/macros")

# Import cmake options
include(CTest)
include(ConfigureBaseTargets)
include(CheckPlatform)

# Designar Library
file(GLOB DESIGNAR_SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp")
add_library(Designar STATIC ${DESIGNAR_SOURCES})
target_include_directories(Designar PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_link_libraries(Designar
PUBLIC
designar-warning-interface
designar-compile-option-interface
)
install(
TARGETS Designar
DESTINATION ${PROJECT_SOURCE_DIR}/lib
)

find_package(Threads REQUIRED)

# Designar Samples
file(GLOB DESIGNAR_SAMPLES_SOURCES "${PROJECT_SOURCE_DIR}/samples/src/*.cpp")
foreach(samplefile ${DESIGNAR_SAMPLES_SOURCES})
get_filename_component(samplename ${samplefile} NAME_WE)
add_executable(${samplename} ${samplefile})
target_link_libraries(${samplename}
PUBLIC
Designar
Threads::Threads
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${samplename}
DESTINATION ${PROJECT_SOURCE_DIR}/samples/bin
)
endforeach(samplefile ${DESIGNAR_SAMPLES_SOURCES})

# Designar Tests
file(GLOB DESIGNAR_TESTS_SOURCES "${PROJECT_SOURCE_DIR}/tests/src/*.cpp")
foreach(testfile ${DESIGNAR_TESTS_SOURCES})
get_filename_component(testname ${testfile} NAME_WE)
add_executable(${testname} ${testfile})
target_link_libraries(${testname}
PUBLIC
Designar
Threads::Threads
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${testname}
DESTINATION ${PROJECT_SOURCE_DIR}/tests/bin
)
add_test(
NAME
${testname}
COMMAND
${testname}
)
endforeach(testfile ${DESIGNAR_TESTS_SOURCES})
57 changes: 0 additions & 57 deletions Makefile

This file was deleted.

29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ The structure of this library is:

## Getting started

- Build the static library
- Requirements
- cmake

```shell
$ make library
```

- Compile samples
- Compiling and installing the library

```shell
$ make samples
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install
```

- Compile tests

- Running tests
```shell
$ make tests
$ make test
```

- Compile all of the above

```shell
$ make all
```
After this, the static library `libDesignar.a` is located in the directory `lib`,
the executable samples are located in the directory `samples/bin`, and the
executable tests are located in the directory `tests/bin`.
22 changes: 22 additions & 0 deletions cmake/compiler/clang/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(CLANG_EXPECTED_VERSION 14.0.0)

if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION)
message(FATAL_ERROR "Clang: Designar requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}")
else()
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
endif()

# Clang Warning Options
target_compile_options(designar-warning-interface
INTERFACE
-Wall
-Wextra
-Wcast-align
-Wno-sign-compare
-Wno-write-strings
-Wno-parentheses
-Wfloat-equal
-pedantic
)

message(STATUS "Clang: All warnings enabled")
Empty file.
10 changes: 10 additions & 0 deletions cmake/compiler/msvc/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Warning interface in Visual Studio
target_compile_options(designar-warning-interface
INTERFACE
/W3)

# disable permissive mode to make msvc more eager to reject code that other compilers don't already accept
target_compile_options(designar-compile-option-interface
INTERFACE
/permissive-)
14 changes: 14 additions & 0 deletions cmake/macros/CheckPlatform.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# check what platform we're on (64-bit or 32-bit), and create a simpler test than CMAKE_SIZEOF_VOID_P
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PLATFORM 64)
MESSAGE(STATUS "Detected 64-bit platform")
else()
set(PLATFORM 32)
MESSAGE(STATUS "Detected 32-bit platform")
endif()

if(WIN32)
include("${CMAKE_SOURCE_DIR}/cmake/platform/windows/settings.cmake")
elseif(UNIX)
include("${CMAKE_SOURCE_DIR}/cmake/platform/unix/settings.cmake")
endif()
6 changes: 6 additions & 0 deletions cmake/macros/ConfigureBaseTargets.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# An interface library to make the warnings level available to other targets
# This interface taget is set-up through the platform specific script
add_library(designar-warning-interface INTERFACE)

# An interface library to make the target com available to other targets
add_library(designar-compile-option-interface INTERFACE)
6 changes: 6 additions & 0 deletions cmake/platform/unix/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")
if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake)
elseif(CMAKE_C_COMPILER MATCHES "clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
endif()
3 changes: 3 additions & 0 deletions cmake/platform/windows/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
endif()
Loading

0 comments on commit 367e6d1

Please sign in to comment.