Annotation of embedaddon/miniupnpc/CMakeLists.txt, revision 1.1.1.1

1.1       misho       1: cmake_minimum_required (VERSION 2.6)
                      2: 
                      3: project (miniupnpc C)
                      4: set (MINIUPNPC_VERSION 1.5)
                      5: set (MINIUPNPC_API_VERSION 8)
                      6: 
                      7: if (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)
                     16: endif()
                     17: 
                     18: option (UPNPC_BUILD_STATIC "Build static library" TRUE)
                     19: option (UPNPC_BUILD_SHARED "Build shared library" TRUE)
                     20: if (NOT WIN32)
                     21:   option (UPNPC_BUILD_TESTS "Build test executables" TRUE)
                     22: endif (NOT WIN32)
                     23: option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
                     24: 
                     25: mark_as_advanced (NO_GETADDRINFO)
                     26: 
                     27: if (NO_GETADDRINFO)
                     28:   add_definitions (-DNO_GETADDRINFO)
                     29: endif (NO_GETADDRINFO)
                     30: 
                     31: if (NOT WIN32)
                     32:   add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
                     33: else (NOT WIN32)
                     34:   add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
                     35: endif (NOT WIN32)
                     36: 
                     37: if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
                     38:   add_definitions (-DMACOSX -D_DARWIN_C_SOURCE)
                     39: endif ()
                     40: 
                     41: # Set compiler specific build flags
                     42: if (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)
                     62: endif ()
                     63: 
                     64: configure_file (${CMAKE_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_BINARY_DIR}/miniupnpcstrings.h)
                     65: include_directories (${CMAKE_BINARY_DIR})
                     66: 
                     67: set (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: 
                     81: if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     82:   set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
                     83: endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     84: 
                     85: if (WIN32)
                     86:   set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
                     87:                                                     COMPILE_DEFINITIONS STATICLIB
                     88:                                                     COMPILE_DEFINITIONS MINIUPNP_EXPORTS
                     89:   )
                     90: endif (WIN32)
                     91: 
                     92: if (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})
                    101: endif (WIN32)
                    102: 
                    103: if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
                    104:     message (FATAL "Both shared and static libraries are disabled!")
                    105: endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
                    106: 
                    107: if (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 ${LDLIBS})
                    111:   set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-static)
                    112:   set (UPNPC_LIBRARY_TARGET upnpc-static)
                    113: endif (UPNPC_BUILD_STATIC)
                    114: 
                    115: if (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 ${LDLIBS})
                    121:   set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-shared)
                    122:   set (UPNPC_LIBRARY_TARGET upnpc-shared)
                    123: endif (UPNPC_BUILD_SHARED)
                    124: 
                    125: if (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)
                    151: endif (UPNPC_BUILD_TESTS)
                    152: 
                    153: 
                    154: install (TARGETS ${UPNPC_INSTALL_TARGETS}
                    155:   RUNTIME DESTINATION bin
                    156:   LIBRARY DESTINATION lib${LIB_SUFFIX}
                    157:   ARCHIVE DESTINATION lib${LIB_SUFFIX}
                    158: )
                    159: install (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: 
                    170: set (CONFIGURED YES CACHE INTERNAL "")
                    171: 
                    172: # vim: ts=2:sw=2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>