Skip to content

Commit

Permalink
Work around gmock/gtest bug
Browse files Browse the repository at this point in the history
To work around bug:
google/googletest#930

Its not possible to link with gmock dynamically. Therefore we need separate kits for tests and building dlls.
  • Loading branch information
kohnech committed Mar 16, 2019
1 parent 1187e89 commit 47979d3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
23 changes: 19 additions & 4 deletions .vscode/cmake-kits.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[
{
"name": "Windows-VS2017-x64",
"name": "Windows-SharedLib-VS2017-x64",
"cmakeSettings": {
"ENABLE_TESTS": "OFF",
"BUILD_SHARED_LIBS": "YES"
"BUILD_SHARED_LIBS": "YES",
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": "TRUE"
},
"visualStudio": "VisualStudio.15.0",
"visualStudioArchitecture": "amd64",
Expand All @@ -13,10 +14,24 @@
}
},
{
"name": "Windows-VS2017-x86",
"name": "Windows-SharedLib-VS2017-x86",
"cmakeSettings": {
"ENABLE_TESTS": "OFF",
"BUILD_SHARED_LIBS": "YES"
"BUILD_SHARED_LIBS": "YES",
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": "TRUE"
},
"visualStudio": "VisualStudio.15.0",
"visualStudioArchitecture": "x86",
"preferredGenerator" : {
"name" : "Visual Studio 15 2017",
"platform": "x86"
}
},
{
"name": "Windows-StaticLib-VS2017-x86",
"cmakeSettings": {
"ENABLE_TESTS": "ON",
"BUILD_SHARED_LIBS": "NO"
},
"visualStudio": "VisualStudio.15.0",
"visualStudioArchitecture": "x86",
Expand Down
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ endif()
#-------------------
set(BENCHMARK_ENABLE_TESTING OFF)
option(ENABLE_TESTS "Build with tests" ON)
if(MSVC)
set(ENABLE_TESTS OFF)
endif()
option(ENABLE_COMPONENT_TESTS "Build with component tests" ON)

if(ENABLE_TESTS)
add_subdirectory(tests)
add_subdirectory(bench)
endif()

if(MSVC)
set(ENABLE_COMPONENT_TESTS OFF)
endif()
if(ENABLE_COMPONENT_TESTS)
add_subdirectory(component_tests)
endif()

Expand Down
11 changes: 7 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ endif(NOT USE_DOCKER)
#-------------------------------------------------------------
project(
run_gtests
VERSION 1.0.0
DESCRIPTION "GTests for ts-lib"
LANGUAGES CXX
VERSION 1.0.0
DESCRIPTION "GTests for ts-lib"
LANGUAGES CXX
)

enable_testing()
Expand All @@ -71,6 +71,8 @@ endif(USE_DOCKER)
# Now simply link against gtest, gmock, gtest_main or gmock_main as needed. Eg
add_executable(${PROJECT_NAME})

target_compile_definitions(${PROJECT_NAME} PRIVATE MPEG2TS_DLL_EXPORTS)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

target_sources(${PROJECT_NAME}
Expand All @@ -84,7 +86,8 @@ target_sources(${PROJECT_NAME}
TsParser_Tests.cc
TsStatistics_Tests.cc
TsUtilities_Tests.cc
H264Parser_Tests.cc)
H264Parser_Tests.cc
)

target_include_directories(${PROJECT_NAME} PRIVATE ../include)
target_include_directories(${PROJECT_NAME} PRIVATE ../src)
Expand Down

0 comments on commit 47979d3

Please sign in to comment.