forked from dtrugman/pfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
48 lines (37 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
cmake_minimum_required (VERSION 3.5)
project(pfs)
option(BUILD_SHARED_LIBS "Build shared library (.so) instead of static one (.a)" ON)
option(ADDRESS_SANITIZER "Enable address sanitizer" OFF)
option(BUILD_SAMPLES "Build samples" ON)
option(BUILD_TESTS "Build tests" ON)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Debug)
endif ()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
add_compile_options (-std=c++11 -Wall -Wextra -pedantic -Werror)
include_directories (include)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (ROOT_SOURCE_DIR src)
aux_source_directory (${ROOT_SOURCE_DIR} ROOT_SOURCES)
aux_source_directory (${ROOT_SOURCE_DIR}/parsers PARSERS_SOURCES)
set (SOURCES ${ROOT_SOURCES} ${PARSERS_SOURCES})
add_library (pfs ${SOURCES})
if (ADDRESS_SANITIZER MATCHES ON)
message (STATUS "Enabling address sanitizer")
set (SANITIZE_FLAGS -fno-omit-frame-pointer -fsanitize=address -fsanitize=leak)
target_compile_options (pfs PUBLIC ${SANITIZE_FLAGS})
target_link_libraries (pfs PUBLIC -lasan ${SANITIZE_FLAGS})
endif ()
if (BUILD_SAMPLES)
aux_source_directory (sample SAMPLE_SOURCES)
add_executable (sample ${SAMPLE_SOURCES})
target_link_libraries (sample PRIVATE pfs)
endif()
if (BUILD_TESTS)
set (UNITTEST_SOURCE_DIR test)
aux_source_directory (${UNITTEST_SOURCE_DIR} UNITTEST_SOURCES)
add_executable (unittest ${UNITTEST_SOURCES})
target_link_libraries (unittest PRIVATE pfs)
endif()