11#
22# Amalgamation
33#
4- # We should check whether bash is available here and avoid failures on systems where
5- # bash is unavailable.
4+
65set (SINGLEHEADER_FILES
76 ${CMAKE_CURRENT_BINARY_DIR} /simdjson.cpp
87 ${CMAKE_CURRENT_BINARY_DIR} /simdjson.h
@@ -17,32 +16,16 @@ set(SINGLEHEADER_REPO_FILES
1716)
1817set_source_files_properties (${SINGLEHEADER_FILES} PROPERTIES GENERATED TRUE )
1918
20- if (MSVC )
21- # MSVC doesn't have bash, so we use existing amalgamated files instead of generating them ...
22- # (Do not do this if the source and destination are the same!)
23- if (NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} ))
24- add_custom_command (
25- OUTPUT ${SINGLEHEADER_FILES}
26- COMMAND ${CMAKE_COMMAND} -E copy
27- ${SINGLEHEADER_REPO_FILES}
28- ${CMAKE_CURRENT_BINARY_DIR}
29- DEPENDS ${SINGLEHEADER_REPO_FILES}
30- )
31- endif ()
32-
33- else (MSVC )
19+ find_program (BASH bash )
3420
35- ##
36- # Important! The script amalgamate.sh is not generally executable. It
37- # assumes that bash is at /bin/bash which may not be true.
38- ###
21+ if (BASH)
3922 add_custom_command (
4023 OUTPUT ${SINGLEHEADER_FILES}
4124 COMMAND ${CMAKE_COMMAND} -E env
4225 AMALGAMATE_SOURCE_PATH=${PROJECT_SOURCE_DIR}/src
4326 AMALGAMATE_INPUT_PATH=${PROJECT_SOURCE_DIR}/include
4427 AMALGAMATE_OUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}
45- bash ${CMAKE_CURRENT_SOURCE_DIR} /amalgamate.sh
28+ ${BASH} ${CMAKE_CURRENT_SOURCE_DIR} /amalgamate.sh
4629 #
4730 # This is the best way I could find to make amalgamation trigger whenever source files or
4831 # header files change: since the "simdjson" library has to get rebuilt when that happens, we
@@ -72,7 +55,22 @@ else(MSVC)
7255 # "make amalgamate" to generate the header files directly and update the original source
7356 #
7457 add_custom_target (amalgamate DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /simdjson.cpp ${CMAKE_CURRENT_SOURCE_DIR} /simdjson.h ${CMAKE_CURRENT_SOURCE_DIR} /amalgamate_demo.cpp ${CMAKE_CURRENT_SOURCE_DIR} /README.md )
75- endif (MSVC )
58+
59+ else (BASH )
60+
61+ # We do not have bash, so we use existing amalgamated files instead of generating them ...
62+ # (Do not do this if the source and destination are the same!)
63+ if (NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} ))
64+ add_custom_command (
65+ OUTPUT ${SINGLEHEADER_FILES}
66+ COMMAND ${CMAKE_COMMAND} -E copy
67+ ${SINGLEHEADER_REPO_FILES}
68+ ${CMAKE_CURRENT_BINARY_DIR}
69+ DEPENDS ${SINGLEHEADER_REPO_FILES}
70+ )
71+ endif ()
72+
73+ endif (BASH )
7674
7775
7876#
0 commit comments