| 1 |
set( |
| 2 |
UCHARDET_SOURCES |
| 3 |
uchardet.cpp |
| 4 |
) |
| 5 |
|
| 6 |
include(CheckSymbolExists) |
| 7 |
|
| 8 |
check_symbol_exists(getopt_long "getopt.h" HAVE_GETOPT_LONG) |
| 9 |
|
| 10 |
# On Windows with MSVC, `getopt_long` is not available by default. |
| 11 |
# But some third-party libraries can be used. For example, in `vcpkg`, |
| 12 |
# we can find a port named `getopt-win32`. |
| 13 |
if (NOT HAVE_GETOPT_LONG) |
| 14 |
find_path(GETOPT_INCLUDE_DIR NAMES getopt.h) |
| 15 |
find_library(GETOPT_LIBRARY NAMES getopt) |
| 16 |
endif (NOT HAVE_GETOPT_LONG) |
| 17 |
|
| 18 |
set(UCHARDET_BINARY uchardet) |
| 19 |
|
| 20 |
add_executable( |
| 21 |
${UCHARDET_BINARY} |
| 22 |
${UCHARDET_SOURCES} |
| 23 |
) |
| 24 |
|
| 25 |
if (GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY) |
| 26 |
target_include_directories(${UCHARDET_BINARY} PRIVATE ${GETOPT_INCLUDE_DIR}) |
| 27 |
target_link_libraries(${UCHARDET_BINARY} PRIVATE ${GETOPT_LIBRARY}) |
| 28 |
endif (GETOPT_INCLUDE_DIR AND GETOPT_LIBRARY) |
| 29 |
|
| 30 |
target_link_libraries( |
| 31 |
${UCHARDET_BINARY} |
| 32 |
${UCHARDET_LIBRARY} |
| 33 |
) |
| 34 |
|
| 35 |
install( |
| 36 |
TARGETS |
| 37 |
${UCHARDET_BINARY} |
| 38 |
EXPORT |
| 39 |
UchardetTargets |
| 40 |
RUNTIME DESTINATION |
| 41 |
${CMAKE_INSTALL_BINDIR} |
| 42 |
) |