Skip to content

Commit c7300b5

Browse files
moved finding the gd lib to separate module
1 parent 3f88640 commit c7300b5

3 files changed

Lines changed: 46 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,20 @@ include(UseCython)
1515

1616
# FetchContent_MakeAvailable(gd)
1717

18-
find_library (libgd
19-
gd
20-
REQUIRED
21-
)
22-
message (STATUS "libgd found at ${libgd}")
18+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake"
19+
)
2320

24-
find_path (gd_include_path
25-
"gd.h"
26-
REQUIRED)
27-
28-
message (STATUS "gd.h found at ${gd_include_path}")
21+
find_package(GD
22+
MODULE
23+
REQUIRED
24+
)
2925

3026
cython_transpile(py_gd/py_gd.pyx
3127
LANGUAGE C
3228
OUTPUT_VARIABLE py_gd_c)
3329

3430
python_add_library(py_gd MODULE "${py_gd_c}" WITH_SOABI)
35-
target_link_libraries(py_gd PUBLIC "${libgd}" Python::NumPy)
36-
target_include_directories(py_gd PUBLIC "${gd_include_path}")
31+
target_link_libraries(py_gd PUBLIC GD::GD Python::NumPy)
3732
install(TARGETS py_gd DESTINATION py_gd)
3833

3934

cmake/FindGD.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
find_path (GD_INCLUDE_DIR
3+
"gd.h"
4+
REQUIRED)
5+
6+
find_library (GD_LIBRARY
7+
gd
8+
REQUIRED
9+
)
10+
11+
message (STATUS "libgd found at ${GD_LIBRARY}, ${GD_INCLUDE_DIR}")
12+
13+
include(FindPackageHandleStandardArgs)
14+
find_package_handle_standard_args(GD
15+
REQUIRED_VARS
16+
GD_LIBRARY
17+
GD_INCLUDE_DIR
18+
VERSION_VAR GD_VERSION
19+
)
20+
21+
if(GD_FOUND)
22+
set(GD_LIBRARIES "${GD_LIBRARY}")
23+
set(GD_INCLUDE_DIRS "${GD_INCLUDE_DIR}")
24+
endif()
25+
26+
if(GD_FOUND AND NOT TARGET GD::GD)
27+
add_library(GD::GD UNKNOWN IMPORTED)
28+
set_target_properties(GD::GD PROPERTIES
29+
IMPORTED_LOCATION "${GD_LIBRARY}"
30+
INTERFACE_INCLUDE_DIRECTORIES "${GD_INCLUDE_DIR}"
31+
)
32+
endif()
33+
34+
mark_as_advanced(
35+
GD_INCLUDE_DIR
36+
GD_LIBRARY
37+
)
38+

py_gd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414
import os
1515

16-
__version__ = "2.3.2"
16+
__version__ = "2.3.3"
1717

1818
if sys.platform.startswith('win'):
1919
# This only works for Anaconda / miniconda

0 commit comments

Comments
 (0)