@@ -36,6 +36,15 @@ set_property(TARGET lpython_rtlib PROPERTY INTERFACE_LINK_LIBRARIES
36
36
${LPYTHON_RTLIB_LIBRARY} )
37
37
target_link_libraries (lpython_rtlib INTERFACE m)
38
38
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
+
39
48
enable_testing ()
40
49
41
50
message ("\n " )
@@ -57,7 +66,7 @@ message("LPYTHON_RTLIB_LIBRARY: ${LPYTHON_RTLIB_LIBRARY}")
57
66
58
67
59
68
macro (RUN)
60
- set (options FAIL)
69
+ set (options FAIL ENABLE_CPYTHON )
61
70
set (oneValueArgs NAME IMPORT_PATH)
62
71
set (multiValueArgs LABELS EXTRAFILES)
63
72
cmake_parse_arguments (RUN "${options} " "${oneValueArgs} "
@@ -68,6 +77,11 @@ macro(RUN)
68
77
message (FATAL_ERROR "Must specify the NAME argument" )
69
78
endif ()
70
79
80
+ set (enable_cpython "" )
81
+ if (${RUN_ENABLE_CPYTHON} )
82
+ set (enable_cpython "--enable-cpython" )
83
+ endif ()
84
+
71
85
if (${KIND} IN_LIST RUN_LABELS)
72
86
if (KIND STREQUAL "llvm" )
73
87
if (import_path)
@@ -97,13 +111,13 @@ macro(RUN)
97
111
if (import_path)
98
112
add_custom_command (
99
113
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
101
115
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${name} .py
102
116
VERBATIM )
103
117
else ()
104
118
add_custom_command (
105
119
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
107
121
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${name} .py
108
122
VERBATIM )
109
123
endif ()
@@ -112,6 +126,12 @@ macro(RUN)
112
126
target_include_directories (${name} PRIVATE ${CMAKE_SOURCE_DIR} )
113
127
set_target_properties (${name} PROPERTIES LINKER_LANGUAGE C)
114
128
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 ()
115
135
add_test (${name} ${CMAKE_CURRENT_BINARY_DIR} /${name} )
116
136
if (RUN_LABELS)
117
137
set_tests_properties (${name} PROPERTIES LABELS "${RUN_LABELS} " )
0 commit comments