Skip to content

Enable CMake ExternalProject_Add and other improvements #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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*
37 changes: 23 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>)
install(TARGETS tinyformat EXPORT tinyformat)
install(EXPORT tinyformat NAMESPACE tinyformat:: DESTINATION ${CMAKE_CURRENT_LIST_DIR})