-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
48 lines (35 loc) · 1.32 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
cmake_minimum_required(VERSION 3.10)
project(threadpool, VERSION 0.0.2 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
IF(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W4 /WX -Od ")
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -Wall -Wextra -pedantic -Werror")
ENDIF()
ELSEIF("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
IF(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -O2")
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g1")
ENDIF()
ELSE()
message("Undefined build type... The default 'CMAKE_CXX_FLAGS' will be used")
ENDIF()
########## UNIT TESTS #########################################################
# GoogleTest requires at least C++11
# set(CMAKE_CXX_STANDARD 11)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)
# 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()
add_executable(threadpool_tests threadpool_tests.cpp threadpool.hpp)
target_link_libraries(threadpool_tests gtest_main)
include(GoogleTest)
gtest_discover_tests(threadpool_tests)