fixed: auto_ptr -> unique_ptr
[opensg.git] / Support / libiconv / CMakeLists.txt
blob5149c20a38dbda58b73f4c748c3c13a57a0dea7c
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3 IF(OSGLibIconvSrcDir)
5   PROJECT(OSGLibIconv)
7   SET(${PROJECT_NAME}SharedTarget osgiconv)
8   SET(${PROJECT_NAME}StaticTarget libosgiconv)
10   SET(OSGLibIconvLibSrcDir ${OSGLibIconvSrcDir} CACHE PATH "")
12   IF(EXISTS ${OSGLibIconvSrcDir}/source)
13     SET(OSGLibIconvSrcDir ${OSGLibIconvSrcDir}/source CACHE PATH "" FORCE)
14   ELSEIF(EXISTS ${OSGLibIconvSrcDir}/src/libiconv/1.9.2/libiconv-1.9.2)
15     SET(OSGLibIconvLibSrcDir ${OSGLibIconvSrcDir}/src/libiconv/1.9.2/libiconv-1.9.2-src CACHE PATH "" FORCE)
16     SET(OSGLibIconvSrcDir ${OSGLibIconvSrcDir}/src/libiconv/1.9.2/libiconv-1.9.2 CACHE PATH "" FORCE)
17   ENDIF()
19   SET(OSG_LIBICONV_SRCS ${OSGLibIconvLibSrcDir}/lib/iconv.c
20                         ${OSGLibIconvLibSrcDir}/libcharset/lib/localcharset.c
21                         ${OSGLibIconvLibSrcDir}/lib/relocatable.c)
23   IF(NOT EXISTS ${OSGLibIconvSrcDir}/include/iconv.h)
25     EXECUTE_PROCESS(
26       COMMAND "${CMAKE_COMMAND}" -E copy_if_different
27                        "${CMAKE_CURRENT_SOURCE_DIR}/iconv.h"
28                        "${CMAKE_BINARY_DIR}/libiconv/include/iconv.h")
30     EXECUTE_PROCESS(
31       COMMAND "${CMAKE_COMMAND}" -E copy_if_different
32                        "${CMAKE_CURRENT_SOURCE_DIR}/config.h"
33                        "${CMAKE_BINARY_DIR}/libiconv/config.h")
35     EXECUTE_PROCESS(
36       COMMAND "${CMAKE_COMMAND}" -E copy_if_different
37                        "${CMAKE_CURRENT_SOURCE_DIR}/localcharset.h"
38                        "${CMAKE_BINARY_DIR}/libiconv/localcharset.h")
39     
41     SET(OSG_LIBICONV_HDR ${CMAKE_BINARY_DIR}/libiconv/include/iconv.h)
43     INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/libiconv/include)
44     INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/libiconv)
46   ELSE()
48     SET(OSG_LIBICONV_HDR ${OSGLibIconvSrcDir}/include/iconv.h)
50   ENDIF()
53   SET(OSGLIBICONV_DEF _UNICODE;UNICODE;relocate=libiconv_relocate;set_relocation_prefix=libiconv_set_relocation_prefix;HAVE_CONFIG_H;ENABLE_RELOCATABLE=1;IN_LIBRARY;NO_XMALLOC;INSTALLPREFIX="${CMAKE_INSTALL_PREFIX}";INSTALLDIR="${CMAKE_INSTALL_PREFIX}";LIBDIR="${CMAKE_INSTALL_PREFIX}")
54   
55   INCLUDE_DIRECTORIES(${OSGLibIconvSrcDir})
56   INCLUDE_DIRECTORIES(${OSGLibIconvSrcDir}/lib)
57   INCLUDE_DIRECTORIES(${OSGLibIconvSrcDir}/libcharset/include)
58   INCLUDE_DIRECTORIES(${OSGLibIconvSrcDir}/include)
60   IF(BUILD_SHARED_LIBS)
61     ADD_LIBRARY(${${PROJECT_NAME}SharedTarget} SHARED ${OSG_LIBICONV_SRCS})
63     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}SharedTarget})
65     SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
66                           DEBUG_POSTFIX "D")
68     SET(OSGLIBICONV_DEF_SHARED ${OSGLIBICONV_DEF};BUILDING_LIBICONV;BUILDING_DLL;PIC;)
70     SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
71                           COMPILE_DEFINITIONS "${OSGLIBICONV_DEF_SHARED}")
73     INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
74                 CONFIGURATIONS Release
75                 RUNTIME DESTINATION bin COMPONENT release_runtimes
76                 LIBRARY DESTINATION lib COMPONENT release_libraries
77                 ARCHIVE DESTINATION lib COMPONENT release_libraries)
79     INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
80                 CONFIGURATIONS Debug
81                 RUNTIME DESTINATION bin COMPONENT debug_runtimes
82                 LIBRARY DESTINATION lib COMPONENT debug_libraries
83                 ARCHIVE DESTINATION lib COMPONENT debug_libraries)
85   ENDIF(BUILD_SHARED_LIBS)
87   IF(BUILD_STATIC_LIBS)
88     ADD_LIBRARY(${${PROJECT_NAME}StaticTarget} STATIC ${OSG_LIBICONV_SRCS})
90     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}StaticTarget})
92     SET_TARGET_PROPERTIES(${${PROJECT_NAME}StaticTarget} PROPERTIES
93                           DEBUG_POSTFIX "D")
95     SET_TARGET_PROPERTIES(${${PROJECT_NAME}StaticTarget} PROPERTIES
96                           COMPILE_DEFINITIONS "${OSGLIBICONV_DEF}")
99     INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
100                 CONFIGURATIONS Release
101                 RUNTIME DESTINATION lib COMPONENT release_libraries
102                 LIBRARY DESTINATION lib COMPONENT release_libraries
103                 ARCHIVE DESTINATION lib COMPONENT release_libraries)
105     INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
106                 CONFIGURATIONS Debug
107                 RUNTIME DESTINATION lib COMPONENT debug_libraries
108                 LIBRARY DESTINATION lib COMPONENT debug_libraries
109                 ARCHIVE DESTINATION lib COMPONENT debug_libraries)
110   ENDIF(BUILD_STATIC_LIBS)
112   INSTALL(FILES ${OSG_LIBICONV_HDR}
113           DESTINATION include${OSG_SUPPORT_INC_SUBDIR}
114           COMPONENT code_headers
115           PERMISSIONS OWNER_WRITE OWNER_READ
116                       GROUP_READ
117                       WORLD_READ)
119   IF(NOT EXISTS ${OSGLibIconvSrcDir}/include/iconv.h)
120     SET(OSG_ICONV_INCLUDE_DIR ${CMAKE_BINARY_DIR}/libiconv/include CACHE PATH "" FORCE)
121   ELSE()
122     SET(OSG_ICONV_INCLUDE_DIR ${OSGLibIconvSrcDir}/include CACHE PATH "" FORCE)
123   ENDIF()
125   SET(OSG_ICONV_STATIC_LIBRARY ${${PROJECT_NAME}StaticTarget} CACHE STRING "" FORCE)
126   SET(OSG_ICONV_SHARED_LIBRARY ${${PROJECT_NAME}SharedTarget} CACHE STRING "" FORCE)
128 ELSE(OSGLibIconvSrcDir)
129   SET(OSGLibIconvSrcDir "" CACHE PATH "")
130 ENDIF(OSGLibIconvSrcDir)