Added flag to building the dynamic libraries

BUILD_DYNAMIC_LIBS

Some libs (glfw comes to mind), offer the option to build both or either the static and dynamic libs
This commit is contained in:
Corey Powell 2016-06-30 10:45:55 -05:00
parent 425dc4bf69
commit 3e1033cd30

View file

@ -28,6 +28,7 @@ if(NOT SOUNDIO_STATIC_LIBNAME)
endif() endif()
option(BUILD_STATIC_LIBS "Build static libraries" ON) option(BUILD_STATIC_LIBS "Build static libraries" ON)
option(BUILD_DYNAMIC_LIBS "Build dynamic libraries" ON)
option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON) option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON)
option(BUILD_TESTS "Build tests" ON) option(BUILD_TESTS "Build tests" ON)
option(ENABLE_JACK "Enable JACK backend" ON) option(ENABLE_JACK "Enable JACK backend" ON)
@ -222,17 +223,18 @@ configure_file(
${DOXYGEN_CONF_FILE} ${DOXYGEN_CONF_FILE}
) )
add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES}) if(BUILD_DYNAMIC_LIBS)
set_target_properties(libsoundio_shared PROPERTIES add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES})
OUTPUT_NAME soundio set_target_properties(libsoundio_shared PROPERTIES
SOVERSION ${LIBSOUNDIO_VERSION_MAJOR} OUTPUT_NAME soundio
VERSION ${LIBSOUNDIO_VERSION} SOVERSION ${LIBSOUNDIO_VERSION_MAJOR}
COMPILE_FLAGS ${LIB_CFLAGS} VERSION ${LIBSOUNDIO_VERSION}
LINKER_LANGUAGE C COMPILE_FLAGS ${LIB_CFLAGS}
) LINKER_LANGUAGE C
target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS}) )
install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS})
install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(BUILD_STATIC_LIBS) if(BUILD_STATIC_LIBS)
add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES}) add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES})