monero/external/miniupnpc/CMakeLists.txt

194 lines
7.0 KiB
CMake
Raw Normal View History

2014-04-09 15:14:35 +03:00
cmake_minimum_required (VERSION 2.6)
project (miniupnpc C)
2016-09-17 11:11:02 +03:00
set (MINIUPNPC_VERSION 2.0)
2016-03-21 15:05:50 +02:00
set (MINIUPNPC_API_VERSION 16)
2015-12-30 09:56:25 +02:00
2016-01-03 10:22:06 +02:00
# - we comment out this block as we don't support these other build types
if(0)
2015-12-30 09:56:25 +02:00
if (NOT CMAKE_BUILD_TYPE)
if (WIN32)
set (DEFAULT_BUILD_TYPE MinSizeRel)
else (WIN32)
set (DEFAULT_BUILD_TYPE RelWithDebInfo)
endif(WIN32)
set (CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE} CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
2016-01-03 10:22:06 +02:00
endif()
2014-04-09 15:14:35 +03:00
option (UPNPC_BUILD_STATIC "Build static library" TRUE)
option (UPNPC_BUILD_SHARED "Build shared library" FALSE)
2016-09-17 11:37:48 +03:00
option (UPNPC_BUILD_TESTS "Build test executables" FALSE)
2014-04-09 15:14:35 +03:00
option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
mark_as_advanced (NO_GETADDRINFO)
if (NO_GETADDRINFO)
add_definitions (-DNO_GETADDRINFO)
2015-12-30 09:56:25 +02:00
endif (NO_GETADDRINFO)
2014-04-09 15:14:35 +03:00
if (NOT WIN32)
add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT)
2016-03-21 19:37:07 +02:00
add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE)
2016-09-17 11:11:02 +03:00
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
# add_definitions (-D_POSIX_C_SOURCE=200112L)
add_definitions (-D_XOPEN_SOURCE=600)
endif (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
2015-12-30 09:56:25 +02:00
else (NOT WIN32)
2014-04-09 15:14:35 +03:00
add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends
2015-12-30 09:56:25 +02:00
endif (NOT WIN32)
2014-04-09 15:14:35 +03:00
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions (-D_DARWIN_C_SOURCE)
2014-04-09 15:14:35 +03:00
endif ()
2016-01-03 10:22:06 +02:00
# - we comment out this block as we already set flags
if(0)
2015-12-30 09:56:25 +02:00
# Set compiler specific build flags
if (CMAKE_COMPILER_IS_GNUC)
# Set our own default flags at first run.
if (NOT CONFIGURED)
if (NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
set (_PIC -fPIC)
endif (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
set (CMAKE_C_FLAGS "${_PIC} -Wall $ENV{CFLAGS}" # CMAKE_C_FLAGS gets appended to the other C flags
CACHE STRING "Flags used by the C compiler during normal builds." FORCE)
set (CMAKE_C_FLAGS_DEBUG "-g -DDDEBUG"
CACHE STRING "Flags used by the C compiler during debug builds." FORCE)
set (CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)
set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)
set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG"
CACHE STRING "Flags used by the C compiler during release builds." FORCE)
endif (NOT CONFIGURED)
endif ()
2016-01-03 10:22:06 +02:00
endif()
2015-12-30 09:56:25 +02:00
2016-09-17 11:11:02 +03:00
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/miniupnpcstrings.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/miniupnpcstrings.h)
include_directories (${CMAKE_CURRENT_BINARY_DIR})
2014-04-09 15:14:35 +03:00
set (MINIUPNPC_SOURCES
igd_desc_parse.c
miniupnpc.c
minixml.c
minisoap.c
2015-12-30 09:56:25 +02:00
minissdpc.c
2014-04-09 15:14:35 +03:00
miniwget.c
upnpcommands.c
2015-12-30 09:56:25 +02:00
upnpdev.c
2014-04-09 15:14:35 +03:00
upnpreplyparse.c
upnperrors.c
connecthostport.c
portlistingparse.c
receivedata.c
)
2015-12-30 09:56:25 +02:00
if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
2014-04-09 15:14:35 +03:00
set (MINIUPNPC_SOURCES ${MINIUPNPC_SOURCES} minissdpc.c)
2015-12-30 09:56:25 +02:00
endif (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
2014-04-09 15:14:35 +03:00
if (WIN32)
set_source_files_properties (${MINIUPNPC_SOURCES} PROPERTIES
2015-12-30 09:56:25 +02:00
COMPILE_DEFINITIONS "MINIUPNP_STATICLIB;MINIUPNP_EXPORTS"
2014-04-09 15:14:35 +03:00
)
2015-12-30 09:56:25 +02:00
endif (WIN32)
2014-04-09 15:14:35 +03:00
if (WIN32)
2015-12-31 09:06:11 +02:00
# We use set instead of find_library because otherwise static compilation on Windows breaks. Don't ask me why, just roll with it.
# find_library (WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
# find_library (IPHLPAPI_LIBRARY NAMES iphlpapi)
set (WINSOCK2_LIBRARY ws2_32)
set (IPHLPAPI_LIBRARY iphlpapi)
2014-04-09 15:14:35 +03:00
set (LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
2015-12-30 09:56:25 +02:00
#elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
# find_library (SOCKET_LIBRARY NAMES socket)
# find_library (NSL_LIBRARY NAMES nsl)
# find_library (RESOLV_LIBRARY NAMES resolv)
# set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS})
endif (WIN32)
2014-04-09 15:14:35 +03:00
if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
2015-12-30 09:56:25 +02:00
message (FATAL "Both shared and static libraries are disabled!")
endif (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
2014-04-09 15:14:35 +03:00
if (UPNPC_BUILD_STATIC)
2016-09-17 11:11:02 +03:00
add_library (libminiupnpc-static STATIC ${MINIUPNPC_SOURCES})
set_target_properties (libminiupnpc-static PROPERTIES OUTPUT_NAME "miniupnpc")
target_link_libraries (libminiupnpc-static ${LDLIBS})
set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} libminiupnpc-static)
set (UPNPC_LIBRARY_TARGET libminiupnpc-static)
2016-09-17 11:42:35 +03:00
# add_executable (upnpc-static upnpc.c)
2016-09-17 11:47:50 +03:00
# target_link_libraries (upnpc-static LINK_PRIVATE libminiupnpc-static)
2015-12-30 09:56:25 +02:00
endif (UPNPC_BUILD_STATIC)
2014-04-09 15:14:35 +03:00
if (UPNPC_BUILD_SHARED)
2016-09-17 11:11:02 +03:00
add_library (libminiupnpc-shared SHARED ${MINIUPNPC_SOURCES})
set_target_properties (libminiupnpc-shared PROPERTIES OUTPUT_NAME "miniupnpc")
set_target_properties (libminiupnpc-shared PROPERTIES VERSION ${MINIUPNPC_VERSION})
set_target_properties (libminiupnpc-shared PROPERTIES SOVERSION ${MINIUPNPC_API_VERSION})
target_link_libraries (libminiupnpc-shared ${LDLIBS})
set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} libminiupnpc-shared)
set (UPNPC_LIBRARY_TARGET libminiupnpc-shared)
add_executable (upnpc-shared upnpc.c)
target_link_libraries (upnpc-shared LINK_PRIVATE libminiupnpc-shared)
2015-12-30 09:56:25 +02:00
endif (UPNPC_BUILD_SHARED)
if (UPNPC_BUILD_TESTS)
add_executable (testminixml testminixml.c minixml.c igd_desc_parse.c)
target_link_libraries (testminixml ${LDLIBS})
add_executable (minixmlvalid minixmlvalid.c minixml.c)
target_link_libraries (minixmlvalid ${LDLIBS})
add_executable (testupnpreplyparse testupnpreplyparse.c
minixml.c upnpreplyparse.c)
target_link_libraries (testupnpreplyparse ${LDLIBS})
add_executable (testigddescparse testigddescparse.c
igd_desc_parse.c minixml.c miniupnpc.c miniwget.c minissdpc.c
upnpcommands.c upnpreplyparse.c minisoap.c connecthostport.c
portlistingparse.c receivedata.c
)
target_link_libraries (testigddescparse ${LDLIBS})
add_executable (testminiwget testminiwget.c
miniwget.c miniupnpc.c minisoap.c upnpcommands.c minissdpc.c
upnpreplyparse.c minixml.c igd_desc_parse.c connecthostport.c
portlistingparse.c receivedata.c
)
target_link_libraries (testminiwget ${LDLIBS})
# set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
endif (UPNPC_BUILD_TESTS)
2014-04-09 15:14:35 +03:00
install (TARGETS ${UPNPC_INSTALL_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)
install (FILES
2015-12-30 09:56:25 +02:00
miniupnpc.h
2014-04-09 15:14:35 +03:00
miniwget.h
upnpcommands.h
igd_desc_parse.h
upnpreplyparse.h
upnperrors.h
2015-12-30 09:56:25 +02:00
upnpdev.h
miniupnpctypes.h
portlistingparse.h
2015-12-30 09:56:25 +02:00
miniupnpc_declspec.h
2014-04-09 15:14:35 +03:00
DESTINATION include/miniupnpc
)
2015-12-31 09:06:11 +02:00
# commented out by Ben Boeckel, who I presume knows what he's doing;)
# set (CONFIGURED YES CACHE INTERNAL "")
2015-12-30 09:56:25 +02:00
2014-04-09 15:14:35 +03:00
# vim: ts=2:sw=2