Skip to content

Commit d0211d3

Browse files
committed
Getting sick of freebsd
1 parent 0b41879 commit d0211d3

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎tests/CMakeLists.txt‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ endif()
6363

6464
add_test(NAME tests COMMAND tests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
6565
target_link_libraries(tests PRIVATE ${PROJECT_NAME} GTest::gtest_main)
66-
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
67-
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
68-
find_library(ICONV_LIBRARY NAMES iconv PATHS /usr/local/lib NO_DEFAULT_PATH)
69-
find_path(ICONV_INCLUDE_DIR NAMES iconv.h PATHS /usr/local/include NO_DEFAULT_PATH)
70-
71-
target_include_directories(tests PRIVATE ${ICONV_INCLUDE_DIR})
72-
target_link_libraries(tests PRIVATE ${ICONV_LIBRARY})
73-
else()
74-
find_package(Iconv REQUIRED)
75-
target_include_directories(tests PRIVATE ${Iconv_INCLUDE_DIRS})
76-
target_link_libraries(tests PRIVATE ${Iconv_LIBRARIES})
66+
if(NOT SIMPLEINI_USE_SYSTEM_GTEST)
67+
# Bundled GTest must win over a system install (e.g. FreeBSD ports in /usr/local/include).
68+
get_target_property(_gtest_include_dirs GTest::gtest INTERFACE_INCLUDE_DIRECTORIES)
69+
if(_gtest_include_dirs)
70+
target_include_directories(tests BEFORE PRIVATE ${_gtest_include_dirs})
7771
endif()
7872
endif()
73+
if(APPLE)
74+
find_package(Iconv REQUIRED)
75+
target_include_directories(tests PRIVATE ${Iconv_INCLUDE_DIRS})
76+
target_link_libraries(tests PRIVATE ${Iconv_LIBRARIES})
77+
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
78+
# Use libc iconv. Avoid /usr/local/include: pkg's GNU libiconv and googletest
79+
# headers would otherwise shadow the bundled GTest includes above.
80+
target_include_directories(tests BEFORE PRIVATE /usr/include)
81+
endif()
7982

8083
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
8184
target_link_options(tests PRIVATE "-Wl,--wrap=malloc")

0 commit comments

Comments
 (0)