Fix tests.

This commit is contained in:
Victor Zverovich 2014-06-09 09:57:34 -07:00
parent 5222f59cc0
commit e7b6896c43
3 changed files with 11 additions and 10 deletions

View File

@ -46,6 +46,8 @@ if (FMT_SHARED)
set(shared SHARED) set(shared SHARED)
endif () endif ()
set(FMT_SOURCES format.cc format.h)
include(CheckSymbolExists) include(CheckSymbolExists)
if (WIN32) if (WIN32)
check_symbol_exists(open io.h HAVE_OPEN) check_symbol_exists(open io.h HAVE_OPEN)
@ -54,10 +56,10 @@ else ()
endif () endif ()
if (HAVE_OPEN) if (HAVE_OPEN)
add_definitions(-DFMT_USE_FILE_DESCRIPTORS=1) add_definitions(-DFMT_USE_FILE_DESCRIPTORS=1)
set(FMT_POSIX_SRC posix.cc posix.h) set(FMT_SOURCES ${FMT_SOURCES} posix.cc posix.h)
endif () endif ()
add_library(format ${shared} format.cc format.h ${FMT_POSIX_SRC}) add_library(format ${shared} ${FMT_SOURCES})
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(format PROPERTIES COMPILE_FLAGS set_target_properties(format PROPERTIES COMPILE_FLAGS
"-Wall -Wextra -pedantic") "-Wall -Wextra -pedantic")
@ -66,7 +68,7 @@ if (CPP11_FLAG AND FMT_EXTRA_TESTS)
set_target_properties(format PROPERTIES COMPILE_FLAGS ${CPP11_FLAG}) set_target_properties(format PROPERTIES COMPILE_FLAGS ${CPP11_FLAG})
# Test compilation with default flags. # Test compilation with default flags.
file(GLOB src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cc test/*.h) file(GLOB src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*.cc test/*.h)
add_library(testformat format.cc ${FMT_POSIX_SRC} ${src}) add_library(testformat ${FMT_SOURCES} ${src})
endif () endif ()
add_subdirectory(doc) add_subdirectory(doc)
@ -112,10 +114,10 @@ endforeach ()
cxx_test(util-test test-main) cxx_test(util-test test-main)
if (HAVE_OPEN) if (HAVE_OPEN)
add_executable(posix-test test/posix-test.cc ${TEST_MAIN_SRC}) add_executable(posix-test test/posix-test.cc ${FMT_SOURCES} ${TEST_MAIN_SRC})
set_target_properties(posix-test set_target_properties(posix-test
PROPERTIES COMPILE_DEFINITIONS "FMT_INCLUDE_POSIX_TEST=1") PROPERTIES COMPILE_DEFINITIONS "FMT_INCLUDE_POSIX_TEST=1")
target_link_libraries(posix-test gtest format) target_link_libraries(posix-test gtest)
add_test(posix-test posix-test) add_test(posix-test posix-test)
endif () endif ()

View File

@ -37,6 +37,10 @@
#include "format.h" #include "format.h"
#ifdef FMT_INCLUDE_POSIX_TEST
# include "test/posix-test.h"
#endif
#ifndef FMT_POSIX #ifndef FMT_POSIX
# ifdef _WIN32 # ifdef _WIN32
// Fix warnings about deprecated symbols. // Fix warnings about deprecated symbols.

View File

@ -29,15 +29,10 @@
#define FMT_GTEST_EXTRA_H #define FMT_GTEST_EXTRA_H
#include <string> #include <string>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "format.h" #include "format.h"
#ifdef FMT_INCLUDE_POSIX_TEST
# include "posix-test.h"
#endif
#ifndef FMT_USE_FILE_DESCRIPTORS #ifndef FMT_USE_FILE_DESCRIPTORS
# define FMT_USE_FILE_DESCRIPTORS 0 # define FMT_USE_FILE_DESCRIPTORS 0
#endif #endif