2020-04-18 06:07:18 +08:00
|
|
|
#
|
|
|
|
# Amalgamation
|
|
|
|
#
|
2020-04-23 09:22:09 +08:00
|
|
|
# We should check whether bash is available here and avoid failures on systems where
|
|
|
|
# bash is unavailable.
|
2020-04-18 06:07:18 +08:00
|
|
|
if (NOT MSVC)
|
2020-04-23 09:22:09 +08:00
|
|
|
##
|
|
|
|
# Important! The script amalgamate.sh is not generally executable. It
|
|
|
|
# assumes that bash is at /bin/bash which may not be true.
|
|
|
|
###
|
2020-04-18 06:07:18 +08:00
|
|
|
set(SINGLEHEADER_FILES simdjson.h simdjson.cpp amalgamate_demo.cpp README.md)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${SINGLEHEADER_FILES}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env
|
|
|
|
AMALGAMATE_SOURCE_PATH=${PROJECT_SOURCE_DIR}/src
|
|
|
|
AMALGAMATE_INPUT_PATH=${PROJECT_SOURCE_DIR}/include
|
|
|
|
AMALGAMATE_OUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}
|
2020-04-23 09:22:09 +08:00
|
|
|
bash ${CMAKE_CURRENT_SOURCE_DIR}/amalgamate.sh
|
|
|
|
DEPENDS amalgamate.sh simdjson-source
|
2020-04-18 06:07:18 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(amalgamate DEPENDS ${SINGLEHEADER_FILES})
|
|
|
|
add_executable(amalgamate_demo amalgamate_demo.cpp)
|
|
|
|
target_link_libraries(amalgamate_demo simdjson-include-source)
|
|
|
|
add_test(amalgamate_demo amalgamate_demo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})
|
2020-04-24 03:07:26 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# We also want to be able to build amalgamate_demo.cpp from the single header
|
|
|
|
# files alone.
|
|
|
|
#
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simdjson.h ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/simdjson.h COPYONLY)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/simdjson.cpp ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/simdjson.cpp COPYONLY)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amalgamate_demo.cpp ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/amalgamate_demo.cpp COPYONLY)
|
|
|
|
set(SINGLEHEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/simdjson.h )
|
|
|
|
add_library(singleheaderlib ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/simdjson.cpp ${SINGLEHEADER_FILE})
|
|
|
|
add_executable(amalgamate_demo_from_repo ${CMAKE_CURRENT_BINARY_DIR}/single_header_from_repo/amalgamate_demo.cpp ${SINGLEHEADER_FILE})
|
|
|
|
add_dependencies(amalgamate_demo_from_repo singleheaderlib)
|
|
|
|
add_test(amalgamate_demo_from_repo amalgamate_demo_from_repo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})
|
|
|
|
|