From 425dc4bf697e7465e3d41f9e5d198222c0bce448 Mon Sep 17 00:00:00 2001 From: Corey Powell Date: Thu, 30 Jun 2016 10:45:08 -0500 Subject: [PATCH 1/2] Allow overriding static lib name This helps alleviate cases where compilers will choose to link against the dynamic library instead of the static based on name alone (in which you don't have much control, or don't wish to tinker too much with the compiler args) --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb645a8..09b48d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ set(LIBSOUNDIO_VERSION_PATCH 0) set(LIBSOUNDIO_VERSION "${LIBSOUNDIO_VERSION_MAJOR}.${LIBSOUNDIO_VERSION_MINOR}.${LIBSOUNDIO_VERSION_PATCH}") message("Configuring libsoundio version ${LIBSOUNDIO_VERSION}") +if(NOT SOUNDIO_STATIC_LIBNAME) + set(SOUNDIO_STATIC_LIBNAME soundio) +endif() + option(BUILD_STATIC_LIBS "Build static libraries" ON) option(BUILD_EXAMPLE_PROGRAMS "Build example programs" ON) option(BUILD_TESTS "Build tests" ON) @@ -233,7 +237,7 @@ install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(BUILD_STATIC_LIBS) add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES}) set_target_properties(libsoundio_static PROPERTIES - OUTPUT_NAME soundio + OUTPUT_NAME ${SOUNDIO_STATIC_LIBNAME} COMPILE_FLAGS ${LIB_CFLAGS} LINKER_LANGUAGE C ) From 3e1033cd30fa9e23adbe467af2850845aa55f74a Mon Sep 17 00:00:00 2001 From: Corey Powell Date: Thu, 30 Jun 2016 10:45:55 -0500 Subject: [PATCH 2/2] 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 --- CMakeLists.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09b48d2..e47a46d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ if(NOT SOUNDIO_STATIC_LIBNAME) endif() 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_TESTS "Build tests" ON) option(ENABLE_JACK "Enable JACK backend" ON) @@ -222,17 +223,18 @@ configure_file( ${DOXYGEN_CONF_FILE} ) -add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES}) -set_target_properties(libsoundio_shared PROPERTIES - OUTPUT_NAME soundio - SOVERSION ${LIBSOUNDIO_VERSION_MAJOR} - VERSION ${LIBSOUNDIO_VERSION} - COMPILE_FLAGS ${LIB_CFLAGS} - LINKER_LANGUAGE C -) -target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS}) -install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - +if(BUILD_DYNAMIC_LIBS) + add_library(libsoundio_shared SHARED ${LIBSOUNDIO_SOURCES}) + set_target_properties(libsoundio_shared PROPERTIES + OUTPUT_NAME soundio + SOVERSION ${LIBSOUNDIO_VERSION_MAJOR} + VERSION ${LIBSOUNDIO_VERSION} + COMPILE_FLAGS ${LIB_CFLAGS} + LINKER_LANGUAGE C + ) + target_link_libraries(libsoundio_shared LINK_PUBLIC ${LIBSOUNDIO_LIBS}) + install(TARGETS libsoundio_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() if(BUILD_STATIC_LIBS) add_library(libsoundio_static STATIC ${LIBSOUNDIO_SOURCES})