Skip to content

Commit e535721

Browse files
committed
Make iconv test more strict
Since some systems (FreeBSD) use macro magic to chose between iconv library (GNU vs. internal) versions, including iconv.h is crucial here. This fixed build on FreeBSD 10+ with libiconv installed from ports.
1 parent 12525a6 commit e535721

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

cmake/FindIconv.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ FIND_PATH(ICONV_INCLUDE_DIR NAMES iconv.h)
1111

1212
# Check if library is needed
1313
IF(ICONV_INCLUDE_DIR)
14-
INCLUDE(CheckFunctionExists)
15-
1614
SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
17-
CHECK_FUNCTION_EXISTS(iconv ICONV_LIBRARY_NOT_NEEDED)
15+
TRY_COMPILE(ICONV_LIBRARY_NOT_NEEDED
16+
${CMAKE_BINARY_DIR}
17+
${CMAKE_MODULE_PATH}/iconv_test.c
18+
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${ICONV_INCLUDE_DIR}"
19+
)
1820

1921
IF(NOT ICONV_LIBRARY_NOT_NEEDED)
2022
# Locate library

cmake/iconv_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <iconv.h>
2+
3+
int main() {
4+
iconv_open("", "");
5+
return 0;
6+
}

0 commit comments

Comments
 (0)