-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
43 lines (34 loc) · 1.1 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
cmake_minimum_required(VERSION 3.14)
project(libft LANGUAGES C CXX)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
# Flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
file(GLOB SRC_FILES "src/*.c")
file(GLOB BONUS_SRC_FILES "src_bonus/*.c")
file(GLOB TEST_FILES "tests/*.cpp")
# Handle BUFFER_SIZE values
set(TEST_NAME "run_tests")
add_executable(${TEST_NAME} ${SRC_FILES} ${BONUS_SRC_FILES} ${TEST_FILES})
target_include_directories(${TEST_NAME} PRIVATE includes)
target_include_directories(${TEST_NAME} PRIVATE ${gtest_SOURCE_DIR}/googletest/include)
target_link_libraries(
${TEST_NAME}
# GTest::gtest
GTest::gtest_main
pthread
bsd
)
# Register the test with CTest
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})