Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
da02ebe3
Commit
da02ebe3
authored
Dec 02, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1978 from libgit2/rb/cmake-find-iconv
Improve iconv finding for cmake
parents
14984af6
726b75d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
+58
-7
CMakeLists.txt
+16
-7
cmake/Modules/FindIconv.cmake
+42
-0
No files found.
CMakeLists.txt
View file @
da02ebe3
...
...
@@ -34,7 +34,7 @@ OPTION( ANDROID "Build for android NDK" OFF )
OPTION
(
USE_ICONV
"Link with and use iconv library"
OFF
)
OPTION
(
USE_SSH
"Link with libssh to enable SSH support"
ON
)
IF
(
APPLE
)
IF
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Darwin"
)
SET
(
USE_ICONV ON
)
ENDIF
()
...
...
@@ -82,12 +82,6 @@ FUNCTION(TARGET_OS_LIBRARIES target)
SET
(
LIBGIT2_PC_LIBS
"
${
LIBGIT2_PC_LIBS
}
-lrt"
PARENT_SCOPE
)
ENDIF
()
IF
(
USE_ICONV
)
TARGET_LINK_LIBRARIES
(
${
target
}
iconv
)
ADD_DEFINITIONS
(
-DGIT_USE_ICONV
)
SET
(
LIBGIT2_PC_LIBS
"
${
LIBGIT2_PC_LIBS
}
-liconv"
PARENT_SCOPE
)
ENDIF
()
IF
(
THREADSAFE
)
TARGET_LINK_LIBRARIES
(
${
target
}
${
CMAKE_THREAD_LIBS_INIT
}
)
ENDIF
()
...
...
@@ -190,6 +184,7 @@ ELSE()
FILE
(
GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h
)
ENDIF
()
# Optional external dependency: libssh2
IF
(
USE_SSH AND NOT MINGW
)
FIND_PACKAGE
(
LIBSSH2 QUIET
)
ENDIF
()
...
...
@@ -200,6 +195,18 @@ IF (LIBSSH2_FOUND)
SET
(
SSH_LIBRARIES
${
LIBSSH2_LIBRARIES
}
)
ENDIF
()
# Optional external dependency: iconv
IF
(
USE_ICONV
)
FIND_PACKAGE
(
ICONV QUIET
)
ENDIF
()
IF
(
ICONV_FOUND
)
ADD_DEFINITIONS
(
-DGIT_USE_ICONV
)
IF
(
ICONV_LIBRARIES MATCHES
"libiconv"
)
SET
(
LIBGIT2_PC_LIBS
"
${
LIBGIT2_PC_LIBS
}
-liconv"
)
ELSE
()
SET
(
LIBGIT2_PC_REQUIRES
"
${
LIBGIT2_PC_REQUIRES
}
iconv"
)
ENDIF
()
ENDIF
()
# Platform specific compilation flags
IF
(
MSVC
)
...
...
@@ -353,6 +360,7 @@ ENDIF()
ADD_LIBRARY
(
git2
${
SRC_H
}
${
SRC_GIT2
}
${
SRC_OS
}
${
SRC_ZLIB
}
${
SRC_HTTP
}
${
SRC_REGEX
}
${
SRC_SHA1
}
${
WIN_RC
}
)
TARGET_LINK_LIBRARIES
(
git2
${
SSL_LIBRARIES
}
)
TARGET_LINK_LIBRARIES
(
git2
${
SSH_LIBRARIES
}
)
TARGET_LINK_LIBRARIES
(
git2
${
ICONV_LIBRARIES
}
)
TARGET_OS_LIBRARIES
(
git2
)
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
...
...
@@ -418,6 +426,7 @@ IF (BUILD_CLAR)
TARGET_LINK_LIBRARIES(libgit2_clar
${
SSL_LIBRARIES
}
)
TARGET_LINK_LIBRARIES(libgit2_clar
${
SSH_LIBRARIES
}
)
TARGET_LINK_LIBRARIES(libgit2_clar
${
ICONV_LIBRARIES
}
)
TARGET_OS_LIBRARIES(libgit2_clar)
MSVC_SPLIT_SOURCES(libgit2_clar)
...
...
cmake/Modules/FindIconv.cmake
0 → 100644
View file @
da02ebe3
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
IF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
# Already in cache, be silent
SET
(
ICONV_FIND_QUIETLY TRUE
)
ENDIF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
FIND_PATH
(
ICONV_INCLUDE_DIR iconv.h
)
FIND_LIBRARY
(
ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c PATH
)
IF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
SET
(
ICONV_FOUND TRUE
)
ENDIF
(
ICONV_INCLUDE_DIR AND ICONV_LIBRARIES
)
set
(
CMAKE_REQUIRED_INCLUDES
${
ICONV_INCLUDE_DIR
}
)
set
(
CMAKE_REQUIRED_LIBRARIES
${
ICONV_LIBRARIES
}
)
set
(
CMAKE_REQUIRED_INCLUDES
)
set
(
CMAKE_REQUIRED_LIBRARIES
)
IF
(
ICONV_FOUND
)
IF
(
NOT ICONV_FIND_QUIETLY
)
MESSAGE
(
STATUS
"Found Iconv:
${
ICONV_LIBRARIES
}
"
)
ENDIF
(
NOT ICONV_FIND_QUIETLY
)
ELSE
(
ICONV_FOUND
)
IF
(
Iconv_FIND_REQUIRED
)
MESSAGE
(
FATAL_ERROR
"Could not find Iconv"
)
ENDIF
(
Iconv_FIND_REQUIRED
)
ENDIF
(
ICONV_FOUND
)
MARK_AS_ADVANCED
(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment