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* diff --git a/CMakeLists.txt b/CMakeLists.txt index 7715dd0..c62d3c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,18 +27,27 @@ 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(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\"") + 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 () + +# 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})