mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-27 07:14:12 +08:00
fixed pr #228 to include pthread and removed header_dependecies test
This commit is contained in:
parent
6402885164
commit
3a44818b2a
@ -9,11 +9,16 @@ add_library(catch INTERFACE)
|
|||||||
target_include_directories(catch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(catch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
file(GLOB catch_tests LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB catch_tests LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set ( CMAKE_CXX_FLAGS "--std=c++11 -pthread")
|
||||||
|
set ( CMAKE_EXE_LIKKER_FLAGS "-pthread")
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_executable(catch_tests ${catch_tests})
|
add_executable(catch_tests ${catch_tests})
|
||||||
target_link_libraries(catch_tests spdlog)
|
target_link_libraries(catch_tests spdlog)
|
||||||
add_test(NAME catch_tests COMMAND catch_tests)
|
add_test(NAME catch_tests COMMAND catch_tests)
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
|
||||||
|
|
||||||
# Ensure headers include their own dependencies
|
|
||||||
add_subdirectory(header_dependencies)
|
|
||||||
|
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
#
|
|
||||||
# Ensure all headers include all dependencies
|
|
||||||
#
|
|
||||||
|
|
||||||
set(IGNORED_HEADERS "")
|
|
||||||
|
|
||||||
set(COMMON_TEST_LIBRARIES spdlog)
|
|
||||||
|
|
||||||
add_custom_target(header_dependencies)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE headers RELATIVE "${HEADER_BASE}" ${HEADER_BASE}/*.h)
|
|
||||||
set(test_index 0)
|
|
||||||
foreach(HEADER ${headers})
|
|
||||||
# Sample of relevant variables computed here
|
|
||||||
# HEADER: details/line_logger_impl.h
|
|
||||||
# symbolname: spdlog_details_line_logger_impl
|
|
||||||
|
|
||||||
# Compute symbolname
|
|
||||||
string(REPLACE ".h" "" symbolname "${HEADER}")
|
|
||||||
string(MAKE_C_IDENTIFIER "${symbolname}" symbolname)
|
|
||||||
|
|
||||||
list(FIND IGNORED_HEADERS "${HEADER}" _index)
|
|
||||||
# If we didn't explicitly ignore this and if we built this target
|
|
||||||
if(${_index} EQUAL -1)
|
|
||||||
#message(STATUS "${HEADER}: '${symbolname}'")
|
|
||||||
|
|
||||||
set(extension cpp)
|
|
||||||
|
|
||||||
# Name the test and output file with a number, to dodge Windows path length limits.
|
|
||||||
# Call it header, instead of test, to avoid polluting the 'executable namespace'
|
|
||||||
set(test_name "header_${extension}_${test_index}")
|
|
||||||
|
|
||||||
set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/main.${extension}")
|
|
||||||
|
|
||||||
add_executable(${test_name} "${source_file}")
|
|
||||||
target_compile_definitions(${test_name} PRIVATE HEADER_TO_TEST="${HEADER}")
|
|
||||||
target_include_directories(${test_name}
|
|
||||||
PRIVATE
|
|
||||||
${BUILDTREE_HEADER_BASE}
|
|
||||||
${HEADER_BASE})
|
|
||||||
|
|
||||||
set_target_properties(${test_name} PROPERTIES
|
|
||||||
FOLDER "Header dependency tests")
|
|
||||||
|
|
||||||
target_link_libraries(${test_name}
|
|
||||||
PRIVATE
|
|
||||||
${COMMON_TEST_LIBRARIES}
|
|
||||||
${LIBRARIES_${symbolname}}
|
|
||||||
${LIBRARIES_${libname}})
|
|
||||||
|
|
||||||
add_test(NAME ${test_name}_builds COMMAND ${test_name})
|
|
||||||
add_dependencies(header_dependencies ${test_name})
|
|
||||||
|
|
||||||
math(EXPR test_index "${test_index} + 1")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
#include HEADER_TO_TEST
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
#include HEADER_TO_TEST
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) { return 0; }
|
|
Loading…
Reference in New Issue
Block a user