Skip to content

Commit b637e27

Browse files
committed
TEST: Support ENABLE_CPYTHON in integration_tests
1 parent 2d0a738 commit b637e27

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

integration_tests/CMakeLists.txt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ set_property(TARGET lpython_rtlib PROPERTY INTERFACE_LINK_LIBRARIES
3636
${LPYTHON_RTLIB_LIBRARY})
3737
target_link_libraries(lpython_rtlib INTERFACE m)
3838

39+
find_package(Python COMPONENTS Development)
40+
message("\n")
41+
message("System has the Python development artifacts: ${Python_Development_FOUND}")
42+
message("The Python include directories: ${Python_INCLUDE_DIRS}")
43+
message("The Python libraries: ${Python_LIBRARIES}")
44+
message("The Python library directories: ${Python_LIBRARY_DIRS}")
45+
message("The Python runtime library directories: ${Python_RUNTIME_LIBRARY_DIRS}")
46+
message("Python version: ${Python_VERSION}")
47+
3948
enable_testing()
4049

4150
message("\n")
@@ -57,7 +66,7 @@ message("LPYTHON_RTLIB_LIBRARY: ${LPYTHON_RTLIB_LIBRARY}")
5766

5867

5968
macro(RUN)
60-
set(options FAIL)
69+
set(options FAIL ENABLE_CPYTHON)
6170
set(oneValueArgs NAME IMPORT_PATH)
6271
set(multiValueArgs LABELS EXTRAFILES)
6372
cmake_parse_arguments(RUN "${options}" "${oneValueArgs}"
@@ -68,6 +77,11 @@ macro(RUN)
6877
message(FATAL_ERROR "Must specify the NAME argument")
6978
endif()
7079

80+
set(enable_cpython "")
81+
if (${RUN_ENABLE_CPYTHON})
82+
set(enable_cpython "--enable-cpython")
83+
endif()
84+
7185
if (${KIND} IN_LIST RUN_LABELS)
7286
if (KIND STREQUAL "llvm")
7387
if (import_path)
@@ -97,13 +111,13 @@ macro(RUN)
97111
if (import_path)
98112
add_custom_command(
99113
OUTPUT ${name}.c
100-
COMMAND ${LPYTHON} -I ${CMAKE_CURRENT_SOURCE_DIR}/${import_path} --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c
114+
COMMAND ${LPYTHON} ${enable_cpython} -I ${CMAKE_CURRENT_SOURCE_DIR}/${import_path} --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c
101115
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py
102116
VERBATIM)
103117
else ()
104118
add_custom_command(
105119
OUTPUT ${name}.c
106-
COMMAND ${LPYTHON} --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c
120+
COMMAND ${LPYTHON} ${enable_cpython} --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py > ${name}.c
107121
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py
108122
VERBATIM)
109123
endif()
@@ -112,6 +126,12 @@ macro(RUN)
112126
target_include_directories(${name} PRIVATE ${CMAKE_SOURCE_DIR})
113127
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE C)
114128
target_link_libraries(${name} lpython_rtlib)
129+
if (${RUN_ENABLE_CPYTHON})
130+
target_link_libraries(${name} Python::Python)
131+
if (RUN_EXTRAFILES)
132+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${RUN_EXTRAFILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
133+
endif()
134+
endif()
115135
add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name})
116136
if (RUN_LABELS)
117137
set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}")

0 commit comments

Comments
 (0)