Add BARRIER_USE_EXTERNAL_GTEST CMake option to use external GTest
This commit is contained in:
parent
4a031b8ce5
commit
bd1db368b3
|
@ -21,6 +21,7 @@ project (barrier C CXX)
|
||||||
option (BARRIER_BUILD_GUI "Build the GUI" ON)
|
option (BARRIER_BUILD_GUI "Build the GUI" ON)
|
||||||
option (BARRIER_BUILD_INSTALLER "Build the installer" ON)
|
option (BARRIER_BUILD_INSTALLER "Build the installer" ON)
|
||||||
option (BARRIER_BUILD_TESTS "Build the tests" ON)
|
option (BARRIER_BUILD_TESTS "Build the tests" ON)
|
||||||
|
option (BARRIER_USE_EXTERNAL_GTEST "Use external installation of Google Test framework" OFF)
|
||||||
|
|
||||||
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set (CMAKE_CXX_STANDARD 14)
|
set (CMAKE_CXX_STANDARD 14)
|
||||||
|
|
|
@ -14,19 +14,33 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
include_directories(
|
if (BARRIER_USE_EXTERNAL_GTEST)
|
||||||
../../ext/gtest
|
include (FindPkgConfig)
|
||||||
../../ext/gtest/include
|
find_package(GTest REQUIRED)
|
||||||
../../ext/gmock
|
pkg_check_modules(GMOCK REQUIRED gmock)
|
||||||
../../ext/gmock/include)
|
include_directories(
|
||||||
|
${GTEST_INCLUDE_DIRS}
|
||||||
|
${GMOCK_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
include_directories(
|
||||||
|
../../ext/gtest
|
||||||
|
../../ext/gtest/include
|
||||||
|
../../ext/gmock
|
||||||
|
../../ext/gmock/include
|
||||||
|
)
|
||||||
|
|
||||||
add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc)
|
add_library(gtest STATIC ../../ext/gtest/src/gtest-all.cc)
|
||||||
add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc)
|
add_library(gmock STATIC ../../ext/gmock/src/gmock-all.cc)
|
||||||
|
|
||||||
if (UNIX)
|
set(GTEST_LIBRARIES gtest)
|
||||||
# ignore warnings in gtest and gmock
|
set(GMOCK_LIBRARIES gmock)
|
||||||
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
|
|
||||||
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
|
if (UNIX)
|
||||||
|
# ignore warnings in gtest and gmock
|
||||||
|
set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
|
||||||
|
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(integtests)
|
add_subdirectory(integtests)
|
||||||
|
|
|
@ -68,8 +68,6 @@ endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../../
|
../../
|
||||||
../../../ext/gtest/include
|
|
||||||
../../../ext/gmock/include
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
@ -80,4 +78,4 @@ endif()
|
||||||
|
|
||||||
add_executable(integtests ${sources})
|
add_executable(integtests ${sources})
|
||||||
target_link_libraries(integtests
|
target_link_libraries(integtests
|
||||||
arch base client common io ipc mt net platform server synlib gtest gmock ${libs} ${OPENSSL_LIBS})
|
arch base client common io ipc mt net platform server synlib ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
|
@ -50,8 +50,6 @@ list(APPEND headers ${platform_sources})
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../../
|
../../
|
||||||
../../../ext/gtest/include
|
|
||||||
../../../ext/gmock/include
|
|
||||||
../../../ext
|
../../../ext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -67,4 +65,4 @@ endif()
|
||||||
|
|
||||||
add_executable(unittests ${sources})
|
add_executable(unittests ${sources})
|
||||||
target_link_libraries(unittests
|
target_link_libraries(unittests
|
||||||
arch base client server common io net platform server synlib mt ipc gtest gmock ${libs} ${OPENSSL_LIBS})
|
arch base client server common io net platform server synlib mt ipc ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
Loading…
Reference in New Issue