-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
554 lines (435 loc) · 18.9 KB
/
CMakeLists.txt
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
cmake_minimum_required(VERSION 3.20...3.27)
project(scapix CXX)
set(SCAPIX_BRIDGE "cpp" CACHE STRING "cpp, java, objc, python, js, cs")
set(_SCAPIX_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
message(STATUS "SCAPIX_BRIDGE: ${SCAPIX_BRIDGE}")
# to do: remove duplication
set(PROJECT_ROOT ${CMAKE_SOURCE_DIR})
set(bridges
"cpp"
"java"
"objc"
"python"
"js"
"cs"
# "swift"
)
find_package(ScapixBin REQUIRED)
file(GLOB_RECURSE bridge_sources CONFIGURE_DEPENDS ${_SCAPIX_PATH}/source/scapix/bridge/${SCAPIX_BRIDGE}/*.cpp ${_SCAPIX_PATH}/source/scapix/bridge/${SCAPIX_BRIDGE}/*.mm)
file(GLOB_RECURSE link_sources CONFIGURE_DEPENDS ${_SCAPIX_PATH}/source/scapix/link/${SCAPIX_BRIDGE}/*.cpp ${_SCAPIX_PATH}/source/scapix/link/${SCAPIX_BRIDGE}/*.mm)
if(bridge_sources OR link_sources)
add_library(scapix)
set(scapix_public PUBLIC)
else()
add_library(scapix INTERFACE)
set(scapix_public INTERFACE)
endif()
file(GLOB_RECURSE sources CONFIGURE_DEPENDS ${_SCAPIX_PATH}/source/*)
source_group(TREE ${_SCAPIX_PATH}/source PREFIX "source" FILES ${sources})
target_sources(scapix PRIVATE ${sources})
find_package(ScapixCore REQUIRED)
target_link_libraries(scapix ${scapix_public} scapix::core)
if(SCAPIX_BRIDGE STREQUAL "java")
find_package(ScapixJNI REQUIRED)
target_link_libraries(scapix ${scapix_public} scapix::jni)
scapix_jni_source_group()
endif()
if(SCAPIX_BRIDGE STREQUAL "cs")
file(GLOB_RECURSE interface_sources ${_SCAPIX_PATH}/source/*.cs)
target_sources(scapix INTERFACE ${interface_sources})
endif()
foreach(bridge ${bridges})
if(NOT SCAPIX_BRIDGE STREQUAL bridge)
file(GLOB_RECURSE bridge_sources
${_SCAPIX_PATH}/source/scapix/link/${bridge}/*.*
${_SCAPIX_PATH}/source/scapix/bridge/${bridge}/*.*
)
set_source_files_properties(${bridge_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
endif()
endforeach()
if(SCAPIX_BRIDGE STREQUAL "objc")
target_compile_options(scapix PUBLIC "-fobjc-arc")
set_source_files_properties(${_SCAPIX_PATH}/source/scapix/bridge/objc/BridgeObject.mm PROPERTIES COMPILE_OPTIONS "-fno-objc-arc")
endif()
target_compile_features(scapix ${scapix_public} cxx_std_20)
# scapix looks at COMPILE_FEATURES, not CXX_STANDARD
get_target_property(scapix_cxx_standard scapix CXX_STANDARD)
get_target_property(scapix_cxx_standard_required scapix CXX_STANDARD_REQUIRED)
if(scapix_cxx_standard AND scapix_cxx_standard_required)
target_compile_features(scapix ${scapix_public} cxx_std_${scapix_cxx_standard})
endif()
target_include_directories(scapix ${scapix_public} ${_SCAPIX_PATH}/source)
target_compile_definitions(scapix ${scapix_public} SCAPIX_BRIDGE=${SCAPIX_BRIDGE} SCAPIX_BRIDGE_${SCAPIX_BRIDGE})
function(camel_case source target)
set(up true)
set(res "")
string(LENGTH ${source} source_length)
math(EXPR last_char_index "${source_length} - 1")
foreach(char_index RANGE ${last_char_index})
string(SUBSTRING "${source}" "${char_index}" "1" char)
if(char STREQUAL "_")
set(up true)
else()
if(up)
string(TOUPPER ${char} char)
set(up false)
endif()
string(APPEND res ${char})
endif()
endforeach()
set(${target} ${res} PARENT_SCOPE)
endfunction(camel_case)
function(scapix_bridge_headers target domain)
scapix_bridge(TARGET ${target} DOMAIN ${domain} HEADERS ${ARGN})
endfunction()
function(scapix_bridge)
cmake_parse_arguments(SCAPIX "" "TARGET;DOMAIN" "HEADERS;IMPORT_TARGETS" ${ARGN})
set(target ${SCAPIX_TARGET})
set(domain ${SCAPIX_DOMAIN})
set(bridge_headers ${SCAPIX_HEADERS})
if(SCAPIX_BRIDGE STREQUAL "cpp")
target_link_libraries(${target} PUBLIC scapix)
return()
endif()
string(REPLACE "." "/" domain_path ${domain})
foreach(import_target ${SCAPIX_IMPORT_TARGETS})
get_property(headers TARGET ${import_target} PROPERTY SCAPIX_BRIDGE_HEADERS)
list(APPEND bridge_headers ${headers})
endforeach()
# to do: remove duplication
set(PROJECT_ROOT ${CMAKE_SOURCE_DIR})
set(bridges
"cpp"
"java"
"objc"
"python"
"js"
"cs"
# "swift"
)
set_target_properties(${target} PROPERTIES SCAPIX_BRIDGE_HEADERS "${bridge_headers}")
# extract scapix_project_name from domain
string(FIND ${domain} "." scapix_domain_pos REVERSE)
math(EXPR scapix_domain_pos "${scapix_domain_pos}+1")
string(SUBSTRING ${domain} ${scapix_domain_pos} -1 scapix_project_name)
get_target_property(scapix_output_name ${target} OUTPUT_NAME)
if(NOT scapix_output_name)
set(scapix_output_name ${target})
endif()
if(XCODE)
# to do: could also generate objc-swift bridge header.
get_target_property(target_binary_dir ${target} BINARY_DIR)
get_target_property(scapix_binary_dir scapix BINARY_DIR)
file(WRITE
"${CMAKE_BINARY_DIR}/scapix_${target}.xcconfig"
"// Generated by Scapix Language Bridge\n"
"\n"
"HEADER_SEARCH_PATHS = $(inherited) \"${PROJECT_ROOT}/generated/bridge/objc\" \"${_SCAPIX_PATH}/source\"\n"
"OTHER_LDFLAGS = $(inherited) -l${scapix_output_name} -lscapix -lc++\n"
"LIBRARY_SEARCH_PATHS = $(inherited) \"${target_binary_dir}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\" \"${scapix_binary_dir}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"\n"
)
endif()
get_target_property(scapix_position_independent_code ${target} POSITION_INDEPENDENT_CODE)
set_target_properties(scapix PROPERTIES POSITION_INDEPENDENT_CODE ${scapix_position_independent_code})
if(SCAPIX_BRIDGE STREQUAL "java")
get_target_property(scapix_jni_dir scapix::jni SOURCE_DIR)
file(COPY "${scapix_jni_dir}/source/com" DESTINATION "${PROJECT_ROOT}/generated/bridge/java")
# This only works if target is defined in the same directory which calls scapix_bridge():
scapix_jni_source_group()
endif()
if(SCAPIX_BRIDGE STREQUAL "python")
set(PYBIND11_FINDPYTHON ON)
find_package(Pybind11 REQUIRED)
target_link_libraries(${target} PRIVATE pybind11::module)
set_target_properties(${target} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" SUFFIX "${PYTHON_MODULE_EXTENSION}")
endif()
target_link_libraries(${target} PUBLIC scapix)
get_target_property(interface_sources scapix INTERFACE_SOURCES)
if(interface_sources)
source_group(TREE ${_SCAPIX_PATH}/source/scapix PREFIX "scapix" FILES ${interface_sources})
endif()
# JVM on macOS looks for native libs with .dylib extension
if(APPLE AND SCAPIX_BRIDGE STREQUAL "java")
set_target_properties(${target} PROPERTIES SUFFIX ".dylib")
endif()
# generated_java_cpp
set(generated_java_cpp
"${PROJECT_ROOT}/generated/bridge/java/${scapix_project_name}.cpp"
)
file(REMOVE "${generated_java_cpp}")
file(APPEND "${generated_java_cpp}"
"// Generated by Scapix Language Bridge
#include <scapix/bridge/java/on_load.h>
#include <scapix/jni/module.h>
")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_java_cpp}" "void scapix_java_export_${name}();\n")
endforeach(filename)
file(APPEND "${generated_java_cpp}" "
jint scapix_JNI_OnLoad(JavaVM* vm, void* reserved)
{
\treturn scapix::jni::on_load(vm, reserved, []
\t{
")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_java_cpp}" "\t\tscapix_java_export_${name}();\n")
endforeach(filename)
file(APPEND "${generated_java_cpp}"
"\t});
}
#ifndef SCAPIX_CUSTOM_JNI_ONLOAD
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
\treturn scapix_JNI_OnLoad(vm, reserved);
}
#endif
")
set(generated_sources_java_private ${generated_java_cpp})
# generated_java_java
set(generated_java_java
"${PROJECT_ROOT}/generated/bridge/java/${domain_path}/ScapixConfig.java"
)
file(REMOVE "${generated_java_java}")
file(APPEND "${generated_java_java}"
"// Generated by Scapix Language Bridge
package ${domain};
public class ScapixConfig
{
public static void Init() {}
static { System.loadLibrary(\"${scapix_output_name}\"); }
}
")
set(generated_sources_java_interface ${generated_java_java})
# generated_python_cpp
set(generated_python_cpp
"${PROJECT_ROOT}/generated/bridge/python/${scapix_project_name}.cpp"
)
file(REMOVE "${generated_python_cpp}")
file(APPEND "${generated_python_cpp}"
"// Generated by Scapix Language Bridge
")
file(APPEND "${generated_python_cpp}" "#include <pybind11/pybind11.h>\n\n")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_python_cpp}" "void scapix_python_export_${name}(pybind11::module& m);\n")
endforeach(filename)
file(APPEND "${generated_python_cpp}" "
PYBIND11_MODULE(${scapix_output_name}, m)
{
m.doc() = \"${domain}\";
")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_python_cpp}" " scapix_python_export_${name}(m);\n")
endforeach(filename)
file(APPEND "${generated_python_cpp}" "}\n")
set(generated_sources_python_private ${generated_python_cpp})
# generated_cs_cpp
set(generated_cs_cpp
"${PROJECT_ROOT}/generated/bridge/cs/${scapix_project_name}.cpp"
)
file(REMOVE "${generated_cs_cpp}")
file(APPEND "${generated_cs_cpp}"
"// Generated by Scapix Language Bridge
#include <scapix/bridge/cs/init.h>
")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_cs_cpp}" "void scapix_cs_export_${name}();\n")
endforeach(filename)
file(APPEND "${generated_cs_cpp}" "
extern \"C\" SCAPIX_EXPORT
const scapix::link::cs::api::cpp_api* SCAPIX_CALL ScapixInit(const scapix::link::cs::api::cs_api* funcs)
{
auto ret = scapix::link::cs::api::init(funcs);
")
foreach(filename ${bridge_headers})
get_filename_component(name ${filename} NAME_WLE)
file(APPEND "${generated_cs_cpp}" " scapix_cs_export_${name}();\n")
endforeach(filename)
file(APPEND "${generated_cs_cpp}"
"
return ret;
}
")
set(generated_sources_cs_private ${generated_cs_cpp})
# generated_cs_cs
camel_case(${scapix_project_name} scapix_project_name_camel)
set(generated_cs_cs
"${PROJECT_ROOT}/generated/bridge/cs/${scapix_project_name_camel}.cs"
)
file(REMOVE "${generated_cs_cs}")
file(APPEND "${generated_cs_cs}"
"// Generated by Scapix Language Bridge
namespace ${scapix_project_name_camel} {
public static class ScapixConfig
{
[System.Runtime.InteropServices.DllImport(\"${scapix_output_name}\")]
static extern System.IntPtr ScapixInit(Scapix.Link.API.CsApi funcTable);
")
foreach(import_target ${SCAPIX_IMPORT_TARGETS})
get_target_property(import_target_output_name ${import_target} OUTPUT_NAME)
if(NOT import_target_output_name)
set(import_target_output_name ${import_target})
endif()
camel_case(${import_target_output_name} import_target_output_name_camel)
file(APPEND "${generated_cs_cs}"
"
[System.Runtime.InteropServices.DllImport(\"${import_target_output_name}\", EntryPoint = \"ScapixInit\")]
static extern System.IntPtr ${import_target_output_name_camel}Init(Scapix.Link.API.CsApi funcTable);
")
endforeach()
file(APPEND "${generated_cs_cs}"
"
static ScapixConfig() { Scapix.Link.API.Init(ScapixInit); ")
foreach(import_target ${SCAPIX_IMPORT_TARGETS})
get_target_property(import_target_output_name ${import_target} OUTPUT_NAME)
if(NOT import_target_output_name)
set(import_target_output_name ${import_target})
endif()
camel_case(${import_target_output_name} import_target_output_name_camel)
file(APPEND "${generated_cs_cs}"
"Scapix.Link.API.Init(${import_target_output_name_camel}Init); ")
endforeach()
file(APPEND "${generated_cs_cs}"
"}
public static void Init() {}
}
} // namespace ${scapix_project_name_camel}
")
set(generated_sources_cs_interface ${generated_cs_cs})
set(generated_sources_private)
set(generated_sources_interface)
foreach(bridge ${bridges})
list(APPEND generated_sources_private ${generated_sources_${bridge}_private})
list(APPEND generated_sources_interface ${generated_sources_${bridge}_interface})
set(generated_sources_${bridge} ${generated_sources_${bridge}_private} ${generated_sources_${bridge}_interface})
endforeach()
set(generated_sources
${generated_sources_private}
${generated_sources_interface}
)
set_source_files_properties(${generated_sources} PROPERTIES GENERATED TRUE)
#set_source_files_properties(${generated_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
#set_source_files_properties(${generated_sources_${SCAPIX_BRIDGE}} PROPERTIES HEADER_FILE_ONLY FALSE)
#target_sources(${target} PRIVATE ${generated_sources_private})
#target_sources(${target} INTERFACE ${generated_sources_interface})
target_sources(${target} PRIVATE ${generated_sources_${SCAPIX_BRIDGE}_private})
target_sources(${target} INTERFACE ${generated_sources_${SCAPIX_BRIDGE}_interface})
source_group(TREE ${PROJECT_ROOT}/generated PREFIX "generated" FILES ${generated_sources})
set(all_generated_sources)
foreach(bridge_header ${bridge_headers})
if(IS_ABSOLUTE bridge_header)
file(RELATIVE_PATH bridge_header_relative ${PROJECT_ROOT} ${bridge_header})
set(bridge_header_absolute ${bridge_header})
else()
set(bridge_header_relative ${bridge_header})
get_filename_component(bridge_header_absolute ${bridge_header} ABSOLUTE BASE_DIR ${PROJECT_ROOT})
endif()
get_filename_component(bridge_header_name ${bridge_header} NAME_WLE)
camel_case(${bridge_header_name} bridge_header_name_camel)
set(generated_sources_java_private
"${PROJECT_ROOT}/generated/bridge/java/${bridge_header_name}.cpp"
)
set(generated_sources_java_interface
"${PROJECT_ROOT}/generated/bridge/java/${domain_path}/${bridge_header_name_camel}.java"
)
set(generated_sources_objc_private
"${PROJECT_ROOT}/generated/bridge/objc/${scapix_project_name}/bridge/${bridge_header_name_camel}.h"
"${PROJECT_ROOT}/generated/bridge/objc/${scapix_project_name}/bridge/${bridge_header_name_camel}.mm"
)
set_source_files_properties("${PROJECT_ROOT}/generated/bridge/objc/${scapix_project_name}/bridge/${bridge_header_name_camel}.mm" PROPERTIES COMPILE_OPTIONS "-Wno-objc-designated-initializers")
set(generated_sources_python_private
"${PROJECT_ROOT}/generated/bridge/python/${bridge_header_name}.cpp"
)
set(generated_sources_js_private
"${PROJECT_ROOT}/generated/bridge/js/${bridge_header_name}.cpp"
)
set(generated_sources_cs_private
"${PROJECT_ROOT}/generated/bridge/cs/${bridge_header_name}.cpp"
)
set(generated_sources_cs_interface
"${PROJECT_ROOT}/generated/bridge/cs/${bridge_header_name_camel}.cs"
)
set(generated_sources_private)
set(generated_sources_interface)
foreach(bridge ${bridges})
list(APPEND generated_sources_private ${generated_sources_${bridge}_private})
list(APPEND generated_sources_interface ${generated_sources_${bridge}_interface})
set(generated_sources_${bridge} ${generated_sources_${bridge}_private} ${generated_sources_${bridge}_interface})
endforeach()
set(generated_sources
${generated_sources_private}
${generated_sources_interface}
)
# can add all generated_sources, but mark unused as HEADER_FILE_ONLY
#set_source_files_properties(${generated_sources} PROPERTIES HEADER_FILE_ONLY TRUE)
#set_source_files_properties(${generated_sources_${SCAPIX_BRIDGE}} PROPERTIES HEADER_FILE_ONLY FALSE)
#target_sources(${target} PRIVATE ${generated_sources_private})
#target_sources(${target} INTERFACE ${generated_sources_interface})
target_sources(${target} PRIVATE ${generated_sources_${SCAPIX_BRIDGE}_private})
target_sources(${target} INTERFACE ${generated_sources_${SCAPIX_BRIDGE}_interface})
source_group(TREE ${PROJECT_ROOT}/generated PREFIX "generated" FILES ${generated_sources})
set(scapix_clang_config)
if(MSVC)
list(APPEND scapix_clang_config -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH)
endif()
if(ANDROID)
list(APPEND scapix_clang_config -DANDROID -target ${ANDROID_LLVM_TRIPLE} --sysroot ${ANDROID_TOOLCHAIN_ROOT}/sysroot)
elseif(APPLE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND scapix_clang_config -arch arm64)
endif()
list(APPEND scapix_clang_config --sysroot ${CMAKE_OSX_SYSROOT})
elseif(EMSCRIPTEN)
list(APPEND scapix_clang_config -DEMSCRIPTEN -target wasm32-unknown-emscripten --sysroot ${EMSCRIPTEN_SYSROOT} -iwithsysroot /include/compat)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_TARGET)
list(APPEND scapix_clang_config -target ${CMAKE_CXX_COMPILER_TARGET})
endif()
list(APPEND scapix_clang_config -xc++)
list(APPEND scapix_clang_config -std=$<IF:$<IN_LIST:cxx_std_26,$<TARGET_PROPERTY:${target},COMPILE_FEATURES>>,c++26,$<IF:$<IN_LIST:cxx_std_23,$<TARGET_PROPERTY:${target},COMPILE_FEATURES>>,c++23,c++20>>)
list(APPEND scapix_clang_config $<LIST:TRANSFORM,$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>,PREPEND,-I>)
list(APPEND scapix_clang_config $<LIST:TRANSFORM,$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>,PREPEND,-D>)
add_custom_command(
OUTPUT ${generated_sources}
COMMAND ${SCAPIX_EXE} -scapix-domain=${domain} ${bridge_header_absolute} -- "${scapix_clang_config}"
MAIN_DEPENDENCY ${bridge_header_absolute}
IMPLICIT_DEPENDS CXX ${bridge_header_absolute}
DEPENDS ${SCAPIX_EXE}
WORKING_DIRECTORY ${PROJECT_ROOT}
COMMENT "Scapix Bridge: ${bridge_header_relative}"
COMMAND_EXPAND_LISTS
VERBATIM
)
list(APPEND all_generated_sources ${generated_sources})
endforeach(bridge_header)
# when add_library() and scapix_bridge_headers() are in different directories:
# add_custom_command: A target created in the same directory (CMakeLists.txt file) that specifies any output of the custom command as a source file is given a rule to generate the file using the command at build time.
add_custom_target(${target}_scapix_generated DEPENDS ${all_generated_sources})
add_dependencies(${target} ${target}_scapix_generated)
endfunction(scapix_bridge)
function(scapix_add_target target domain)
set(bridge_headers ${ARGN})
if(EMSCRIPTEN)
add_executable(${target})
target_link_options(${target} PRIVATE -lembind)
# target_link_options(${target} PRIVATE --emrun)
else()
if(SCAPIX_BRIDGE STREQUAL "java" OR SCAPIX_BRIDGE STREQUAL "python" OR SCAPIX_BRIDGE STREQUAL "cs")
set(LIBRARY_TYPE SHARED)
endif()
add_library(${target} ${LIBRARY_TYPE})
endif()
scapix_bridge_headers(${target} ${domain} ${bridge_headers})
endfunction(scapix_add_target)
# workaround for CMake's 'Source file properties are visible only to targets added in the same directory'
function(scapix_fix_sources target)
get_target_property(sources ${target} INTERFACE_SOURCES)
source_group(TREE ${CMAKE_SOURCE_DIR}/generated PREFIX "generated" FILES ${sources})
get_target_property(sources scapix INTERFACE_SOURCES)
if(sources)
source_group(TREE ${_SCAPIX_PATH}/source/scapix PREFIX "scapix" FILES ${sources})
endif()
endfunction()