1
1
#
2
2
# Amalgamation
3
3
#
4
- # We should check whether bash is available here and avoid failures on systems where
5
- # bash is unavailable.
4
+
6
5
set (SINGLEHEADER_FILES
7
6
${CMAKE_CURRENT_BINARY_DIR} /simdjson.cpp
8
7
${CMAKE_CURRENT_BINARY_DIR} /simdjson.h
@@ -17,32 +16,16 @@ set(SINGLEHEADER_REPO_FILES
17
16
)
18
17
set_source_files_properties (${SINGLEHEADER_FILES} PROPERTIES GENERATED TRUE )
19
18
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)
34
20
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)
39
22
add_custom_command (
40
23
OUTPUT ${SINGLEHEADER_FILES}
41
24
COMMAND ${CMAKE_COMMAND} -E env
42
25
AMALGAMATE_SOURCE_PATH=${PROJECT_SOURCE_DIR} /src
43
26
AMALGAMATE_INPUT_PATH=${PROJECT_SOURCE_DIR} /include
44
27
AMALGAMATE_OUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}
45
- bash ${CMAKE_CURRENT_SOURCE_DIR} /amalgamate.sh
28
+ ${BASH} ${CMAKE_CURRENT_SOURCE_DIR} /amalgamate.sh
46
29
#
47
30
# This is the best way I could find to make amalgamation trigger whenever source files or
48
31
# header files change: since the "simdjson" library has to get rebuilt when that happens, we
@@ -72,7 +55,22 @@ else(MSVC)
72
55
# "make amalgamate" to generate the header files directly and update the original source
73
56
#
74
57
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)
76
74
77
75
78
76
#
0 commit comments