build: Only ever build static or shared libraries, but never both (#1343)
Closes #1341
This commit is contained in:
parent
1f71fa0a0e
commit
e19d73321d
|
@ -112,36 +112,23 @@ set(libpackager_deps
|
|||
)
|
||||
|
||||
# A static library target is always built.
|
||||
add_library(libpackager_static STATIC ${libpackager_sources})
|
||||
target_link_libraries(libpackager_static ${libpackager_deps})
|
||||
|
||||
# And always installed as libpackager.a / libpackager.lib:
|
||||
if(NOT MSVC)
|
||||
set_property(TARGET libpackager_static PROPERTY OUTPUT_NAME packager)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(libpackager SHARED ${libpackager_sources})
|
||||
target_link_libraries(libpackager ${libpackager_deps})
|
||||
target_compile_definitions(libpackager PUBLIC SHAKA_IMPLEMENTATION)
|
||||
else()
|
||||
set_property(TARGET libpackager_static PROPERTY OUTPUT_NAME libpackager)
|
||||
add_library(libpackager STATIC ${libpackager_sources})
|
||||
target_link_libraries(libpackager ${libpackager_deps})
|
||||
endif()
|
||||
|
||||
# A shared library target is conditional (default OFF):
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(libpackager_shared SHARED ${libpackager_sources})
|
||||
target_link_libraries(libpackager_shared ${libpackager_deps})
|
||||
target_compile_definitions(libpackager_shared PUBLIC SHAKA_IMPLEMENTATION)
|
||||
|
||||
# And always installed as libpackager.so / libpackager.dll:
|
||||
if(NOT MSVC)
|
||||
set_property(TARGET libpackager_shared PROPERTY OUTPUT_NAME packager)
|
||||
else()
|
||||
set_property(TARGET libpackager_shared PROPERTY OUTPUT_NAME libpackager)
|
||||
endif()
|
||||
|
||||
# If we're building a shared library, this is what the "libpackager" target
|
||||
# aliases to.
|
||||
add_library(libpackager ALIAS libpackager_shared)
|
||||
# The library is always installed as
|
||||
# libpackager.so / libpackager.dll / libpackager.a / libpackager.lib:
|
||||
if(NOT MSVC)
|
||||
# The "lib" prefix is implied outside of MSVC.
|
||||
set_property(TARGET libpackager PROPERTY OUTPUT_NAME packager)
|
||||
else()
|
||||
# If we're not building a shared library, the "libpackager" target aliases to
|
||||
# the static library.
|
||||
add_library(libpackager ALIAS libpackager_static)
|
||||
set_property(TARGET libpackager PROPERTY OUTPUT_NAME libpackager)
|
||||
endif()
|
||||
|
||||
add_executable(packager
|
||||
|
@ -256,7 +243,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pssh-box-protos
|
|||
# The static library isn't usable as a standalone because it doesn't include
|
||||
# its static dependencies (zlib, absl, etc).
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(TARGETS libpackager_shared)
|
||||
install(TARGETS libpackager)
|
||||
install(DIRECTORY ../include/packager
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/packager.pc
|
||||
|
|
Loading…
Reference in New Issue