tomato/cmake/ModulePackage.cmake
Green Sky b2ae9530a4 Squashed 'external/toxcore/c-toxcore/' changes from e29e185c03..f1df709b87
f1df709b87 feat: add ngc events
1b6c907235 refactor: Make event dispatch ordered by receive time.
b7f9367f6f test: Upgrade cppcheck, fix some warnings.
766e62bc89 chore: Use `pkg_search_module` directly in cmake.
00ff078f91 cleanup: Use target_link_libraries directly in cmake.
c58928cc89 chore: Add `IMPORTED_TARGET` to pkg-config packages.
895a6af122 cleanup: Remove NaCl support.
41dfb1c1c0 fix: unpack enum function names in event impl generator
447666d1a1 chore: Disable targets for cross-compilation.
572924e924 chore: Build a docker image with coverage info in it.
415cb78f5e cleanup: Some portability/warning fixes for Windows builds.
425216d9ec fix: Correct a use-after-free and fix some memory leaks.
4b1cfa3e08 refactor: Change all enum-like `#define` sequences into enums.
d3c2704fa9 chore: Fix make_single_file to support core-only.
0ce46b644e refactor: Change the `TCP_PACKET_*` defines into an enum.
22cd38ad50 adopt event impl generation tool to #2392
f31ea1088a add the event impl generation tool
4e603bb613 refactor: Use `enum-from-int` rule from tokstyle.
19d8f180d6 chore: Update github actions `uses`.
6a895be0c7 test: Make esp32 build actually try to instantiate tox.
65d09c9bfb cleanup: Remove test net support.
REVERT: e29e185c03 feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: f1df709b8792da4c0e946d826b11df77d565064d
2023-12-27 12:37:22 +01:00

81 lines
2.3 KiB
CMake

option(ENABLE_SHARED "Build shared (dynamic) libraries for all modules" ON)
option(ENABLE_STATIC "Build static libraries for all modules" ON)
if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
message(WARNING
"Both static and shared libraries are disabled; "
"enabling only shared libraries. Use -DENABLE_SHARED or -DENABLE_STATIC to "
"select one manually.")
set(ENABLE_SHARED ON)
endif()
option(FULLY_STATIC "Build fully static executables" OFF)
if(FULLY_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-static -no-pie")
# remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(ENABLE_SHARED OFF)
set(ENABLE_STATIC ON)
endif()
find_package(PkgConfig)
function(add_module lib)
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
if(ENABLE_SHARED)
add_library(${lib}_shared SHARED ${ARGN})
set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib})
endif()
if(ENABLE_STATIC)
add_library(${lib}_static STATIC ${ARGN})
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
endif()
endfunction()
function(install_module lib)
if(TARGET ${lib}_shared)
set_target_properties(${lib}_shared PROPERTIES
VERSION ${SOVERSION}
SOVERSION ${SOVERSION_MAJOR}
)
install(TARGETS ${lib}_shared
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(TARGET ${lib}_static)
install(TARGETS ${lib}_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
string(REPLACE ";" " " ${lib}_PKGCONFIG_LIBS "${${lib}_PKGCONFIG_LIBS}")
string(REPLACE ";" " " ${lib}_PKGCONFIG_REQUIRES "${${lib}_PKGCONFIG_REQUIRES}")
configure_file(
"${${lib}_SOURCE_DIR}/other/pkgconfig/${lib}.pc.in"
"${CMAKE_BINARY_DIR}/${lib}.pc"
@ONLY
)
configure_file(
"${toxcore_SOURCE_DIR}/other/rpm/${lib}.spec.in"
"${CMAKE_BINARY_DIR}/${lib}.spec"
@ONLY
)
install(FILES
${CMAKE_BINARY_DIR}/${lib}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
foreach(sublib ${${lib}_API_HEADERS})
string(REPLACE "^" ";" sublib ${sublib})
list(GET sublib 0 header)
install(FILES ${header} ${ARGN})
endforeach()
endfunction()