peteb / tankage

Multiplayer 2D tank game; drive around in a mutable world together with friends
10 stars 2 forks source link

Optional Unittest Target #18

Closed kskels closed 13 years ago

kskels commented 13 years ago

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)
peteb commented 13 years ago

It seems to be working, great :-)