-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
68 lines (53 loc) · 1.31 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
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 2.8)
set(THIS_NAME ctstring)
project(${THIS_NAME})
enable_language(CXX)
include_directories(
${PROJECT_SOURCE_DIR}
)
# Library path
set(CMAKE_LDFLAGS
"${CMAKE_LDFLAGS} -L\".\" "
)
# Define the CXX sources
set ( CXX_SRCS
string.cpp
ut/ut_ctstring.cpp
)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14)
if (COMPILER_SUPPORTS_CXX14)
add_definitions(-std=c++14)
else ()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
endif ()
if(DEFINED ENV{BUILD_FLAGS})
set(BUILD_FLAGS "$ENV{BUILD_FLAGS}")
else ()
set(BUILD_FLAGS "-O3")
endif ()
#message(STATUS "Using ${BUILD_FLAGS}.")
add_compile_options(
-Werror
-Wall
# -Wextra
-Waddress
-Warray-bounds
# -Wconversion
-Winit-self
# -Wsuggest-attribute=const
-Wunreachable-code
-pedantic
-pedantic-errors
)
add_executable(ut_${THIS_NAME} ${CXX_SRCS})
set_target_properties(ut_${THIS_NAME} PROPERTIES COMPILE_FLAGS
${BUILD_FLAGS}
)
#set_source_files_properties(
# ${CXX_SRCS} PROPERTIES COMPILE_FLAGS
# " -O3 -std=c++14 -Wall -Werror")
enable_testing()
add_test(UT ut_${THIS_NAME})
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS ut_${THIS_NAME})