-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed several warnings in WINDOWS compilation and enabled testing in …
…windows
- Loading branch information
Bardo91
authored and
Bardo91
committed
Nov 4, 2019
1 parent
77f4687
commit f844c6f
Showing
8 changed files
with
133 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
# | ||
# | ||
# Downloads GTest and provides a helper macro to add tests. Add make check, as well, which | ||
# gives output on failed tests without having to set an environment variable. | ||
# | ||
# | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
|
||
if(CMAKE_VERSION VERSION_LESS 3.11) | ||
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1") | ||
|
||
include(DownloadProject) | ||
download_project(PROJ googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG release-1.8.0 | ||
UPDATE_DISCONNECTED 1 | ||
QUIET | ||
) | ||
|
||
# CMake warning suppression will not be needed in version 1.9 | ||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") | ||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_SOURCE_DIR} EXCLUDE_FROM_ALL) | ||
unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS) | ||
else() | ||
include(FetchContent) | ||
FetchContent_Declare(googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG release-1.8.0) | ||
FetchContent_GetProperties(googletest) | ||
if(NOT googletest_POPULATED) | ||
FetchContent_Populate(googletest) | ||
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE BOOL "") | ||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
unset(CMAKE_SUPPRESS_DEVELOPER_WARNINGS) | ||
endif() | ||
endif() | ||
|
||
|
||
if(CMAKE_CONFIGURATION_TYPES) | ||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} | ||
--force-new-ctest-process --output-on-failure | ||
--build-config "$<CONFIGURATION>") | ||
else() | ||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} | ||
--force-new-ctest-process --output-on-failure) | ||
endif() | ||
set_target_properties(check PROPERTIES FOLDER "Scripts") | ||
|
||
#include_directories(${gtest_SOURCE_DIR}/include) | ||
|
||
# More modern way to do the last line, less messy but needs newish CMake: | ||
# target_include_directories(gtest INTERFACE ${gtest_SOURCE_DIR}/include) | ||
|
||
|
||
if(GOOGLE_TEST_INDIVIDUAL) | ||
if(NOT CMAKE_VERSION VERSION_LESS 3.9) | ||
include(GoogleTest) | ||
else() | ||
set(GOOGLE_TEST_INDIVIDUAL OFF) | ||
endif() | ||
endif() | ||
|
||
# Target must already exist | ||
macro(add_gtest TESTNAME) | ||
target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main) | ||
|
||
if(GOOGLE_TEST_INDIVIDUAL) | ||
if(CMAKE_VERSION VERSION_LESS 3.10) | ||
gtest_add_tests(TARGET ${TESTNAME} | ||
TEST_PREFIX "${TESTNAME}." | ||
TEST_LIST TmpTestList) | ||
set_tests_properties(${TmpTestList} PROPERTIES FOLDER "Tests") | ||
else() | ||
gtest_discover_tests(${TESTNAME} | ||
TEST_PREFIX "${TESTNAME}." | ||
PROPERTIES FOLDER "Tests") | ||
endif() | ||
else() | ||
add_test(${TESTNAME} ${TESTNAME}) | ||
set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") | ||
endif() | ||
|
||
endmacro() | ||
|
||
mark_as_advanced( | ||
gmock_build_tests | ||
gtest_build_samples | ||
gtest_build_tests | ||
gtest_disable_pthreads | ||
gtest_force_shared_crt | ||
gtest_hide_internal_symbols | ||
BUILD_GMOCK | ||
BUILD_GTEST | ||
) | ||
|
||
set_target_properties(gtest gtest_main gmock gmock_main | ||
PROPERTIES FOLDER "Extern") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters