diff --git a/src/sail-codecs-archive/CMakeLists.txt b/src/sail-codecs-archive/CMakeLists.txt index 7a9927d8..b7602dd6 100644 --- a/src/sail-codecs-archive/CMakeLists.txt +++ b/src/sail-codecs-archive/CMakeLists.txt @@ -46,86 +46,25 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/enabled_codecs.c.in # Add a combined library # -if (BUILD_SHARED_LIBS) - add_library(sail-codecs ${CMAKE_CURRENT_BINARY_DIR}/enabled_codecs.c) - target_link_libraries(sail-codecs PRIVATE sail-common) +add_library(sail-codecs ${CMAKE_CURRENT_BINARY_DIR}/enabled_codecs.c) +target_link_libraries(sail-codecs PRIVATE sail-common) - foreach(CODEC ${ENABLED_CODECS}) - target_link_libraries(sail-codecs PRIVATE $) - endforeach() - - sail_install_pdb(TARGET sail-codecs) - - install(TARGETS sail-codecs - EXPORT SailCodecsTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sail/sail-codecs) -else() - add_library(sail-codecs-objects codecs_objects_stub.c) - target_link_libraries(sail-codecs-objects PRIVATE sail-common) - - # BUILD_INTERFACE is needed as CMake tries to export all the sail-codec-${CODEC} dependencies - # in the below install(TARGETS) command even though they are OBJECT libraries. This is why we also - # use target_link_libraries(sail-codecs INTERFACE ...) later. - # - foreach(CODEC ${ENABLED_CODECS}) - target_link_libraries(sail-codecs-objects PRIVATE $) - endforeach() - - sail_install_pdb(TARGET sail-codecs-objects) - - # Add an extra library to link against it with a special 'whole archive' option. - # Without that option compilers throw functions away as they think they're unreferenced. - # We use dlsym/GetProcAddress to access them. - # - add_library(sail-codecs ${CMAKE_CURRENT_BINARY_DIR}/enabled_codecs.c) - target_link_libraries(sail-codecs PRIVATE sail-common) - - sail_install_pdb(TARGET sail-codecs) - - # Generate a 'whole archive' expression per compiler - # - set(ALLOWED_COMPILERS "MSVC" "Clang" "AppleClang" "GNU") - list(FIND ALLOWED_COMPILERS ${CMAKE_C_COMPILER_ID} ALLOWED_COMPILERS_INDEX) - - if (ALLOWED_COMPILERS_INDEX LESS 0) - message(FATAL_ERROR "Don't know how to build a compiler option for '${CMAKE_C_COMPILER_ID}'") - endif() - - target_link_libraries( - sail-codecs - PRIVATE - $:-WHOLEARCHIVE:$>> - $:-Wl,-force_load,$>> - $:-Wl,-force_load,$>> - $:-Wl,--whole-archive\ $\ -Wl,--no-whole-archive>> - $:-WHOLEARCHIVE:$>> - $:-Wl,-force_load,$>> - $:-Wl,-force_load,$>> - $:-Wl,--whole-archive\ $\ -Wl,--no-whole-archive>> - ) - - # sail-codecs depends on sail-codecs-objects indirectly through the above link command. - # Make the dependency explicit. - # - add_dependencies(sail-codecs sail-codecs-objects) +# BUILD_INTERFACE is needed as CMake tries to export all the sail-codec-${CODEC} dependencies +# in the below install(TARGETS) command even though they are OBJECT libraries. +# +foreach(CODEC ${ENABLED_CODECS}) + target_link_libraries(sail-codecs PRIVATE $) +endforeach() - # External dependencies like libavif are exported through interfaces, grab them - # - foreach(CODEC ${ENABLED_CODECS}) - target_link_libraries(sail-codecs INTERFACE $) - endforeach() +target_include_directories(sail-codecs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../libsail) - install(TARGETS sail-codecs-objects sail-codecs - EXPORT SailCodecsTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sail/sail-codecs) -endif() +sail_install_pdb(TARGET sail-codecs) -target_include_directories(sail-codecs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../libsail) +install(TARGETS sail-codecs + EXPORT SailCodecsTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sail/sail-codecs) sail_install_cmake_config(TARGET "SailCodecs" FOLDER "sailcodecs" VERSION 1.0.0) diff --git a/src/sail-codecs-archive/codecs_objects_stub.c b/src/sail-codecs-archive/codecs_objects_stub.c deleted file mode 100644 index bb7e1335..00000000 --- a/src/sail-codecs-archive/codecs_objects_stub.c +++ /dev/null @@ -1,40 +0,0 @@ -/* This file is part of SAIL (https://github.com/smoked-herring/sail) - - Copyright (c) 2022 Dmitry Baryshev - - The MIT License - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - -#include "sail-common.h" - -/* - * The only purpose of this file is to create an empty sail-codecs-objects library - * in static mode. Why it's needed: - * - * We create sail-codecs-objects library to hold all codecs objects without any - * additional source files. CMake doesn't allow creating libraries without sources - * initially, so we need to specify any source file in add_library(). - * - * Export the function to make compilers happy so they don't complain on unused functions. - * The function is not used in SAIL. - */ -SAIL_EXPORT void sail_codecs_objects_stub_function_for_static_build(void) { -}