2015-07-13 15:49:44 +02:00
|
|
|
# g3log is a KjellKod Logger
|
|
|
|
# 2015 @author Kjell Hedström, hedstrom@kjellkod.cc
|
|
|
|
# ==================================================================
|
|
|
|
# 2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own
|
|
|
|
# risk and comes with no warranties.
|
2014-10-03 08:56:13 +02:00
|
|
|
#
|
2015-07-13 15:49:44 +02:00
|
|
|
# This code is yours to share, use and modify with no strings attached
|
|
|
|
# and no restrictions or obligations.
|
|
|
|
# ===================================================================
|
2014-10-03 08:56:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
# ============================================================================
|
|
|
|
# TEST OPTIONS: Turn OFF the ones that is of no interest to you
|
2014-10-03 09:53:21 +02:00
|
|
|
# ---- by default all is OFF: except 'g3log-FATAL-example -----
|
2014-10-03 08:56:13 +02:00
|
|
|
# ---- the reason for this is that
|
|
|
|
# ----- 1) the performance tests were only thoroughly tested on Ubuntu, not windows-
|
2014-10-03 09:53:21 +02:00
|
|
|
# (g3log windows/linux, but Google's glog only on linux)
|
2014-10-03 08:56:13 +02:00
|
|
|
#
|
2020-06-03 23:37:46 +02:00
|
|
|
# 2) The unit test were tested windows/linux
|
2014-10-03 08:56:13 +02:00
|
|
|
# ============================================================================
|
|
|
|
|
|
|
|
|
2014-10-03 09:53:21 +02:00
|
|
|
# Unit test for g3log (cmake -DUSE_G3LOG_UNIT_TEST=ON ..)
|
2015-07-13 15:49:44 +02:00
|
|
|
option (ADD_G3LOG_UNIT_TEST "g3log unit tests" OFF)
|
2014-10-03 08:56:13 +02:00
|
|
|
|
|
|
|
|
2014-10-03 09:53:21 +02:00
|
|
|
# 4. create the unit tests for g3log --- ONLY TESTED THE UNIT TEST ON LINUX
|
2014-10-03 08:56:13 +02:00
|
|
|
# =========================
|
2015-07-13 15:49:44 +02:00
|
|
|
IF (ADD_G3LOG_UNIT_TEST)
|
2020-06-03 23:37:46 +02:00
|
|
|
# Download and unpack googletest at configure time
|
|
|
|
configure_file(CMakeLists.txt.in
|
|
|
|
googletest-download/CMakeLists.txt)
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
|
|
|
|
|
|
|
|
# Prevent GoogleTest from overriding our compiler/linker options
|
|
|
|
# when building with Visual Studio
|
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
|
|
|
|
|
|
# Add googletest directly to our build. This adds
|
|
|
|
# the following targets: gtest, gtest_main, gmock
|
|
|
|
# and gmock_main
|
|
|
|
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
|
|
|
|
${CMAKE_BINARY_DIR}/googletest-build)
|
|
|
|
|
|
|
|
# The gtest/gmock targets carry header search path
|
|
|
|
# dependencies automatically when using CMake 2.8.11 or
|
|
|
|
# later. Otherwise we have to add them here ourselves.
|
|
|
|
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
|
|
|
include_directories("${gtest_SOURCE_DIR}/include"
|
|
|
|
"${gmock_SOURCE_DIR}/include")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
2014-10-03 08:56:13 +02:00
|
|
|
set(DIR_UNIT_TEST ${g3log_SOURCE_DIR}/test_unit)
|
2017-05-17 22:31:19 +02:00
|
|
|
message( STATUS "-DADD_G3LOG_UNIT_TEST=ON" )
|
2014-10-03 08:56:13 +02:00
|
|
|
|
|
|
|
# obs see this: http://stackoverflow.com/questions/9589192/how-do-i-change-the-number-of-template-arguments-supported-by-msvcs-stdtupl
|
|
|
|
# and this: http://stackoverflow.com/questions/2257464/google-test-and-visual-studio-2010-rc
|
|
|
|
|
|
|
|
|
2015-02-02 08:31:43 +01:00
|
|
|
IF (MSVC OR MINGW)
|
|
|
|
SET(OS_SPECIFIC_TEST test_crashhandler_windows)
|
|
|
|
ENDIF(MSVC OR MINGW)
|
|
|
|
|
2016-08-11 08:27:52 +02:00
|
|
|
SET(tests_to_run test_message test_filechange test_io test_cpp_future_concepts test_concept_sink test_sink ${OS_SPECIFIC_TEST})
|
2014-10-03 08:56:13 +02:00
|
|
|
SET(helper ${DIR_UNIT_TEST}/testing_helpers.h ${DIR_UNIT_TEST}/testing_helpers.cpp)
|
|
|
|
include_directories(${DIR_UNIT_TEST})
|
|
|
|
|
|
|
|
FOREACH(test ${tests_to_run} )
|
|
|
|
SET(all_tests ${all_tests} ${DIR_UNIT_TEST}/${test}.cpp )
|
|
|
|
IF(${test} STREQUAL "test_filechange")
|
2016-08-11 08:27:52 +02:00
|
|
|
add_executable(test_filechange ${DIR_UNIT_TEST}/${test}.cpp ${helper})
|
2014-10-03 08:56:13 +02:00
|
|
|
ELSE()
|
2014-10-03 09:20:33 +02:00
|
|
|
add_executable(${test} ${g3log_SOURCE_DIR}/test_main/test_main.cpp ${DIR_UNIT_TEST}/${test}.cpp ${helper})
|
2014-10-03 08:56:13 +02:00
|
|
|
ENDIF(${test} STREQUAL "test_filechange")
|
|
|
|
|
|
|
|
set_target_properties(${test} PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_TR1_TUPLE=0")
|
|
|
|
set_target_properties(${test} PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_RTTI=0")
|
|
|
|
IF( NOT(MSVC))
|
|
|
|
set_target_properties(${test} PROPERTIES COMPILE_FLAGS "-isystem -pthread ")
|
|
|
|
ENDIF( NOT(MSVC))
|
2020-07-09 06:42:55 +02:00
|
|
|
target_link_libraries(${test} g3log gtest_main)
|
2017-05-09 18:26:48 +02:00
|
|
|
add_test( ${test} ${test} )
|
2014-10-03 08:56:13 +02:00
|
|
|
ENDFOREACH(test)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test for Linux, runtime loading of dynamic libraries
|
|
|
|
#
|
2017-05-09 18:26:48 +02:00
|
|
|
IF (NOT WIN32 AND NOT ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang") AND G3_SHARED_LIB)
|
2014-10-03 08:56:13 +02:00
|
|
|
add_library(tester_sharedlib SHARED ${DIR_UNIT_TEST}/tester_sharedlib.h ${DIR_UNIT_TEST}/tester_sharedlib.cpp)
|
2017-03-31 06:52:09 +02:00
|
|
|
target_link_libraries(tester_sharedlib ${G3LOG_LIBRARY})
|
2014-10-03 08:56:13 +02:00
|
|
|
|
2017-05-17 22:24:11 +02:00
|
|
|
add_executable(test_dynamic_loaded_shared_lib ${g3log_SOURCE_DIR}/test_main/test_main.cpp ${DIR_UNIT_TEST}/test_linux_dynamic_loaded_sharedlib.cpp)
|
2014-10-03 08:56:13 +02:00
|
|
|
set_target_properties(test_dynamic_loaded_shared_lib PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_TR1_TUPLE=0")
|
|
|
|
set_target_properties(test_dynamic_loaded_shared_lib PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_RTTI=0")
|
2020-06-03 23:37:46 +02:00
|
|
|
target_link_libraries(test_dynamic_loaded_shared_lib ${G3LOG_LIBRARY} -ldl gtest_main)
|
2014-10-03 08:56:13 +02:00
|
|
|
ENDIF()
|
|
|
|
ELSE()
|
2017-05-17 22:31:19 +02:00
|
|
|
message( STATUS "-DADD_G3LOG_UNIT_TEST=OFF" )
|
2015-07-13 15:49:44 +02:00
|
|
|
ENDIF (ADD_G3LOG_UNIT_TEST)
|