mirror of
https://github.com/fmtlib/fmt.git
synced 2025-10-28 20:51:42 +01:00
Simplify CMake config and do minor adjustments
for consistency with used coding conventions.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user