Skip to content

Commit 5161129

Browse files
committed
CMake: Support COPY_TO_BIN in CMakelists
1 parent abcbc35 commit 5161129

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

integration_tests/CMakeLists.txt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ message("LPYTHON_RTLIB_DIR: ${LPYTHON_RTLIB_DIR}")
7676
message("LPYTHON_RTLIB_LIBRARY: ${LPYTHON_RTLIB_LIBRARY}")
7777

7878

79-
macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
79+
macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
8080
set(fail ${${RUN_FAIL}})
8181
set(name ${${RUN_NAME}})
8282
set(file_name ${${RUN_FILE_NAME}})
8383
set(labels ${${RUN_LABELS}})
8484
set(extra_files ${${RUN_EXTRAFILES}})
8585
set(extra_args ${${RUN_EXTRA_ARGS}})
86+
set(copy_to_bin ${${RUN_COPY_TO_BIN}})
8687

8788
if (NOT name)
8889
message(FATAL_ERROR "Must specify the NAME argument")
@@ -153,9 +154,6 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
153154
target_include_directories(${name} PRIVATE ${CMAKE_SOURCE_DIR} ${NUMPY_INCLUDE_DIR})
154155
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE C)
155156
target_link_libraries(${name} lpython_rtlib Python::Python)
156-
if (extra_files)
157-
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${extra_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
158-
endif()
159157
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
160158
if (labels)
161159
set_tests_properties(${name} PROPERTIES LABELS "${labels}")
@@ -281,12 +279,17 @@ macro(RUN_UTIL RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXT
281279
set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
282280
endif()
283281
endif()
282+
283+
if (copy_to_bin)
284+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${copy_to_bin} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
285+
endif()
286+
284287
endif()
285288
endmacro(RUN_UTIL)
286289

287290
macro(RUN)
288291
set(options FAIL NOFAST ENABLE_CPYTHON LINK_NUMPY)
289-
set(oneValueArgs NAME IMPORT_PATH)
292+
set(oneValueArgs NAME IMPORT_PATH COPY_TO_BIN)
290293
set(multiValueArgs LABELS EXTRAFILES)
291294
cmake_parse_arguments(RUN "${options}" "${oneValueArgs}"
292295
"${multiValueArgs}" ${ARGN} )
@@ -309,14 +312,14 @@ macro(RUN)
309312
endif()
310313

311314
if (NOT FAST)
312-
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
315+
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
313316
endif()
314317

315318
if ((FAST) AND (NOT RUN_NOFAST))
316319
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} --fast)
317320
set(RUN_NAME "${RUN_NAME}_FAST")
318321
list(REMOVE_ITEM RUN_LABELS cpython cpython_sym) # remove cpython, cpython_sym, from --fast test
319-
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS)
322+
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_EXTRA_ARGS RUN_COPY_TO_BIN)
320323
endif()
321324
endmacro(RUN)
322325

@@ -575,10 +578,10 @@ RUN(NAME bindc_05 LABELS llvm c
575578
EXTRAFILES bindc_05b.c)
576579
RUN(NAME bindc_06 LABELS llvm c
577580
EXTRAFILES bindc_06b.c)
578-
RUN(NAME bindpy_01 LABELS cpython c_py ENABLE_CPYTHON NOFAST EXTRAFILES bindpy_01_module.py)
579-
RUN(NAME bindpy_02 LABELS cpython c_py LINK_NUMPY EXTRAFILES bindpy_02_module.py)
580-
RUN(NAME bindpy_03 LABELS cpython c_py LINK_NUMPY NOFAST EXTRAFILES bindpy_03_module.py)
581-
RUN(NAME bindpy_04 LABELS cpython c_py LINK_NUMPY NOFAST EXTRAFILES bindpy_04_module.py)
581+
RUN(NAME bindpy_01 LABELS cpython c_py ENABLE_CPYTHON NOFAST COPY_TO_BIN bindpy_01_module.py)
582+
RUN(NAME bindpy_02 LABELS cpython c_py LINK_NUMPY COPY_TO_BIN bindpy_02_module.py)
583+
RUN(NAME bindpy_03 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_03_module.py)
584+
RUN(NAME bindpy_04 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_04_module.py)
582585
RUN(NAME test_generics_01 LABELS cpython llvm c NOFAST)
583586
RUN(NAME test_cmath LABELS cpython llvm c NOFAST)
584587
RUN(NAME test_complex_01 LABELS cpython llvm c wasm wasm_x64)

0 commit comments

Comments
 (0)