chore: added CPM and doc cmake
[KDIS.git] / test / CMakeLists.txt
blobe41b6567ab5e785cf9a680667288d7660ae46764
1 set(PROJECT_NAME_STR KDIS)
3 find_package(Threads REQUIRED)
5 CPMAddPackage(
6   NAME googletest
7   GITHUB_REPOSITORY google/googletest
8   GIT_TAG v1.14.0
9   EXCLUDE_FROM_ALL ON
10   SYSTEM ON
11   OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt ON")
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)
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)
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})