Skip to content

Commit f1c66b4

Browse files
committed
Updated FindGMP
1 parent b913416 commit f1c66b4

File tree

3 files changed

+84
-43
lines changed

3 files changed

+84
-43
lines changed

CMakeLists.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ target_link_libraries(tight_inclusion PRIVATE warnings::all)
5050
#Optional
5151
#GMP
5252
if(TIGHT_INCLUSION_WITH_GMP)
53-
message(STATUS "TIGHT_INCLUSION_WITH_GMP is defined, now using rational root finder")
54-
target_include_directories(tight_inclusion PUBLIC ${GMP_INCLUDE_DIRS} src)
55-
target_link_libraries(tight_inclusion PUBLIC ${GMP_LIBRARIES})
53+
message(STATUS "TIGHT_INCLUSION_WITH_GMP is defined, now using rational root finder")
54+
target_link_libraries(tight_inclusion PUBLIC gmp::gmp)
5655
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_USE_GMP)
5756
endif()
5857

@@ -74,7 +73,7 @@ if (TIGHT_INCLUSION_WITH_DOUBLE_PRECISION)
7473
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_DOUBLE)
7574
message(STATUS "Using Double Precision Floating Points")
7675
else()
77-
message(STATUS "Using Single Precision Floating Points")
76+
message(STATUS "Using Single Precision Floating Points")
7877
endif()
7978
if(TIGHT_INCLUSION_LIMIT_QUEUE_SIZE)
8079
target_compile_definitions(tight_inclusion PUBLIC TI_LIMIT_QUEUE_SIZE)
@@ -103,10 +102,9 @@ if(TIGHT_INCLUSION_TOPLEVEL_PROJECT)
103102
ticcd_download_sample_queries()
104103

105104
if (NOT TIGHT_INCLUSION_WITH_GMP AND TIGHT_INCLUSION_WITH_TESTS)
106-
target_include_directories(tight_inclusion PUBLIC ${GMP_INCLUDE_DIRS} src)
107-
target_link_libraries(tight_inclusion PUBLIC ${GMP_LIBRARIES})
105+
target_link_libraries(tight_inclusion PUBLIC gmp::gmp)
108106
target_compile_definitions(tight_inclusion PUBLIC TIGHT_INCLUSION_RUN_EXAMPLES)
109107
target_compile_definitions(Tight_Inclusion_bin PUBLIC
110-
TICCD_EXAMPLE_QUERIES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/external/Sample-Queries/")
108+
TICCD_EXAMPLE_QUERIES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/external/Sample-Queries/")
111109
endif()
112110
endif()

cmake/FindGMP.cmake

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Try to find the GNU Multiple Precision Arithmetic Library (GMP)
2+
# See http://gmplib.org/
3+
4+
find_path(GMP_INCLUDES
5+
NAMES
6+
gmp.h
7+
PATHS
8+
ENV GMP_DIR
9+
${GMP_WINDOWS_PATH}
10+
${INCLUDE_INSTALL_DIR}
11+
PATH_SUFFIXES
12+
include
13+
)
14+
15+
find_library(GMP_LIBRARIES
16+
NAMES
17+
gmp
18+
libgmp
19+
PATHS
20+
ENV GMP_DIR
21+
${GMP_WINDOWS_PATH}
22+
${LIB_INSTALL_DIR}
23+
PATH_SUFFIXES
24+
lib
25+
)
26+
27+
set(GMP_EXTRA_VARS "")
28+
if(WIN32)
29+
# Find dll file and set IMPORTED_LOCATION to the .dll file
30+
find_file(GMP_RUNTIME_LIB
31+
NAMES
32+
gmp.dll
33+
libgmp-10.dll
34+
PATHS
35+
ENV GMP_DIR
36+
${GMP_WINDOWS_PATH}
37+
${LIB_INSTALL_DIR}
38+
PATH_SUFFIXES
39+
lib
40+
)
41+
list(APPEND GMP_EXTRA_VARS GMP_RUNTIME_LIB)
42+
endif()
43+
44+
include(FindPackageHandleStandardArgs)
45+
find_package_handle_standard_args(GMP
46+
REQUIRED_VARS
47+
GMP_INCLUDES
48+
GMP_LIBRARIES
49+
${GMP_EXTRA_VARS}
50+
REASON_FAILURE_MESSAGE
51+
"GMP is not installed on your system. Install GMP using your preferred package manager."
52+
)
53+
mark_as_advanced(GMP_INCLUDES GMP_LIBRARIES)
54+
55+
if(GMP_INCLUDES AND GMP_LIBRARIES AND NOT TARGET gmp::gmp)
56+
if(GMP_RUNTIME_LIB)
57+
add_library(gmp::gmp SHARED IMPORTED)
58+
else()
59+
add_library(gmp::gmp UNKNOWN IMPORTED)
60+
endif()
61+
62+
# Set public header location and link language
63+
set_target_properties(gmp::gmp PROPERTIES
64+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
65+
INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDES}"
66+
)
67+
68+
# Set lib location. On Windows we specify both the .lib and the .dll paths
69+
if(GMP_RUNTIME_LIB)
70+
set_target_properties(gmp::gmp PROPERTIES
71+
IMPORTED_IMPLIB "${GMP_LIBRARIES}"
72+
IMPORTED_LOCATION "${GMP_RUNTIME_LIB}"
73+
)
74+
else()
75+
set_target_properties(gmp::gmp PROPERTIES
76+
IMPORTED_LOCATION "${GMP_LIBRARIES}"
77+
)
78+
endif()
79+
endif()

cmake/FindGMPECCD.cmake

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)