forked from cucumber/cucumber-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (81 loc) · 2.79 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 2.8)
project(Cucumber-Cpp)
set(CUKE_USE_STATIC_BOOST ${MSVC} CACHE BOOL "Statically link Boost (except boost::test)")
set(CUKE_DISABLE_BOOST_TEST OFF CACHE BOOL "Disable boost:test")
set(CUKE_DISABLE_CPPSPEC OFF CACHE BOOL "Disable CppSpec")
set(CUKE_DISABLE_GTEST OFF CACHE BOOL "Disable Google Test framework")
set(CUKE_ENABLE_EXAMPLES OFF CACHE BOOL "Enable the examples")
enable_testing()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
#
# Generic Compiler Flags
#
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Weffc++")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX") # exclude M$ min/max macros
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /analyze")
endif()
#
# Boost
#
set(CUKE_CORE_BOOST_LIBS thread system regex date_time)
if(NOT CUKE_DISABLE_BOOST_TEST)
set(CUKE_TEST_BOOST_LIBS unit_test_framework)
endif()
if(CUKE_USE_STATIC_BOOST)
set(CUKE_STATIC_BOOST_LIBS ${CUKE_CORE_BOOST_LIBS})
# "An external test runner utility is required to link with dynamic library" (Boost User's Guide)
set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_TEST_BOOST_LIBS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_TEST_DYN_LINK")
if(NOT MSVC)
find_package(Threads)
set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
else()
set(CUKE_DYNAMIC_BOOST_LIBS ${CUKE_CORE_BOOST_LIBS} ${CUKE_TEST_BOOST_LIBS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_ALL_DYN_LINK")
endif()
if(CUKE_STATIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS ${CUKE_STATIC_BOOST_LIBS})
endif()
if(CUKE_DYNAMIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost COMPONENTS ${CUKE_DYNAMIC_BOOST_LIBS})
endif()
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY})
endif()
#
# CppSpec
#
if(NOT CUKE_DISABLE_CPPSPEC)
find_package(CppSpec)
endif()
#
# GTest
#
if(NOT CUKE_DISABLE_GTEST)
find_package(GTest)
find_package(GMock)
if(GMOCK_FOUND AND GTEST_FOUND)
set(CUKE_TEST_LIBRARIES ${GTEST_LIBRARY} ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY})
if(UNIX)
find_package(Threads) # GTest needs this and it's a static library
set(CUKE_TEST_LIBRARIES ${CUKE_TEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
endif()
#
# Cucumber-Cpp
#
set(CUKE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CUKE_INCLUDE_DIRS})
set(CUKE_LIBRARIES cucumber-cpp ${CUKE_EXTRA_LIBRARIES})
add_subdirectory(src)
add_subdirectory(tests)
if(CUKE_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()