Skip to content

Commit 7a2979c

Browse files
committed
Fixed linker errors in OSX under macports
1. Added cmake module to find ICU 2. Added link instructions to include icu libs 3. mime roundtrip tests doesn't need to be linked with boost libs. It throws multiple defn errors. Fixed.
1 parent 5be546f commit 7a2979c

File tree

6 files changed

+106
-3
lines changed

6 files changed

+106
-3
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
*.cmake
21
*.swp
32
*.pyc
43
CMakeCache.txt

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
cmake_minimum_required(VERSION 2.8)
88
project(CPP-NETLIB)
9+
10+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
11+
find_package( ICU )
12+
913
set(Boost_USE_STATIC_LIBS ON)
1014
set(Boost_USE_MULTITHREADED ON)
1115
find_package( Boost 1.45.0 REQUIRED unit_test_framework system regex date_time thread chrono filesystem program_options )

FindICU.cmake

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Finds the International Components for Unicode (ICU) Library
2+
#
3+
# ICU_FOUND - True if ICU found.
4+
# ICU_I18N_FOUND - True if ICU's internationalization library found.
5+
# ICU_INCLUDE_DIRS - Directory to include to get ICU headers
6+
# Note: always include ICU headers as, e.g.,
7+
# unicode/utypes.h
8+
# ICU_LIBRARIES - Libraries to link against for the common ICU
9+
# ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation
10+
# (note: in addition to ICU_LIBRARIES)
11+
12+
# Look for the header file.
13+
find_path(
14+
ICU_INCLUDE_DIR
15+
NAMES unicode/utypes.h
16+
DOC "Include directory for the ICU library")
17+
mark_as_advanced(ICU_INCLUDE_DIR)
18+
19+
# Look for the library.
20+
find_library(
21+
ICU_LIBRARY
22+
NAMES icuuc cygicuuc cygicuuc32
23+
DOC "Libraries to link against for the common parts of ICU")
24+
mark_as_advanced(ICU_LIBRARY)
25+
26+
# Copy the results to the output variables.
27+
if(ICU_INCLUDE_DIR AND ICU_LIBRARY)
28+
set(ICU_FOUND 1)
29+
set(ICU_LIBRARIES ${ICU_LIBRARY})
30+
set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
31+
32+
set(ICU_VERSION 0)
33+
set(ICU_MAJOR_VERSION 0)
34+
set(ICU_MINOR_VERSION 0)
35+
if (EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h")
36+
FILE(READ "${ICU_INCLUDE_DIR}/unicode/uvernum.h" _ICU_VERSION_CONENTS)
37+
else()
38+
FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS)
39+
endif()
40+
41+
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
42+
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
43+
44+
set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
45+
46+
# Look for the ICU internationalization libraries
47+
find_library(
48+
ICU_I18N_LIBRARY
49+
NAMES icuin icui18n cygicuin cygicuin32
50+
DOC "Libraries to link against for ICU internationalization")
51+
mark_as_advanced(ICU_I18N_LIBRARY)
52+
if (ICU_I18N_LIBRARY)
53+
set(ICU_I18N_FOUND 1)
54+
set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
55+
else (ICU_I18N_LIBRARY)
56+
set(ICU_I18N_FOUND 0)
57+
set(ICU_I18N_LIBRARIES)
58+
endif (ICU_I18N_LIBRARY)
59+
60+
# Look for the ICU data libraries
61+
find_library(
62+
ICU_DATA_LIBRARY
63+
NAMES icudata cygicudata cygicudata32
64+
DOC "Libraries to link against for ICU data")
65+
mark_as_advanced(ICU_DATA_LIBRARY)
66+
if (ICU_DATA_LIBRARY)
67+
set(ICU_DATA_FOUND 1)
68+
set(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY})
69+
else (ICU_DATA_LIBRARY)
70+
set(ICU_DATA_FOUND 0)
71+
set(ICU_DATA_LIBRARIES)
72+
endif (ICU_DATA_LIBRARY)
73+
else(ICU_INCLUDE_DIR AND ICU_LIBRARY)
74+
set(ICU_FOUND 0)
75+
set(ICU_I18N_FOUND 0)
76+
set(ICU_DATA_FOUND 0)
77+
set(ICU_LIBRARIES)
78+
set(ICU_I18N_LIBRARIES)
79+
set(ICU_DATA_LIBRARIES)
80+
set(ICU_INCLUDE_DIRS)
81+
set(ICU_VERSION)
82+
set(ICU_MAJOR_VERSION)
83+
set(ICU_MINOR_VERSION)
84+
endif(ICU_INCLUDE_DIR AND ICU_LIBRARY)
85+
86+
IF(ICU_FOUND)
87+
IF( NOT ICU_FIND_QUIETLY )
88+
MESSAGE( STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
89+
MESSAGE( STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
90+
ENDIF( NOT ICU_FIND_QUIETLY )
91+
ELSE(ICU_FOUND)
92+
IF(ICU_FIND_REQUIRED)
93+
MESSAGE( FATAL_ERROR "Could not find ICU" )
94+
ELSE(ICU_FIND_REQUIRED)
95+
MESSAGE( STATUS "Optional package ICU was not found" )
96+
ENDIF(ICU_FIND_REQUIRED)
97+
ENDIF(ICU_FOUND)

libs/mime/test/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set ( Boost_USE_MULTITHREADED ON )
55

66
if ( Boost_FOUND )
77
add_executable ( mime-roundtrip mime-roundtrip.cpp )
8-
target_link_libraries ( mime-roundtrip ${Boost_LIBRARIES} )
8+
target_link_libraries ( mime-roundtrip )
99
add_test ( mime-roundtrip mime-roundtrip )
1010
endif ()
1111

libs/network/test/http/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ if (Boost_FOUND)
3636
)
3737
target_link_libraries(cpp-netlib-http-${test}
3838
${Boost_LIBRARIES}
39+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
3940
${CMAKE_THREAD_LIBS_INIT}
4041
cppnetlib-message
4142
cppnetlib-message-wrappers
@@ -65,6 +66,7 @@ if (Boost_FOUND)
6566
add_executable(cpp-netlib-http-${test} ${test}.cpp)
6667
target_link_libraries(cpp-netlib-http-${test}
6768
${Boost_LIBRARIES}
69+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
6870
${CMAKE_THREAD_LIBS_INIT}
6971
cppnetlib-constants
7072
cppnetlib-uri
@@ -96,6 +98,7 @@ if (Boost_FOUND)
9698
add_executable(cpp-netlib-http-${test} ${test}.cpp)
9799
target_link_libraries(cpp-netlib-http-${test}
98100
${Boost_LIBRARIES}
101+
${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}
99102
${CMAKE_THREAD_LIBS_INIT}
100103
cppnetlib-constants
101104
cppnetlib-uri

libs/network/test/uri/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (Boost_FOUND)
2525
add_executable(cpp-netlib-${test} ${test}.cpp)
2626
add_dependencies(cpp-netlib-${test} cppnetlib-uri)
2727
target_link_libraries(cpp-netlib-${test}
28-
${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri)
28+
${Boost_LIBRARIES} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} cppnetlib-uri)
2929
if (OPENSSL_FOUND)
3030
target_link_libraries(cpp-netlib-${test} ${OPENSSL_LIBRARIES})
3131
endif()

0 commit comments

Comments
 (0)