From 9e29c7941056eacd9e2590f8fe59b83578526f70 Mon Sep 17 00:00:00 2001 From: Matthew Ratzloff Date: Fri, 10 Feb 2023 18:40:57 -0800 Subject: [PATCH 1/3] Ignore CMake and binary files --- .gitignore | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index df8c5fe..a761f90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ -/build -_empty.cpp _bloat_test_tmp* -tinyformat_test_cxx* +_empty.cpp +*.cmake +bin +build +CMakeCache.txt +CMakeFiles tinyformat_speed_test +tinyformat_test_cxx* From bde1bfc770c10046951accd54b8c4633091578e0 Mon Sep 17 00:00:00 2001 From: Matthew Ratzloff Date: Fri, 10 Feb 2023 19:29:03 -0800 Subject: [PATCH 2/3] Make build tests optional --- CMakeLists.txt | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7715dd0..9f58d1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,18 +27,21 @@ if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX") endif() -# Dummy translation unit to test for missing `inline`s -include_directories(${CMAKE_SOURCE_DIR}) -file(WRITE ${CMAKE_BINARY_DIR}/_empty.cpp "#include \"tinyformat.h\"") -add_executable(tinyformat_test tinyformat_test.cpp ${CMAKE_BINARY_DIR}/_empty.cpp) -enable_testing() -if(CMAKE_CONFIGURATION_TYPES) - set(ctest_config_opt -C ${CMAKE_BUILD_TYPE}) -endif() -add_test(NAME test COMMAND tinyformat_test) -add_custom_target(testall COMMAND ${CMAKE_CTEST_COMMAND} -V ${ctest_config_opt} DEPENDS tinyformat_test) - -option(COMPILE_SPEED_TEST FALSE) -if (COMPILE_SPEED_TEST) - add_executable(tinyformat_speed_test tinyformat_speed_test.cpp) +option(TINYFORMAT_TEST ON) +if (TINYFORMAT_TEST) + # Dummy translation unit to test for missing `inline`s + include_directories(${CMAKE_SOURCE_DIR}) + file(WRITE ${CMAKE_BINARY_DIR}/_empty.cpp "#include \"tinyformat.h\"") + add_executable(tinyformat_test tinyformat_test.cpp ${CMAKE_BINARY_DIR}/_empty.cpp) + enable_testing() + if(CMAKE_CONFIGURATION_TYPES) + set(ctest_config_opt -C ${CMAKE_BUILD_TYPE}) + endif() + add_test(NAME test COMMAND tinyformat_test) + add_custom_target(testall COMMAND ${CMAKE_CTEST_COMMAND} -V ${ctest_config_opt} DEPENDS tinyformat_test) + + option(COMPILE_SPEED_TEST OFF) + if (COMPILE_SPEED_TEST) + add_executable(tinyformat_speed_test tinyformat_speed_test.cpp) + endif () endif () From 221c24d25cb28bb21f0a34835314e0e36196c546 Mon Sep 17 00:00:00 2001 From: Matthew Ratzloff Date: Fri, 10 Feb 2023 19:50:05 -0800 Subject: [PATCH 3/3] Enable inclusion into other CMake builds --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f58d1e..c62d3c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,8 @@ if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX") endif() -option(TINYFORMAT_TEST ON) -if (TINYFORMAT_TEST) +option(BUILD_TESTS ON) +if (BUILD_TESTS) # Dummy translation unit to test for missing `inline`s include_directories(${CMAKE_SOURCE_DIR}) file(WRITE ${CMAKE_BINARY_DIR}/_empty.cpp "#include \"tinyformat.h\"") @@ -45,3 +45,9 @@ if (TINYFORMAT_TEST) add_executable(tinyformat_speed_test tinyformat_speed_test.cpp) endif () endif () + +# Enable inclusion into other CMake builds +add_library(tinyformat INTERFACE) +target_include_directories(tinyformat INTERFACE $) +install(TARGETS tinyformat EXPORT tinyformat) +install(EXPORT tinyformat NAMESPACE tinyformat:: DESTINATION ${CMAKE_CURRENT_LIST_DIR})