Skip to content

Commit a3e0b6b

Browse files
authored
Merge pull request #2 from arbCoding/cmake
v0.2.0 to main
2 parents d2f860e + b3c91ed commit a3e0b6b

29 files changed

+4761
-2418
lines changed

.clangd

Lines changed: 0 additions & 2 deletions
This file was deleted.

.gitignore

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,35 @@
3434
# Mac stuff
3535
*.dSYM
3636
*.DS_Store
37+
.DS_Store
38+
39+
# langauge server
40+
.ccls-cache/*
3741

38-
# data files
39-
data/*
40-
# Compiled stuff
41-
bin/*
42-
# Be extra sure no objects
43-
./src/objects/*
4442
# Any compressed files
4543
*.tar.gz
46-
# Any csv files
47-
*.csv
48-
# Any sac files
49-
*.sac
50-
*.SAC
51-
# Dumb MacOS
52-
.DS_Store
44+
5345
# Static analysis stuff
5446
.cache
55-
compile_commands.json
47+
48+
# Made using `bear -- make`, meant to be used by CppCheck
49+
# Make sure to remove all lines for boost and msgpack
50+
# as they cause preprocessor directive errors for CppCheck
51+
# took a little while to figure that out
52+
compile_commands.json
53+
54+
# The build directory
55+
build/*
56+
# Cmake-Project prefers bin by default
57+
bin/*
58+
59+
# VS-Code junk
60+
.vscode/*
61+
62+
# LaTeX source
63+
*.tex
64+
65+
# Wrong pdf
66+
src/docs/*.pdf
67+
68+
.clangd

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#===============================================================================
2+
# Basic Setup
3+
#===============================================================================
4+
# CMake version
5+
cmake_minimum_required (VERSION 3.12)
6+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7+
# Build type
8+
set(CMAKE_BUILD_TYPE Release)
9+
if (NOT CMAKE_BUILD_TYPE)
10+
set(CMAKE_BUILD_TYPE Release)
11+
endif()
12+
#===============================================================================
13+
# Fetch
14+
#===============================================================================
15+
include(FetchContent)
16+
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
17+
# Unit testing
18+
FetchContent_Declare(Catch2
19+
GIT_REPOSITORY https://github.com/catchorg/Catch2
20+
GIT_TAG v3.4.0)
21+
# Random number generation
22+
FetchContent_Declare(xoshiro
23+
GIT_REPOSITORY https://github.com/Reputeless/Xoshiro-cpp
24+
GIT_TAG v1.1)
25+
FetchContent_MakeAvailable(Catch2 xoshiro)
26+
# Include Xoshiro since it doesn't have a CMakeLists.txt
27+
include_directories(${xoshiro_SOURCE_DIR})
28+
#===============================================================================
29+
# Flags
30+
#===============================================================================
31+
# Should set presets later on, but this is good enough for now
32+
set(CMAKE_CXX_FLAGS "-Wall -pedantic-errors")
33+
# Flags for debug
34+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -Wextra -Wshadow -Werror")
35+
# Flags for thread-sanitizer
36+
set(CMAKE_CXX_FLAGS_THREAD "-O0 -ggdb -Wextra -Wshadow -Werror -fsanitize=thread -pthread")
37+
# Flags for Address sanitizer
38+
set(CMAKE_CXX_FLAGS_ADDRESS "-O0 -ggdb -Wextra -Wshadow -Werror -fsanitize=address -fno-omit-frame-pointer")
39+
# Flags for Memory sanitizer
40+
#set(CMAKE_CXX_FLAGS_MEMORY "-O0 -ggdb -Wextra -Wshadow -Werror -fsanitize=memory -fPIE -pie -fno-omit-frame-pointer")
41+
# Flags for release
42+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
43+
#==============================================================================
44+
# sac-format
45+
#==============================================================================
46+
project(sac-format
47+
LANGUAGES CXX
48+
DESCRIPTION "C++20 Single-Header SAC File library"
49+
HOMEPAGE_URL https://arbCoding.github.io/sac-format
50+
VERSION 0.2.0)
51+
52+
include_directories(${sac-format_SOURCE_DIR}/src)
53+
54+
# Use C++20
55+
set(CMAKE_CXX_STANDARD 20)
56+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
57+
set(CMAKE_CXX_EXTENSIONS OFF)
58+
59+
add_library(sac-format STATIC
60+
src/sac_format.hpp
61+
src/sac_format.cpp)
62+
63+
set_target_properties(sac-format PROPERTIES VERSION ${PROJECT_VERSION})
64+
set_target_properties(sac-format PROPERTIES PUBLIC_HEADER src/sac_format.hpp)
65+
66+
#===============================================================================
67+
# Example programs
68+
#===============================================================================
69+
add_executable(list_sac
70+
src/sac_format.hpp
71+
src/examples/list_sac.cpp)
72+
73+
target_link_libraries(list_sac
74+
sac-format)
75+
#===============================================================================
76+
# Unit tests
77+
#===============================================================================
78+
# Catch2 stuff
79+
add_executable(utests
80+
src/sac_format.hpp
81+
src/util.hpp
82+
src/utests.cpp)
83+
84+
target_link_libraries(utests
85+
PRIVATE Catch2::Catch2WithMain
86+
sac-format)
87+
88+
add_executable(benchmark
89+
src/sac_format.hpp
90+
src/util.hpp
91+
src/benchmark.cpp)
92+
93+
target_link_libraries(benchmark
94+
PRIVATE Catch2::Catch2WithMain
95+
sac-format)
96+
97+
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
98+
include(CTest)
99+
include(Catch)
100+
catch_discover_tests(utests)

Makefile

Lines changed: 0 additions & 224 deletions
This file was deleted.

0 commit comments

Comments
 (0)