-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
65 lines (49 loc) · 1.37 KB
/
Copy pathCMakeLists.txt
File metadata and controls
65 lines (49 loc) · 1.37 KB
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
cmake_minimum_required(VERSION 3.14)
project(pmalloc)
# GoogleTest
set(CMAKE_CXX_STANDARD 14)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include_directories(
${CMAKE_BINARY_DIR}/src
${CMAKE_BINARY_DIR}/lib
)
# pmalloc
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
# Debug Mode
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
endif()
add_library(
pmalloc
src/pmalloc.c
)
add_executable(pmalloc_example_basic example/example_basic.c)
target_include_directories(pmalloc_example_basic PUBLIC src)
target_link_libraries(pmalloc_example_basic pmalloc)
add_executable(pmalloc_example_suballocation example/example_suballocation.c)
target_include_directories(pmalloc_example_suballocation PUBLIC src)
target_link_libraries(pmalloc_example_suballocation pmalloc)
enable_testing()
add_executable(
pmalloc_test
src/pmalloc_test.cc
)
target_link_libraries(
pmalloc_test
GTest::gtest_main
pmalloc
)
include(GoogleTest)
gtest_discover_tests(pmalloc_test)