PageRenderTime 92ms CodeModel.GetById 50ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 1ms

/thirdparty/libportfwd/third-party/miniupnpc-1.6/CMakeLists.txt

http://github.com/tomahawk-player/tomahawk
CMake | 172 lines | 134 code | 29 blank | 9 comment | 18 complexity | fb379af05cb2815d50db6259ee4f0b29 MD5 | raw file
  1cmake_minimum_required (VERSION 2.6)
  2
  3project (miniupnpc C)
  4set (MINIUPNPC_VERSION 1.5)
  5set (MINIUPNPC_API_VERSION 8)
  6
  7if (NOT CMAKE_BUILD_TYPE)
  8  if (WIN32)
  9    set (DEFAULT_BUILD_TYPE MinSizeRel)
 10  else (WIN32)
 11    set (DEFAULT_BUILD_TYPE RelWithDebInfo)
 12  endif(WIN32)
 13    set (CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING
 14        "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
 15        FORCE)
 16endif()
 17
 18option (UPNPC_BUILD_STATIC "Build static library" TRUE)
 19option (UPNPC_BUILD_SHARED "Build shared library" TRUE)
 20if (NOT WIN32)
 21  option (UPNPC_BUILD_TESTS "Build test executables" TRUE)
 22endif (NOT WIN32)
 23option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
 24
 25mark_as_advanced (NO_GETADDRINFO)
 26
 27if (NO_GETADDRINFO)
 28  add_definitions (-DNO_GETADDRINFO)
 29endif (NO_GETADDRINFO)
 30
 31if (NOT WIN32)
 32  add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
 33else (NOT WIN32)
 34  add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
 35endif (NOT WIN32)
 36
 37if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
 38  add_definitions (-DMACOSX -D_DARWIN_C_SOURCE)
 39endif ()
 40
 41# Set compiler specific build flags
 42if (CMAKE_COMPILER_IS_GNUC)
 43  # Set our own default flags at first run.
 44  if (NOT CONFIGURED)
 45
 46    if (NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
 47      set (_PIC -fPIC)
 48    endif (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
 49
 50    set (CMAKE_C_FLAGS "${_PIC} -Wall $ENV{CFLAGS}" # CMAKE_C_FLAGS gets appended to the other C flags
 51        CACHE STRING "Flags used by the C compiler during normal builds." FORCE)
 52    set (CMAKE_C_FLAGS_DEBUG "-g -DDDEBUG"
 53        CACHE STRING "Flags used by the C compiler during debug builds." FORCE)
 54    set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG"
 55        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
 56    set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG"
 57        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
 58    set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG"
 59        CACHE STRING "Flags used by the C compiler during release builds." FORCE)
 60
 61  endif (NOT CONFIGURED)
 62endif ()
 63
 64configure_file (${CMAKE_CURRENT_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/miniupnpcstrings.h)
 65include_directories (${CMAKE_CURRENT_BINARY_DIR})
 66
 67set (MINIUPNPC_SOURCES
 68  igd_desc_parse.c
 69  miniupnpc.c
 70  minixml.c
 71  minisoap.c
 72  miniwget.c
 73  upnpc.c
 74  upnpcommands.c
 75  upnpreplyparse.c
 76  upnperrors.c
 77  connecthostport.c
 78  portlistingparse.c
 79)
 80
 81if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
 82  set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
 83endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
 84
 85if (WIN32)
 86  set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
 87                                                    COMPILE_DEFINITIONS STATICLIB
 88                                                    COMPILE_DEFINITIONS MINIUPNP_EXPORTS
 89  )
 90endif (WIN32)
 91
 92if (WIN32)
 93  find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
 94  find_library (IPHLPAPI_LIBRARY NAMES iphlpapi)
 95  set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
 96#elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
 97#  find_library (SOCKET_LIBRARY NAMES socket)
 98#  find_library (NSL_LIBRARY NAMES nsl)
 99#  find_library (RESOLV_LIBRARY NAMES resolv)
100#  set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS})
101endif (WIN32)
102
103if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
104    message (FATAL "Both shared and static libraries are disabled!")
105endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
106
107if (UPNPC_BUILD_STATIC)
108  add_library (upnpc-static STATIC ${MINIUPNPC_SOURCES})
109  set_target_properties (upnpc-static PROPERTIES OUTPUT_NAME "miniupnpc")
110  target_link_libraries (upnpc-static PRIVATE ${LDLIBS})
111  set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-static)
112  set (UPNPC_LIBRARY_TARGET upnpc-static)
113endif (UPNPC_BUILD_STATIC)
114
115if (UPNPC_BUILD_SHARED)
116  add_library (upnpc-shared SHARED ${MINIUPNPC_SOURCES})
117  set_target_properties (upnpc-shared PROPERTIES OUTPUT_NAME "miniupnpc")
118  set_target_properties (upnpc-shared PROPERTIES VERSION ${MINIUPNPC_VERSION})
119  set_target_properties (upnpc-shared PROPERTIES SOVERSION ${MINIUPNPC_API_VERSION})
120  target_link_libraries (upnpc-shared PRIVATE ${LDLIBS})
121  set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-shared)
122  set (UPNPC_LIBRARY_TARGET upnpc-shared)
123endif (UPNPC_BUILD_SHARED)
124
125if (UPNPC_BUILD_TESTS)
126  add_executable (testminixml testminixml.c minixml.c igd_desc_parse.c)
127  target_link_libraries (testminixml ${LDLIBS})
128
129  add_executable (minixmlvalid minixmlvalid.c minixml.c)
130  target_link_libraries (minixmlvalid ${LDLIBS})
131
132  add_executable (testupnpreplyparse testupnpreplyparse.c
133                                     minixml.c upnpreplyparse.c)
134  target_link_libraries (testupnpreplyparse ${LDLIBS})
135
136  add_executable (testigddescparse testigddescparse.c
137                                   igd_desc_parse.c minixml.c miniupnpc.c miniwget.c minissdpc.c
138                                   upnpcommands.c upnpreplyparse.c minisoap.c connecthostport.c
139                                   portlistingparse.c
140  )
141  target_link_libraries (testigddescparse ${LDLIBS})
142
143  add_executable (testminiwget testminiwget.c
144                               miniwget.c miniupnpc.c minisoap.c upnpcommands.c minissdpc.c
145                               upnpreplyparse.c minixml.c igd_desc_parse.c connecthostport.c
146                               portlistingparse.c
147  )
148  target_link_libraries (testminiwget ${LDLIBS})
149
150# set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
151endif (UPNPC_BUILD_TESTS)
152
153
154install (TARGETS ${UPNPC_INSTALL_TARGETS}
155  RUNTIME DESTINATION bin
156  LIBRARY DESTINATION lib${LIB_SUFFIX}
157  ARCHIVE DESTINATION lib${LIB_SUFFIX}
158)
159install (FILES
160	miniupnpc.h
161  miniwget.h
162  upnpcommands.h
163  igd_desc_parse.h
164  upnpreplyparse.h
165  upnperrors.h
166  declspec.h
167  DESTINATION include/miniupnpc
168)
169
170set (CONFIGURED YES CACHE INTERNAL "")
171
172# vim: ts=2:sw=2