@@ -74,19 +74,74 @@ endif()
74
74
if (CUKE_USE_STATIC_BOOST)
75
75
set (Boost_USE_STATIC_LIBS ON )
76
76
find_package (Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_CORE_BOOST_LIBS} REQUIRED)
77
-
78
- if (NOT MSVC )
79
- find_package (Threads)
80
- set (CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
81
- endif ()
82
77
else ()
83
78
set (CMAKE_CXX_FLAGS "-DBOOST_ALL_DYN_LINK ${CMAKE_CXX_FLAGS} " )
84
79
set (Boost_USE_STATIC_LIBS OFF )
85
80
find_package (Boost ${BOOST_MIN_VERSION} COMPONENTS ${CUKE_CORE_BOOST_LIBS} REQUIRED)
86
81
endif ()
87
82
88
- include_directories (${Boost_INCLUDE_DIRS} )
89
- set (CUKE_EXTRA_LIBRARIES ${CUKE_EXTRA_LIBRARIES} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} )
83
+ # Create import targets for CMake versions older than 3.5 (actually older FindBoost.cmake)
84
+ if (Boost_USE_STATIC_LIBS)
85
+ set (LIBRARY_TYPE STATIC )
86
+ else ()
87
+ # Just because we don't ask for static doesn't mean we're not getting static
88
+ set (LIBRARY_TYPE UNKNOWN)
89
+ endif ()
90
+ if (Boost_INCLUDE_DIRS AND NOT TARGET Boost::boost)
91
+ add_library (Boost::boost INTERFACE IMPORTED )
92
+ set_target_properties (Boost::boost PROPERTIES
93
+ "INTERFACE_INCLUDE_DIRECTORIES" "${Boost_INCLUDE_DIRS} " )
94
+ endif ()
95
+ if (Boost_THREAD_LIBRARY AND NOT TARGET Boost::thread)
96
+ find_package (Threads REQUIRED)
97
+ add_library (Boost::thread ${LIBRARY_TYPE} IMPORTED )
98
+ set_target_properties (Boost::thread PROPERTIES
99
+ "IMPORTED_LOCATION" "${Boost_THREAD_LIBRARY} "
100
+ "INTERFACE_LINK_LIBRARIES" "Threads::Threads;Boost::boost"
101
+ )
102
+ endif ()
103
+ if (Boost_SYSTEM_LIBRARY AND NOT TARGET Boost::system )
104
+ add_library (Boost::system ${LIBRARY_TYPE} IMPORTED )
105
+ set_target_properties (Boost::system PROPERTIES
106
+ "IMPORTED_LOCATION" "${Boost_SYSTEM_LIBRARY} "
107
+ "INTERFACE_LINK_LIBRARIES" "Boost::boost"
108
+ )
109
+ endif ()
110
+ if (Boost_FILESYSTEM_LIBRARY AND NOT TARGET Boost::filesystem)
111
+ add_library (Boost::filesystem ${LIBRARY_TYPE} IMPORTED )
112
+ set_target_properties (Boost::filesystem PROPERTIES
113
+ "IMPORTED_LOCATION" "${Boost_FILESYSTEM_LIBRARY} "
114
+ "INTERFACE_LINK_LIBRARIES" "Boost::system;Boost::boost"
115
+ )
116
+ endif ()
117
+ if (Boost_REGEX_LIBRARY AND NOT TARGET Boost::regex )
118
+ add_library (Boost::regex ${LIBRARY_TYPE} IMPORTED )
119
+ set_target_properties (Boost::regex PROPERTIES
120
+ "IMPORTED_LOCATION" "${Boost_REGEX_LIBRARY} "
121
+ "INTERFACE_LINK_LIBRARIES" "Boost::boost"
122
+ )
123
+ endif ()
124
+ if (Boost_DATE_TIME_LIBRARY AND NOT TARGET Boost::date_time)
125
+ add_library (Boost::date_time ${LIBRARY_TYPE} IMPORTED )
126
+ set_target_properties (Boost::date_time PROPERTIES
127
+ "IMPORTED_LOCATION" "${Boost_DATE_TIME_LIBRARY} "
128
+ "INTERFACE_LINK_LIBRARIES" "Boost::boost"
129
+ )
130
+ endif ()
131
+ if (Boost_PROGRAM_OPTIONS_LIBRARY AND NOT TARGET Boost::program_options)
132
+ add_library (Boost::program_options ${LIBRARY_TYPE} IMPORTED )
133
+ set_target_properties (Boost::program_options PROPERTIES
134
+ "IMPORTED_LOCATION" "${Boost_PROGRAM_OPTIONS_LIBRARY} "
135
+ "INTERFACE_LINK_LIBRARIES" "Boost::boost"
136
+ )
137
+ endif ()
138
+ if (Boost_UNIT_TEST_FRAMEWORK_LIBRARY AND NOT TARGET Boost::unit_test_framework)
139
+ add_library (Boost::unit_test_framework ${LIBRARY_TYPE} IMPORTED )
140
+ set_target_properties (Boost::unit_test_framework PROPERTIES
141
+ "IMPORTED_LOCATION" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} "
142
+ "INTERFACE_LINK_LIBRARIES" "Boost::boost"
143
+ )
144
+ endif ()
90
145
91
146
#
92
147
# GTest
@@ -106,20 +161,35 @@ endif()
106
161
107
162
if (NOT CUKE_DISABLE_QT)
108
163
find_package (Qt5Core)
164
+ find_package (Qt5Gui)
109
165
find_package (Qt5Widgets)
110
166
find_package (Qt5Test)
111
167
112
- if (${ Qt5Core_FOUND} AND ${ Qt5Widgets_FOUND} AND ${ Qt5Test_FOUND} )
168
+ if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND)
113
169
message (STATUS "Found Qt version: ${Qt5Core_VERSION_STRING} " )
114
- set (QT_LIBRARIES Qt5::Core Qt5::Widgets Qt5::Test )
115
- if (NOT Qt5Core_VERSION_STRING VERSION_LESS 5.7 AND (NOT DEFINED CMAKE_CXX_STANDARD OR NOT CMAKE_CXX_STANDARD STREQUAL 98))
170
+ if (NOT Qt5Core_VERSION_STRING VERSION_LESS 5.7 AND (NOT DEFINED CMAKE_CXX_STANDARD OR NOT CMAKE_CXX_STANDARD STREQUAL 98))
116
171
message (STATUS "C++11 is needed from Qt version 5.7.0, building with c++11 enabled" )
117
172
set (CMAKE_CXX_STANDARD 11)
118
173
endif ()
174
+ add_library (Qt::Core INTERFACE IMPORTED )
175
+ add_library (Qt::Gui INTERFACE IMPORTED )
176
+ add_library (Qt::Widgets INTERFACE IMPORTED )
177
+ add_library (Qt::Test INTERFACE IMPORTED )
178
+ set_target_properties (Qt::Core PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Core )
179
+ set_target_properties (Qt::Gui PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Gui )
180
+ set_target_properties (Qt::Widgets PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Widgets)
181
+ set_target_properties (Qt::Test PROPERTIES INTERFACE_LINK_LIBRARIES Qt5::Test )
119
182
else ()
120
183
find_package (Qt4 COMPONENTS QtCore QtGui QtTest)
121
184
if (QT4_FOUND)
122
- set (QT_LIBRARIES Qt4::QtCore Qt4::QtGui Qt4::QtTest)
185
+ add_library (Qt::Core INTERFACE IMPORTED )
186
+ add_library (Qt::Gui INTERFACE IMPORTED )
187
+ add_library (Qt::Widgets INTERFACE IMPORTED )
188
+ add_library (Qt::Test INTERFACE IMPORTED )
189
+ set_target_properties (Qt::Core PROPERTIES INTERFACE_LINK_LIBRARIES Qt4::QtCore)
190
+ set_target_properties (Qt::Gui PROPERTIES INTERFACE_LINK_LIBRARIES Qt4::QtGui )
191
+ set_target_properties (Qt::Widgets PROPERTIES INTERFACE_LINK_LIBRARIES Qt4::QtGui )
192
+ set_target_properties (Qt::Test PROPERTIES INTERFACE_LINK_LIBRARIES Qt4::QtTest)
123
193
include (${QT_USE_FILE} )
124
194
endif ()
125
195
endif ()
@@ -177,8 +247,6 @@ endif()
177
247
#
178
248
179
249
set (CUKE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /include )
180
- include_directories (${CUKE_INCLUDE_DIR} )
181
- set (CUKE_LIBRARIES cucumber-cpp ${CUKE_EXTRA_LIBRARIES} )
182
250
add_subdirectory (3rdparty/json_spirit)
183
251
add_subdirectory (src)
184
252
@@ -208,10 +276,10 @@ else()
208
276
add_executable (e2e-steps EXCLUDE_FROM_ALL ${CUKE_DYNAMIC_CPP_STEPS} )
209
277
# Mark this file as generated so it isn't required at CMake generation time (it is necessary when the target gets built though)
210
278
set_source_files_properties (${CUKE_DYNAMIC_CPP_STEPS} PROPERTIES GENERATED TRUE )
211
- target_link_libraries (e2e-steps PRIVATE ${CUKE_LIBRARIES} )
279
+ target_link_libraries (e2e-steps PRIVATE cucumber-cpp )
212
280
#Boost test lib required for boost specific scenario "Predicate Message"
213
- if (Boost_UNIT_TEST_FRAMEWORK_FOUND )
214
- target_link_libraries (e2e-steps PRIVATE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} )
281
+ if (TARGET Boost::unit_test_framework )
282
+ target_link_libraries (e2e-steps PRIVATE Boost::unit_test_framework )
215
283
else ()
216
284
set (CUKE_E2E_TAGS "--tags ~@boost" )
217
285
endif ()
@@ -242,7 +310,6 @@ else()
242
310
${CUKE_E2E_TAGS}
243
311
${ARGN}
244
312
${CUKE_FEATURES_DIR}
245
- DEPENDS cucumber-cpp
246
313
${USES_TERMINAL}
247
314
)
248
315
endfunction (add_feature_target)
0 commit comments