diff --git a/CMakeLists.txt b/CMakeLists.txt index 55653f12..d35b499d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,8 @@ if (WIN32) set (STATIC_POSTFIX s) endif() +option (UPNP_BUILD_SHARED "Build shared libraries" ON) +option (UPNP_BUILD_STATIC "Build static libraries" ON) option (BUILD_TESTING "Run Tests after compile" ON) if (BUILD_TESTING) diff --git a/ixml/CMakeLists.txt b/ixml/CMakeLists.txt index e33a561e..184f65d0 100644 --- a/ixml/CMakeLists.txt +++ b/ixml/CMakeLists.txt @@ -15,6 +15,7 @@ set (IXML_SOURCES src/nodeList.c ) +if (UPNP_BUILD_SHARED) add_library (ixml_shared SHARED ${IXML_SOURCES} ) @@ -54,7 +55,9 @@ install (TARGETS ixml_shared INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp ) +endif() +if (UPNP_BUILD_STATIC) add_library (ixml_static STATIC ${IXML_SOURCES} ) @@ -93,6 +96,7 @@ install (TARGETS ixml_static DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp ) +endif() install (EXPORT IXML DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/IXML diff --git a/ixml/test/CMakeLists.txt b/ixml/test/CMakeLists.txt index 7dea06eb..1241e856 100644 --- a/ixml/test/CMakeLists.txt +++ b/ixml/test/CMakeLists.txt @@ -2,6 +2,7 @@ FILE (GLOB XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/testdata/*.xml ) +if (UPNP_BUILD_SHARED) ADD_EXECUTABLE (test-ixml-shared test_document.c ) @@ -17,7 +18,9 @@ ADD_TEST (NAME test-ixml SET_TESTS_PROPERTIES (test-ixml PROPERTIES ENVIRONMENT "PATH=$\;%PATH%" ) +endif() +if (UPNP_BUILD_STATIC) ADD_EXECUTABLE (test-ixml-static test_document.c ) @@ -29,3 +32,4 @@ TARGET_LINK_LIBRARIES (test-ixml-static ADD_TEST (NAME test-ixml-static COMMAND test-ixml-static ${XML_FILES} ) +endif() diff --git a/upnp/CMakeLists.txt b/upnp/CMakeLists.txt index d10336f9..c9d19f8d 100644 --- a/upnp/CMakeLists.txt +++ b/upnp/CMakeLists.txt @@ -83,6 +83,7 @@ if (uuid) ) endif() +if (UPNP_BUILD_SHARED) add_library (upnp_shared SHARED ${UPNP_SOURCES} ) @@ -182,7 +183,9 @@ install (TARGETS upnp_shared INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp ) +endif() +if (UPNP_BUILD_STATIC) add_library (upnp_static STATIC ${UPNP_SOURCES} ) @@ -233,6 +236,7 @@ install (TARGETS upnp_static DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upnp ) +endif() install (EXPORT UPNP DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UPNP diff --git a/upnp/test/CMakeLists.txt b/upnp/test/CMakeLists.txt index 741f9a57..745f2148 100644 --- a/upnp/test/CMakeLists.txt +++ b/upnp/test/CMakeLists.txt @@ -4,6 +4,7 @@ if (WIN32) string (APPEND TEST_ENV "%PATH%") endif() +if (UPNP_BUILD_SHARED) add_executable (test-upnp-init ${WIN_EXE} test_init.c ) @@ -23,7 +24,9 @@ add_test (NAME test-upnp-init set_tests_properties (test-upnp-init PROPERTIES ENVIRONMENT "${TEST_ENV}" ) +endif() +if (UPNP_BUILD_STATIC) add_executable (test-upnp-init-static test_init.c ) @@ -39,7 +42,9 @@ target_compile_definitions (test-upnp-init-static add_test (NAME test-upnp-init-static COMMAND test-upnp-init-static ) +endif() +if (UPNP_BUILD_SHARED) add_executable (test-upnp-list test_list.c ) @@ -55,7 +60,9 @@ set_tests_properties (test-upnp-list PROPERTIES target_link_libraries (test-upnp-list upnp_shared ) +endif() +if (UPNP_BUILD_STATIC) add_executable (test-upnp-list-static test_list.c ) @@ -67,7 +74,9 @@ target_link_libraries (test-upnp-list-static add_test (NAME test-upnp-list-static COMMAND test-upnp-list-static ) +endif() +if (UPNP_BUILD_SHARED) add_executable (test-upnp-log test_log.c ) @@ -87,7 +96,9 @@ add_test (NAME test-upnp-log set_tests_properties (test-upnp-log PROPERTIES ENVIRONMENT "${TEST_ENV}" ) +endif() +if (UPNP_BUILD_STATIC) add_executable (test-upnp-log-static test_log.c ) @@ -103,7 +114,9 @@ target_link_libraries (test-upnp-log-static add_test (NAME test-upnp-log-static COMMAND test-upnp-log-static ) +endif() +if (UPNP_BUILD_SHARED) add_executable (test-upnp-url test_url.c ) @@ -119,7 +132,9 @@ add_test (NAME test-upnp-url set_tests_properties (test-upnp-url PROPERTIES ENVIRONMENT "${TEST_ENV}" ) +endif() +if (UPNP_BUILD_STATIC) add_executable (test-upnp-url-static test_url.c ) @@ -131,3 +146,4 @@ target_link_libraries (test-upnp-url-static add_test (NAME test-upnp-url-static COMMAND test-upnp-url-static ) +endif()