-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
94 lines (68 loc) · 1.96 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
set( CMAKE_VERSION 3.25)
cmake_minimum_required(VERSION ${CMAKE_VERSION})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(DEFINED ENV{PROJECT_NAME})
set(PROJECT_NAME $ENV{PROJECT_NAME})
else()
set(PROJECT_NAME "project-name")
endif()
set( PROJECT_VERSION 0.1 )
project(
${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 23)
if( NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
message(STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION}...\n")
## conan basic setup
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message( STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan...")
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Cmake-Conan downloaded succesfully.")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
# interface means a header only library
add_library( ${PROJECT_NAME}-lib INTERFACE )
# ADD INCLUDE FOLDERS
target_include_directories( ${PROJECT_NAME}-lib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include )
# set up doctest testing
find_package(doctest REQUIRED)
target_link_libraries(${PROJECT_NAME}-lib INTERFACE doctest::doctest)
# ADD EXECUTABLE
add_executable( ${PROJECT_NAME}
src/main.cpp
)
target_link_libraries( ${PROJECT_NAME} PRIVATE ${PROJECT_NAME}-lib )
set(GCC_WARNINGS
-Wall
-Wextra
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wpedantic
-Wconversion
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
#-fsanitize=undefined,thread
-fsanitize=undefined,address
#compile with gdb debug info
#-ggdb3
-g3
)
add_compile_options( ${GCC_WARNINGS} )
link_libraries("-fsanitize=address")
#link_libraries("-fsanitize=thread")
# catch2 set up
# option(BUILD_TESTS "Enables building the Catch2 unit tests" ON)
#if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
#endif()