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

1.1       misho       1: cmake_minimum_required (VERSION 2.6)
                      2: 
                      3: project (miniupnpc C)
1.1.1.2 ! misho       4: set (MINIUPNPC_VERSION 1.7)
        !             5: set (MINIUPNPC_API_VERSION 9)
1.1       misho       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)
1.1.1.2 ! misho      33:   add_definitions (-D_BSD_SOURCE -D_POSIX_C_SOURCE=1)
1.1       misho      34: else (NOT WIN32)
                     35:   add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
                     36: endif (NOT WIN32)
                     37: 
                     38: if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
                     39:   add_definitions (-DMACOSX -D_DARWIN_C_SOURCE)
                     40: endif ()
                     41: 
                     42: # Set compiler specific build flags
                     43: if (CMAKE_COMPILER_IS_GNUC)
                     44:   # Set our own default flags at first run.
                     45:   if (NOT CONFIGURED)
                     46: 
                     47:     if (NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     48:       set (_PIC -fPIC)
                     49:     endif (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     50: 
                     51:     set (CMAKE_C_FLAGS "${_PIC} -Wall $ENV{CFLAGS}" # CMAKE_C_FLAGS gets appended to the other C flags
                     52:         CACHE STRING "Flags used by the C compiler during normal builds." FORCE)
                     53:     set (CMAKE_C_FLAGS_DEBUG "-g -DDDEBUG"
                     54:         CACHE STRING "Flags used by the C compiler during debug builds." FORCE)
                     55:     set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG"
                     56:         CACHE STRING "Flags used by the C compiler during release builds." FORCE)
                     57:     set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG"
                     58:         CACHE STRING "Flags used by the C compiler during release builds." FORCE)
                     59:     set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG"
                     60:         CACHE STRING "Flags used by the C compiler during release builds." FORCE)
                     61: 
                     62:   endif (NOT CONFIGURED)
                     63: endif ()
                     64: 
                     65: configure_file (${CMAKE_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_BINARY_DIR}/miniupnpcstrings.h)
                     66: include_directories (${CMAKE_BINARY_DIR})
                     67: 
                     68: set (MINIUPNPC_SOURCES
                     69:   igd_desc_parse.c
                     70:   miniupnpc.c
                     71:   minixml.c
                     72:   minisoap.c
                     73:   miniwget.c
                     74:   upnpc.c
                     75:   upnpcommands.c
                     76:   upnpreplyparse.c
                     77:   upnperrors.c
                     78:   connecthostport.c
                     79:   portlistingparse.c
1.1.1.2 ! misho      80:   receivedata.c
1.1       misho      81: )
                     82: 
                     83: if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     84:   set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
                     85: endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
                     86: 
                     87: if (WIN32)
                     88:   set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
                     89:                                                     COMPILE_DEFINITIONS STATICLIB
                     90:                                                     COMPILE_DEFINITIONS MINIUPNP_EXPORTS
                     91:   )
                     92: endif (WIN32)
                     93: 
                     94: if (WIN32)
                     95:   find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
                     96:   find_library (IPHLPAPI_LIBRARY NAMES iphlpapi)
                     97:   set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
                     98: #elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
                     99: #  find_library (SOCKET_LIBRARY NAMES socket)
                    100: #  find_library (NSL_LIBRARY NAMES nsl)
                    101: #  find_library (RESOLV_LIBRARY NAMES resolv)
                    102: #  set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS})
                    103: endif (WIN32)
                    104: 
                    105: if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
                    106:     message (FATAL "Both shared and static libraries are disabled!")
                    107: endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
                    108: 
                    109: if (UPNPC_BUILD_STATIC)
                    110:   add_library (upnpc-static STATIC ${MINIUPNPC_SOURCES})
                    111:   set_target_properties (upnpc-static PROPERTIES OUTPUT_NAME "miniupnpc")
                    112:   target_link_libraries (upnpc-static ${LDLIBS})
                    113:   set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-static)
                    114:   set (UPNPC_LIBRARY_TARGET upnpc-static)
                    115: endif (UPNPC_BUILD_STATIC)
                    116: 
                    117: if (UPNPC_BUILD_SHARED)
                    118:   add_library (upnpc-shared SHARED ${MINIUPNPC_SOURCES})
                    119:   set_target_properties (upnpc-shared PROPERTIES OUTPUT_NAME "miniupnpc")
                    120:   set_target_properties (upnpc-shared PROPERTIES VERSION ${MINIUPNPC_VERSION})
                    121:   set_target_properties (upnpc-shared PROPERTIES SOVERSION ${MINIUPNPC_API_VERSION})
                    122:   target_link_libraries (upnpc-shared ${LDLIBS})
                    123:   set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} upnpc-shared)
                    124:   set (UPNPC_LIBRARY_TARGET upnpc-shared)
                    125: endif (UPNPC_BUILD_SHARED)
                    126: 
                    127: if (UPNPC_BUILD_TESTS)
                    128:   add_executable (testminixml testminixml.c minixml.c igd_desc_parse.c)
                    129:   target_link_libraries (testminixml ${LDLIBS})
                    130: 
                    131:   add_executable (minixmlvalid minixmlvalid.c minixml.c)
                    132:   target_link_libraries (minixmlvalid ${LDLIBS})
                    133: 
                    134:   add_executable (testupnpreplyparse testupnpreplyparse.c
                    135:                                      minixml.c upnpreplyparse.c)
                    136:   target_link_libraries (testupnpreplyparse ${LDLIBS})
                    137: 
                    138:   add_executable (testigddescparse testigddescparse.c
                    139:                                    igd_desc_parse.c minixml.c miniupnpc.c miniwget.c minissdpc.c
                    140:                                    upnpcommands.c upnpreplyparse.c minisoap.c connecthostport.c
1.1.1.2 ! misho     141:                                    portlistingparse.c receivedata.c
1.1       misho     142:   )
                    143:   target_link_libraries (testigddescparse ${LDLIBS})
                    144: 
                    145:   add_executable (testminiwget testminiwget.c
                    146:                                miniwget.c miniupnpc.c minisoap.c upnpcommands.c minissdpc.c
                    147:                                upnpreplyparse.c minixml.c igd_desc_parse.c connecthostport.c
1.1.1.2 ! misho     148:                                portlistingparse.c receivedata.c
1.1       misho     149:   )
                    150:   target_link_libraries (testminiwget ${LDLIBS})
                    151: 
                    152: # set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
                    153: endif (UPNPC_BUILD_TESTS)
                    154: 
                    155: 
                    156: install (TARGETS ${UPNPC_INSTALL_TARGETS}
                    157:   RUNTIME DESTINATION bin
                    158:   LIBRARY DESTINATION lib${LIB_SUFFIX}
                    159:   ARCHIVE DESTINATION lib${LIB_SUFFIX}
                    160: )
                    161: install (FILES
                    162:        miniupnpc.h
                    163:   miniwget.h
                    164:   upnpcommands.h
                    165:   igd_desc_parse.h
                    166:   upnpreplyparse.h
                    167:   upnperrors.h
                    168:   declspec.h
                    169:   DESTINATION include/miniupnpc
                    170: )
                    171: 
                    172: set (CONFIGURED YES CACHE INTERNAL "")
                    173: 
                    174: # vim: ts=2:sw=2

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