diff options
author | Lukas Rusak <lorusak@gmail.com> | 2020-03-12 13:30:51 -0700 |
---|---|---|
committer | Lukas Rusak <lorusak@gmail.com> | 2020-04-11 13:06:26 -0700 |
commit | 590641926816d194d16a6e1801d9b10e5e782e2c (patch) | |
tree | c070519e30751615adf4720bf80762d5ddf8b2fe /CMakeLists.txt | |
parent | 16d333916573d2dc5c4bb6a38b4888a3cfca79e6 (diff) |
gtest: remove lib/gtest and add as library
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f9022119f9..69d6c697df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ option(ENABLE_UPNP "Enable UPnP support?" ON) option(ENABLE_AIRTUNES "Enable AirTunes support?" ON) option(ENABLE_OPTICAL "Enable optical support?" ON) option(ENABLE_PYTHON "Enable python support?" ON) +option(ENABLE_TESTING "Enable testing support?" ON) # use ffmpeg from depends or system option(ENABLE_INTERNAL_FFMPEG "Enable internal ffmpeg?" OFF) if(UNIX) @@ -57,6 +58,7 @@ if(UNIX) option(ENABLE_INTERNAL_FSTRCMP "Enable internal fstrcmp?" OFF) option(ENABLE_INTERNAL_FLATBUFFERS "Enable internal flatbuffers?" OFF) option(ENABLE_INTERNAL_DAV1D "Enable internal dav1d?" OFF) + option(ENABLE_INTERNAL_GTEST "Enable internal gtest?" OFF) endif() # System options if(NOT WIN32) @@ -83,11 +85,11 @@ mark_as_advanced(LIBRARY_FILES) set(INCLUDES ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/lib - ${CMAKE_SOURCE_DIR}/lib/gtest/include ${CMAKE_SOURCE_DIR}/xbmc ${CMAKE_SOURCE_DIR}/xbmc/${PLATFORM_DIR} ${CMAKE_SOURCE_DIR}/xbmc/cores/VideoPlayer - ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}) + ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} + ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/include) if (NOT PLATFORMDEFS_DIR STREQUAL "") list(APPEND INCLUDES ${CMAKE_SOURCE_DIR}/xbmc/${PLATFORMDEFS_DIR}) @@ -254,9 +256,6 @@ mark_as_advanced(core_DEPENDS) mark_as_advanced(test_archives) mark_as_advanced(test_sources) -add_subdirectory(${CMAKE_SOURCE_DIR}/lib/gtest ${CORE_BUILD_DIR}/gtest EXCLUDE_FROM_ALL) -set_target_properties(gtest PROPERTIES FOLDER "External Projects") - # copy files to build tree copy_files_from_filelist_to_buildtree(${CMAKE_SOURCE_DIR}/cmake/installdata/common/*.txt ${CMAKE_SOURCE_DIR}/cmake/installdata/${CORE_SYSTEM_NAME}/*.txt) @@ -352,16 +351,23 @@ else() endif() # testing -copy_files_from_filelist_to_buildtree(${CMAKE_SOURCE_DIR}/cmake/installdata/test-reference-data.txt NO_INSTALL) -add_executable(${APP_NAME_LC}-test EXCLUDE_FROM_ALL ${CMAKE_SOURCE_DIR}/xbmc/test/xbmc-test.cpp ${test_sources}) -set_target_properties(${APP_NAME_LC}-test PROPERTIES ENABLE_EXPORTS ON) -whole_archive(_TEST_LIBRARIES ${core_DEPENDS} gtest) -target_link_libraries(${APP_NAME_LC}-test PRIVATE ${SYSTEM_LDFLAGS} ${_TEST_LIBRARIES} lib${APP_NAME_LC} ${DEPLIBS} ${CMAKE_DL_LIBS}) -unset(_TEST_LIBRARIES) -add_dependencies(${APP_NAME_LC}-test ${APP_NAME_LC}-libraries export-files) - -# Enable unit-test related targets -if(CORE_HOST_IS_TARGET) +if(CORE_HOST_IS_TARGET AND ENABLE_TESTING) + find_package(Gtest) + + copy_files_from_filelist_to_buildtree(${CMAKE_SOURCE_DIR}/cmake/installdata/test-reference-data.txt NO_INSTALL) + add_executable(${APP_NAME_LC}-test EXCLUDE_FROM_ALL ${CMAKE_SOURCE_DIR}/xbmc/test/xbmc-test.cpp ${test_sources}) + + set_target_properties(PROPERTIES ENABLE_EXPORTS ON) + + whole_archive(_TEST_LIBRARIES ${core_DEPENDS} ${GTEST_LIBRARY}) + target_link_libraries(${APP_NAME_LC}-test PRIVATE ${SYSTEM_LDFLAGS} ${_TEST_LIBRARIES} lib${APP_NAME_LC} ${DEPLIBS} ${CMAKE_DL_LIBS}) + unset(_TEST_LIBRARIES) + + if (ENABLE_INTERNAL_GTEST) + add_dependencies(${APP_NAME_LC}-test ${APP_NAME_LC}-libraries export-files gtest) + endif() + + # Enable unit-test related targets enable_testing() gtest_add_tests(${APP_NAME_LC}-test "" ${test_sources}) if(NOT WIN32) |