diff options
| -rw-r--r-- | CMakeLists.txt | 14 | ||||
| -rw-r--r-- | GenerateSingleHeader.cmake | 18 |
2 files changed, 32 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 46720d7..89be727 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,5 +17,19 @@ add_library(cxxformat INTERFACE target_include_directories(cxxformat INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_features(cxxformat INTERFACE cxx_std_20) +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cxxformat.hpp" + COMMAND "${CMAKE_COMMAND}" "-DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/cxxformat.hpp" "-DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/GenerateSingleHeader.cmake" + DEPENDS include/cxxformat/core.hpp + include/cxxformat/file_ptr.hpp + include/cxxformat/formatters.hpp + include/cxxformat/helpers.hpp + include/cxxformat/ostream.hpp + include/cxxformat/runtime.hpp + include/cxxformat/string.hpp + GenerateSingleHeader.cmake +) + +add_custom_target(single-header DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/cxxformat.hpp") + add_executable(test EXCLUDE_FROM_ALL main.cpp) target_link_libraries(test PRIVATE cxxformat) diff --git a/GenerateSingleHeader.cmake b/GenerateSingleHeader.cmake new file mode 100644 index 0000000..e8fc5f7 --- /dev/null +++ b/GenerateSingleHeader.cmake @@ -0,0 +1,18 @@ +file(WRITE "${OUTPUT}" "#pragma once\n") + +function(add_header header output) + file(READ "${SRC_DIR}/include/cxxformat/${header}.hpp" content) + + string(REPLACE "#pragma once\n" "" content "${content}") + string(REGEX REPLACE "#include <cxxformat/[^>]+>\n" "" content "${content}") + + file(APPEND ${output} "${content}") +endfunction() + +add_header(helpers ${OUTPUT}) +add_header(core ${OUTPUT}) +add_header(formatters ${OUTPUT}) +add_header(file_ptr ${OUTPUT}) +add_header(ostream ${OUTPUT}) +add_header(string ${OUTPUT}) +add_header(runtime ${OUTPUT}) |
