I created new variable GTEST_FLAG which is set to true if all GTest libraries are found. Added check on this variable at the beginning of the CMakeLists.txt file which is dependent on the GTest. Seems to work pretty good and more nicer it will skip this file in negative case and will not give unittest target at all.
Bad thing that this check must be added in every unittest build file. But should be ok to start with, see some snippets from code below.
GTest find module
UNSET(GTEST_FLAG CACHE)
IF(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)
MESSAGE(STATUS "Found all required GTest stuff =]")
SET(GTEST_FLAG true)
ELSE(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)
MESSAGE(STATUS "WARNING: Failed to find all or some of the required GTest stuff =[")
ENDIF(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)
and at the beginning of CMakeLists.txt
if (NOT GTEST_FLAG)
return()
endif (NOT GTEST_FLAG)
I created new variable GTEST_FLAG which is set to true if all GTest libraries are found. Added check on this variable at the beginning of the CMakeLists.txt file which is dependent on the GTest. Seems to work pretty good and more nicer it will skip this file in negative case and will not give unittest target at all.
Bad thing that this check must be added in every unittest build file. But should be ok to start with, see some snippets from code below.
GTest find module
and at the beginning of CMakeLists.txt