x9e with horus bt module (#5214)
[opentx.git] / radio / src / tests / CMakeLists.txt
bloba8b0941e29e7abce8de330d5c751fdc1e928d6f2
1 set(GTEST_ROOT /usr CACHE string "Base path to Google Test headers and source.")
3 find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').")
4 find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
6 if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
7   add_library(gtests-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
8   target_include_directories(gtests-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
9   add_definitions(-DSIMU)
10   add_definitions(-DGTESTS)
11   set(TESTS_PATH ${RADIO_SRC_DIRECTORY})
12   configure_file(${RADIO_SRC_DIRECTORY}/tests/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
13   include_directories(${CMAKE_CURRENT_BINARY_DIR})
15   if(WIN32)
16     target_include_directories(gtests-lib PUBLIC ${WIN_INCLUDE_DIRS})
17     target_link_libraries(gtests-lib PRIVATE ${WIN_LINK_LIBRARIES})
18   endif(WIN32)
20   if(SDL_FOUND AND SIMU_AUDIO)
21     target_include_directories(gtests-lib PUBLIC ${SDL_INCLUDE_DIR})
22     target_link_libraries(gtests-lib PRIVATE ${SDL_LIBRARY})
23   endif()
25   foreach(FILE ${SRC})
26     set(RADIO_SRC ${RADIO_SRC} ../${FILE})
27   endforeach()
29   file(GLOB TEST_SRC_FILES ${RADIO_SRC_DIRECTORY}/tests/*.cpp)
31   if(MINGW)
32     # struct packing breaks on MinGW w/out -mno-ms-bitfields: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 & http://stackoverflow.com/questions/24015852/struct-packing-and-alignment-with-mingw
33     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-ms-bitfields")
34   endif()
35   set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
36   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
38   use_cxx11()  # ensure gnu++11 in CXX_FLAGS with CMake < 3.1
40   add_executable(gtests EXCLUDE_FROM_ALL ${TEST_SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/location.h ${RADIO_SRC} ../targets/simu/simpgmspace.cpp ../targets/simu/simueeprom.cpp ../targets/simu/simufatfs.cpp)
41   qt5_use_modules(gtests Core Widgets)
42   add_dependencies(gtests ${FIRMWARE_DEPENDENCIES} gtests-lib)
43   target_link_libraries(gtests gtests-lib pthread)
44   message(STATUS "Added optional gtests target")
45 else()
46   message(WARNING "WARNING: gtests target will not be available (check that GTEST_INCDIR, GTEST_SRCDIR, and Qt5Widgets are configured).")
47 endif()