[CMake] Add UPNPC_NO_INSTALL option

This commit is contained in:
past-due 2019-04-17 10:27:29 -04:00 committed by GitHub
parent 41f5475080
commit aea0a6093d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 21 deletions

View File

@ -10,6 +10,7 @@ option (UPNPC_BUILD_SHARED "Build shared library" TRUE)
option (UPNPC_BUILD_TESTS "Build test executables" TRUE) option (UPNPC_BUILD_TESTS "Build test executables" TRUE)
option (UPNPC_BUILD_SAMPLE "Build sample executables" TRUE) option (UPNPC_BUILD_SAMPLE "Build sample executables" TRUE)
option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE) option (NO_GETADDRINFO "Define NO_GETADDRINFO" FALSE)
option (UPNPC_NO_INSTALL "Disable installation" FALSE)
if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED) if (NOT UPNPC_BUILD_STATIC AND NOT UPNPC_BUILD_SHARED)
message (FATAL "Both shared and static libraries are disabled!") message (FATAL "Both shared and static libraries are disabled!")
@ -108,10 +109,12 @@ if (UPNPC_BUILD_STATIC)
target_include_directories(libminiupnpc-static INTERFACE ../${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(libminiupnpc-static INTERFACE ../${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(libminiupnpc-static PUBLIC MINIUPNP_STATICLIB) target_compile_definitions(libminiupnpc-static PUBLIC MINIUPNP_STATICLIB)
install (TARGETS libminiupnpc-static if (NOT UPNPC_NO_INSTALL)
RUNTIME DESTINATION bin install (TARGETS libminiupnpc-static
LIBRARY DESTINATION lib${LIB_SUFFIX} RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_SUFFIX}) LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
endif()
if (UPNPC_BUILD_SAMPLE) if (UPNPC_BUILD_SAMPLE)
add_executable (upnpc-static upnpc.c) add_executable (upnpc-static upnpc.c)
@ -133,10 +136,12 @@ if (UPNPC_BUILD_SHARED)
target_link_libraries(libminiupnpc-shared INTERFACE ws2_32 iphlpapi) target_link_libraries(libminiupnpc-shared INTERFACE ws2_32 iphlpapi)
endif() endif()
install (TARGETS libminiupnpc-shared if (NOT UPNPC_NO_INSTALL)
RUNTIME DESTINATION bin install (TARGETS libminiupnpc-shared
LIBRARY DESTINATION lib${LIB_SUFFIX} RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_SUFFIX}) LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
endif()
if (UPNPC_BUILD_SAMPLE) if (UPNPC_BUILD_SAMPLE)
add_executable (upnpc-shared upnpc.c) add_executable (upnpc-shared upnpc.c)
@ -177,18 +182,20 @@ if (UPNPC_BUILD_TESTS)
# set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget) # set (UPNPC_INSTALL_TARGETS ${UPNPC_INSTALL_TARGETS} testminixml minixmlvalid testupnpreplyparse testigddescparse testminiwget)
endif () endif ()
install (FILES if (NOT UPNPC_NO_INSTALL)
miniupnpc.h install (FILES
miniwget.h miniupnpc.h
upnpcommands.h miniwget.h
igd_desc_parse.h upnpcommands.h
upnpreplyparse.h igd_desc_parse.h
upnperrors.h upnpreplyparse.h
upnpdev.h upnperrors.h
miniupnpctypes.h upnpdev.h
portlistingparse.h miniupnpctypes.h
miniupnpc_declspec.h portlistingparse.h
DESTINATION include/miniupnpc miniupnpc_declspec.h
) DESTINATION include/miniupnpc
)
endif()
# vim: ts=2:sw=2 # vim: ts=2:sw=2