1- cmake_minimum_required (VERSION 3.15 )
1+ cmake_minimum_required (VERSION 3.21 )
22project (${SKBUILD_PROJECT_NAME} LANGUAGES C )
33
4+ # Define source directory
5+ set (convertbng_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng" )
6+
47# Find Python
58find_package (
69 Python
710 COMPONENTS Interpreter Development.Module NumPy
811 REQUIRED )
12+ include (UseCython )
913
1014# Get NumPy include directory
1115message (STATUS "NumPy include directory: ${Python_NumPy_INCLUDE_DIRS} " )
1216
13- # Cythonize the .pyx file to .c
14- add_custom_command (
15- OUTPUT cutil.c
16- COMMENT "Cythonizing ${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng/cutil.pyx"
17- COMMAND Python::Interpreter -m cython
18- "${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng/cutil.pyx"
19- --output-file cutil.c
20- -I "${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng"
21- DEPENDS src/convertbng/cutil.pyx src/convertbng/convertbng_p.pxd
22- VERBATIM )
17+ cython_transpile (
18+ "${convertbng_SRC_DIR} /cutil.pyx"
19+ LANGUAGE C
20+ OUTPUT_VARIABLE cutil
21+ CYTHON_ARGS -I "${convertbng_SRC_DIR} "
22+ )
2323
2424# Create the extension module
25- python_add_library (cutil MODULE cutil.c WITH_SOABI )
25+ python_add_library (cutil MODULE " ${ cutil} " WITH_SOABI )
2626
2727# Set include directories
2828target_include_directories (cutil PRIVATE
29- ${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng
29+ ${convertbng_SRC_DIR}
3030 ${Python_NumPy_INCLUDE_DIRS}
3131)
3232
3333# Link against the Rust library
3434# The library is pre-built and located in src/convertbng/
3535find_library (LONLAT_BNG_LIBRARY
3636 NAMES lonlat_bng liblonlat_bng
37- PATHS ${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng
37+ PATHS ${convertbng_SRC_DIR}
3838 NO_DEFAULT_PATH
3939 REQUIRED
4040)
@@ -60,16 +60,16 @@ install(TARGETS cutil DESTINATION convertbng)
6060
6161# Install the shared library
6262if (APPLE )
63- set (RDP_LIB_NAME "liblonlat_bng.dylib" )
63+ set (LONLAT_BNG_LIB_NAME "liblonlat_bng.dylib" )
6464elseif (UNIX )
65- set (RDP_LIB_NAME "liblonlat_bng.so" )
65+ set (LONLAT_BNG_LIB_NAME "liblonlat_bng.so" )
6666elseif (WIN32 )
67- set (RDP_LIB_NAME "lonlat_bng.dll" )
67+ set (LONLAT_BNG_LIB_NAME "lonlat_bng.dll" )
6868endif ()
6969
70- install (FILES ${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng/ ${RDP_LIB_NAME }
70+ install (FILES ${convertbng_SRC_DIR} / ${LONLAT_BNG_LIB_NAME }
7171 DESTINATION convertbng)
7272
7373# Install header file
74- install (FILES ${CMAKE_CURRENT_SOURCE_DIR } /src/convertbng /header.h
74+ install (FILES ${convertbng_SRC_DIR} /header.h
7575 DESTINATION convertbng)
0 commit comments