Simplify CMake config and do minor adjustments

for consistency with used coding conventions.
This commit is contained in:
vitaut
2015-12-10 07:24:23 -08:00
parent a9d2e826fe
commit 1cba0aea27
3 changed files with 30 additions and 30 deletions

View File

@@ -2,9 +2,13 @@ set(FMT_GMOCK_DIR ../gmock)
include_directories(.. ${FMT_GMOCK_DIR})
if (BUILD_SHARED_LIBS)
set(FMT_IMPORT "-DFMT_SHARED")
endif ()
# Links target with cppformat and any libraries passed as extra arguments.
function (target_link_cppformat target)
target_link_libraries(${target} cppformat ${ARGN})
if (BUILD_SHARED_LIBS)
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -DFMT_SHARED)
endif ()
endfunction ()
# We compile Google Test ourselves instead of using pre-compiled libraries.
# See the Google Test FAQ "Why is it not recommended to install a
@@ -49,8 +53,7 @@ endif ()
set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
add_library(test-main STATIC ${TEST_MAIN_SRC})
set_target_properties(test-main PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
target_link_libraries(test-main cppformat gmock)
target_link_cppformat(test-main gmock)
# Adds a test.
# Usage: add_fmt_test(name [CUSTOM_LINK] srcs...)
@@ -59,8 +62,7 @@ function(add_fmt_test name)
add_executable(${name} ${name}.cc ${add_fmt_test_UNPARSED_ARGUMENTS})
target_link_libraries(${name} test-main)
if (NOT add_fmt_test_CUSTOM_LINK)
set_target_properties(${name} PROPERTIES COMPILE_FLAGS "${FMT_IMPORT}")
target_link_libraries(${name} cppformat)
target_link_cppformat(${name})
endif ()
add_test(NAME ${name} COMMAND ${name})
endfunction()