Merge pull request #5 from intothevoid/master
[KDIS.git] / KDIS / Tests / CMakeLists.txt
blob5aca34fd20fa76cc5bb0494780515f5c6108ae9e
1 set(PROJECT_NAME_STR KDIS)
3 find_package(Threads REQUIRED)
4 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
5 include(FetchContent)
6 FetchContent_Declare(
7         googletest
8         GIT_REPOSITORY https://github.com/google/googletest.git
9         GIT_TAG        703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0
11 FetchContent_MakeAvailable(googletest)
13 enable_testing()
14 set(PROJECT_TEST_NAME ${PROJECT_NAME_STR}_tests)
15 include_directories(${GTEST_INCLUDE_DIRS} ${COMMON_INCLUDES})
16 INCLUDE_DIRECTORIES(${KDIS_SOURCE_DIR})
17 file(GLOB TEST_SRC_FILES UnitTests/*.cpp)
18 add_executable(${PROJECT_TEST_NAME} ${TEST_SRC_FILES})
19 target_link_libraries(${PROJECT_TEST_NAME} gtest_main)
20 add_test(${PROJECT_TEST_NAME} ${PROJECT_TEST_NAME})
22 IF(BUILD_EXAMPLES_TO_LINK_TO_LIB)
24     IF(EXAMPLES_USE_STATIC_OR_SHARED_LIB MATCHES STATIC)
25         TARGET_LINK_LIBRARIES(${PROJECT_TEST_NAME} KDIS_LIB)
26     ENDIF(EXAMPLES_USE_STATIC_OR_SHARED_LIB MATCHES STATIC)
27     
28     IF(EXAMPLES_USE_STATIC_OR_SHARED_LIB MATCHES SHARED)
29         TARGET_LINK_LIBRARIES(${PROJECT_TEST_NAME} KDIS_DLL)
30         ADD_DEFINITIONS(-D "IMPORT_KDIS")
31     ENDIF(EXAMPLES_USE_STATIC_OR_SHARED_LIB MATCHES SHARED)
32     
33 ENDIF(BUILD_EXAMPLES_TO_LINK_TO_LIB)
35 IF(DIS_VERSION MATCHES 6)
36         ADD_DEFINITIONS(-D "DIS_VERSION=6")
37 ENDIF(DIS_VERSION MATCHES 6)
39 IF(DIS_VERSION MATCHES 5)
40         ADD_DEFINITIONS(-D "DIS_VERSION=5")
41 ENDIF(DIS_VERSION MATCHES 5)
43 IF(DIS_VERSION MATCHES 7)
44         ADD_DEFINITIONS(-D "DIS_VERSION=7")
45 ENDIF(DIS_VERSION MATCHES 7)
47 IF(KDIS_USE_ENUM_DESCRIPTORS)
48         ADD_DEFINITIONS(-D "KDIS_USE_ENUM_DESCRIPTORS")
49 ENDIF(KDIS_USE_ENUM_DESCRIPTORS) 
51 #target_link_libraries(${PROJECT_TEST_NAME} ${CMAKE_THREAD_LIBS_INIT})