-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (55 loc) · 1.56 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
cmake_minimum_required(VERSION 3.14)
project(ccmlina)
# ---------------------#
# --- Compile Flags ---#
# ---------------------#
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
enable_language(C CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Wno-sign-compare -Wno-unused-parameter -fopenmp")
# Build-type specific flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
# Static libs
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
message(STATUS "Building with the following extra flags: ${CMAKE_CXX_FLAGS}")
# -------------#
# --- Files ---#
# -------------#
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB SOURCES "src/*.cpp*")
# ---------------#
# --- Library ---#
# ---------------#
add_library(${PROJECT_NAME} SHARED ${SOURCES})
# ---------------#
# --- Testing ---#
# ---------------#
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
file(GLOB TESTSOURCES "tests/*.cpp*")
add_executable(
mtest
${TESTSOURCES}
)
target_link_libraries(
mtest
GTest::gtest_main
${PROJECT_NAME}
)
include(GoogleTest)
gtest_discover_tests(mtest)