This repository has been archived by the owner on Dec 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
58 lines (41 loc) · 1.75 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
cmake_minimum_required(VERSION 3.5.1)
set(PROJECT_NAME Grammar)
project(${PROJECT_NAME})
set(CMAKE_CXX_FLAGS "-g -Wall")
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include)
include_directories(${COMMON_INCLUDES})
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cxx)
file(GLOB TEST_SRC_FILES ${PROJECT_SOURCE_DIR}/test/*.cxx)
list(REMOVE_ITEM SRC_FILES ${PROJECT_SOURCE_DIR}/src/driver.cxx)
set(CMAKE_CXX_STANDARD 11)
add_library(Grammar_lib ${SRC_FILES})
add_executable(Grammar ${PROJECT_SOURCE_DIR}/src/driver.cxx)
target_link_libraries(Grammar Grammar_lib)
option(BUILD_TESTS "Build all tests." OFF)
if (BUILD_TESTS)
# This adds another subdirectory, which has 'project(gtest)'.
add_subdirectory(ext/gtest-1.8.0)
enable_testing()
# Include the gtest library. gtest_SOURCE_DIR is available due to
# 'project(gtest)' above.
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
##############
# Unit Tests
##############
add_executable(runUnitTests ${TEST_SRC_FILES})
# Standard linking to gtest stuff.
target_link_libraries(runUnitTests gtest gtest_main)
# Extra linking for the project.
target_link_libraries(runUnitTests Grammar_lib)
# This is so you can do 'make test' to see all your tests run, instead of
# manually running the executable runUnitTests to see those specific tests.
add_test(UnitTests runUnitTests)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.travis/cmake)
#if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
# include(CodeCoverage)
# setup_target_for_coverage(${PROJECT_NAME}_coverage runUnitTests coverage)
#
# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
#endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage"
endif()