This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeHelpers.cmake
129 lines (124 loc) · 5.47 KB
/
CMakeHelpers.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Ben Brittain
# Copyright OkCupid 2016
# Moving the Build System into 2012
set(OKWS_XMLRPCC ${OKWS_BINARY_DIR}/xmlrpcc/xmlrpcc)
FUNCTION(PreprocessTamedFiles RET RET_HEADERS SOURCES)
set(OKWS_TAME /usr/local/lib/sfslite-1.2/shopt/tame)
if(STATIC)
set(OKWS_TAME /usr/local/lib/sfslite-1.2/hiperf/tame)
endif()
set(_result ${${RET}})
set(_result_headers ${${RET_HEADERS}})
foreach(t_file ${SOURCES})
get_filename_component(name_file ${t_file} NAME)
if ("${t_file}" MATCHES ".Th$")
string(REPLACE ".Th" ".h" cxx_file ${CMAKE_CURRENT_BINARY_DIR}/${t_file})
else()
string(REPLACE ".T" ".cxx" cxx_file ${CMAKE_CURRENT_BINARY_DIR}/${t_file})
endif()
add_custom_command(
OUTPUT ${cxx_file}
COMMAND ${OKWS_TAME}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${t_file} > ${cxx_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${t_file} ${OKWS_TAME})
if ("${t_file}" MATCHES ".Th$")
list(APPEND _result_headers ${cxx_file})
else()
list(APPEND _result ${cxx_file})
endif()
endforeach(t_file ${SOURCES})
SET(${RET} ${_result} PARENT_SCOPE)
SET(${RET_HEADERS} ${_result_headers} PARENT_SCOPE)
ENDFUNCTION()
FUNCTION(OkwsPreprocessProtFiles CFILES HFILES SOURCES)
set(OKWS_RPCC /usr/local/lib/sfslite-1.2/shopt/rpcc)
if(STATIC)
set(OKWS_RPCC /usr/local/lib/sfslite-1.2/hiperf/rpcc)
endif()
set(_c_result)
set(_h_result)
foreach(p_file ${SOURCES})
get_filename_component(name_file ${p_file} NAME)
if ("${p_file}" MATCHES ".v$") #hacky but people used the wrong suffixes a lot :(
string(REPLACE ".v" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".v" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
else()
string(REPLACE ".x" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".x" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
endif()
add_custom_command(
OUTPUT ${h_file}
COMMAND ${OKWS_RPCC}
ARGS -X -o ${h_file} -h ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${p_file} ${OKWS_RPCC})
add_custom_command(
OUTPUT ${c_file}
COMMAND ${OKWS_RPCC}
ARGS -X -o ${c_file} -c ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${h_file} ${OKWS_RPCC})
list(APPEND _c_result ${c_file})
list(APPEND _h_result ${h_file})
endforeach(p_file ${SOURCES})
SET(${HFILES} ${_h_result} PARENT_SCOPE)
SET(${CFILES} ${_c_result} PARENT_SCOPE)
ENDFUNCTION()
FUNCTION(OkwsPreprocessXmlProtFiles CFILES HFILES SOURCES)
set(OKWS_RPCC /usr/local/lib/sfslite-1.2/shopt/rpcc)
if(STATIC)
set(OKWS_RPCC /usr/local/lib/sfslite-1.2/hiperf/rpcc)
endif()
set(_c_result)
set(_h_result)
foreach(p_file ${SOURCES})
get_filename_component(name_file ${p_file} NAME)
if ("${p_file}" MATCHES ".v$") #hacky but people used the wrong suffixes a lot :(
string(REPLACE ".v" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".v" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
else()
string(REPLACE ".x" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".x" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
endif()
add_custom_command(
OUTPUT ${h_file}
COMMAND ${OKWS_RPCC}
ARGS -o ${h_file} -h ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${p_file} ${OKWS_RPCC})
add_custom_command(
OUTPUT ${c_file}
COMMAND ${OKWS_RPCC}
ARGS -o ${c_file} -c ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${h_file} ${OKWS_RPCC})
list(APPEND _c_result ${c_file})
list(APPEND _h_result ${h_file})
endforeach(p_file ${SOURCES})
SET(${HFILES} ${_h_result} PARENT_SCOPE)
SET(${CFILES} ${_c_result} PARENT_SCOPE)
ENDFUNCTION()
FUNCTION(PreprocessXmlProtFiles CFILES HFILES SOURCES)
set(_c_result)
set(_h_result)
foreach(p_file ${SOURCES})
get_filename_component(name_file ${p_file} NAME)
if ("${p_file}" MATCHES ".v$") #hacky but people used the wrong suffixes a lot :(
string(REPLACE ".v" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".v" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
else()
string(REPLACE ".x" ".h" h_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
string(REPLACE ".x" ".C" c_file ${CMAKE_CURRENT_BINARY_DIR}/${p_file})
endif()
add_custom_command(
OUTPUT ${h_file}
COMMAND LD_LIBRARY_PATH=/usr/local/lib/sfslite-1.2/shopt/ ${OKWS_XMLRPCC}
ARGS -o ${h_file} -h ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${p_file} ${OKWS_XMLRPCC})
add_custom_command(
OUTPUT ${c_file}
COMMAND LD_LIBRARY_PATH=/usr/local/lib/sfslite-1.2/shopt/ ${OKWS_XMLRPCC}
ARGS -o ${c_file} -c ${CMAKE_CURRENT_SOURCE_DIR}/${p_file}
DEPENDS ${h_file} ${OKWS_XMLRPCC})
list(APPEND _c_result ${c_file})
list(APPEND _h_result ${h_file})
endforeach(p_file ${SOURCES})
SET(${HFILES} ${_h_result} PARENT_SCOPE)
SET(${CFILES} ${_c_result} PARENT_SCOPE)
ENDFUNCTION()