diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eea65609..071457cb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -421,6 +421,13 @@ endif() # Make the OBJECT library for haicrypt and srt. Then they'll be bound into # real libraries later, either one common, or separate. +# This is needed for Xcode to properly handle CMake OBJECT Libraries +# From docs (https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries): +# +# ... Some native build systems (such as Xcode) may not like targets that have only object files, +# so consider adding at least one real source file to any target that references $. +set(OBJECT_LIB_SUPPORT "${PROJECT_SOURCE_DIR}/cmake_object_lib_support.c") + add_library(haicrypt_virtual OBJECT ${SOURCES_haicrypt} ${SOURCES_common}) # NOTE: The "virtual library" is a library specification that cmake @@ -462,7 +469,7 @@ endif() set (VIRTUAL_srt $ $) if (srt_libspec_shared) - add_library(${TARGET_srt}_shared SHARED ${VIRTUAL_srt}) + add_library(${TARGET_srt}_shared SHARED ${OBJECT_LIB_SUPPORT} ${VIRTUAL_srt}) # shared libraries need PIC set_property(TARGET ${TARGET_srt}_shared PROPERTY OUTPUT_NAME ${TARGET_srt}) set_target_properties (${TARGET_srt}_shared PROPERTIES VERSION ${SRT_VERSION} SOVERSION ${SRT_VERSION_MAJOR}) @@ -476,7 +483,7 @@ if (srt_libspec_shared) endif() if (srt_libspec_static) - add_library(${TARGET_srt}_static STATIC ${VIRTUAL_srt}) + add_library(${TARGET_srt}_static STATIC ${OBJECT_LIB_SUPPORT} ${VIRTUAL_srt}) # For Windows, leave the name to be "srt_static.lib". # Windows generates two different library files: diff --git a/cmake_object_lib_support.c b/cmake_object_lib_support.c new file mode 100644 index 000000000..dd1d89038 --- /dev/null +++ b/cmake_object_lib_support.c @@ -0,0 +1,9 @@ +// DO NOT DELETE +// This file is needed for Xcode to properly handle CMake OBJECT Libraries +// From docs (https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries): +// +// ... Some native build systems (such as Xcode) may not like targets that have only object files, +// so consider adding at least one real source file to any target that references $. + +// Just a dummy symbol to avoid compiler warnings +int srt_object_lib_dummy = 0;