2024-08-25 12:04:55 +00:00
|
|
|
cmake_minimum_required(VERSION 3.30)
|
|
|
|
|
|
|
|
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
|
|
|
|
# This specific value changes as experimental support evolves. See
|
|
|
|
# `Help/dev/experimental.rst` in the CMake source corresponding to
|
|
|
|
# your CMake build for the exact value to use.
|
|
|
|
"0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
|
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
project(larra
|
2024-08-25 12:04:55 +00:00
|
|
|
VERSION 0.1
|
|
|
|
LANGUAGES CXX)
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(FMT_MODULE ON)
|
|
|
|
set(CXX_EXTENSIONS NO)
|
|
|
|
set(BOOST_INCLUDE_LIBRARIES "pfr")
|
|
|
|
option(CPM_USE_LOCAL_PACKAGES "Use local packages" ON)
|
|
|
|
|
2024-08-26 14:22:15 +00:00
|
|
|
file(GLOB_RECURSE LIB_SOURCES "src/lib/*.cpp")
|
2024-08-25 12:04:55 +00:00
|
|
|
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
2024-08-26 14:22:15 +00:00
|
|
|
file(GLOB_RECURSE IMPL_SOURCES "src/*_impl.cpp")
|
|
|
|
file(GLOB_RECURSE LIB_IMPL_SOURCES "src/lib/*_impl.cpp")
|
|
|
|
list(REMOVE_ITEM LIB_SOURCES ${LIB_IMPL_SOURCES})
|
|
|
|
list(REMOVE_ITEM SOURCES ${IMPL_SOURCES} ${LIB_SOURCES})
|
2024-08-25 12:04:55 +00:00
|
|
|
set(CMAKE_CXX_MODULE_STD 1)
|
|
|
|
|
|
|
|
set_target_properties(__cmake_cxx23 PROPERTIES CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
file(
|
|
|
|
DOWNLOAD
|
|
|
|
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.0/CPM.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
|
|
|
|
EXPECTED_HASH
|
|
|
|
SHA256=7b354f3a5976c4626c876850c93944e52c83ec59a159ae5de5be7983f0e17a2a
|
|
|
|
)
|
|
|
|
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
|
|
|
|
|
|
|
|
find_package(PkgConfig)
|
|
|
|
|
|
|
|
pkg_check_modules(GTKMM gtkmm-4.0)
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
${GTKMM_LIBRARY_DIRS} )
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${GTKMM_INCLUDE_DIRS} )
|
|
|
|
|
|
|
|
CPMAddPackage(
|
|
|
|
NAME Boost
|
|
|
|
VERSION 1.85.0
|
|
|
|
URL "https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz"
|
|
|
|
EXCLUDE_FROM_ALL ON
|
|
|
|
OPTIONS "BOOST_SKIP_INSTALL_RULES OFF"
|
|
|
|
)
|
|
|
|
|
|
|
|
set(TMP ${CPM_USE_LOCAL_PACKAGES})
|
|
|
|
set(CPM_USE_LOCAL_PACKAGES OFF)
|
|
|
|
|
|
|
|
|
|
|
|
CPMAddPackage("gh:fmtlib/fmt#11.0.2")
|
|
|
|
|
|
|
|
set(CPM_USE_LOCAL_PACKAGES ${TMP})
|
|
|
|
|
|
|
|
CPMAddPackage(
|
|
|
|
NAME utempl
|
|
|
|
URL "https://github.com/linuxnyasha/utempl/archive/refs/heads/main.zip"
|
|
|
|
EXCLUDE_FROM_ALL ON
|
|
|
|
OPTIONS "ENABLE_TESTS OFF" "ENABLE_EXAMPLES OFF"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmake_policy(SET CMP0079 NEW)
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
add_library(larra_xmpp)
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
add_library(larra::larra_xmpp ALIAS larra_xmpp)
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
target_compile_features(larra_xmpp INTERFACE cxx_std_23)
|
|
|
|
|
|
|
|
target_sources(larra_xmpp PUBLIC FILE_SET larraXMPPSet TYPE CXX_MODULES
|
2024-08-25 12:04:55 +00:00
|
|
|
FILES ${LIB_SOURCES})
|
|
|
|
|
2024-08-26 14:22:15 +00:00
|
|
|
target_sources(larra_xmpp PUBLIC ${LIB_IMPL_SOURCES})
|
|
|
|
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
install(TARGETS larra_xmpp
|
|
|
|
EXPORT larraXMPPTargets
|
2024-08-25 12:04:55 +00:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2024-08-26 04:29:16 +00:00
|
|
|
FILE_SET larraXMPPSet DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2024-08-25 12:04:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(TARGET Boost::pfr)
|
2024-08-26 04:55:09 +00:00
|
|
|
target_link_libraries(larra_xmpp INTERFACE
|
2024-08-25 12:04:55 +00:00
|
|
|
Boost::pfr utempl::utempl ${GTKMM_LIBRARIES})
|
|
|
|
else()
|
|
|
|
find_package(Boost 1.85.0 REQUIRED)
|
2024-08-26 04:55:09 +00:00
|
|
|
target_link_libraries(larra_xmpp INTERFACE
|
2024-08-25 12:04:55 +00:00
|
|
|
utempl::utempl ${Boost_LIBRARIES} ${GTKMM_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
add_executable(larra)
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
target_compile_features(larra INTERFACE cxx_std_23)
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
target_link_libraries(larra larra_xmpp)
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
target_sources(larra PUBLIC FILE_SET larraSet TYPE CXX_MODULES
|
2024-08-25 12:04:55 +00:00
|
|
|
FILES ${SOURCES})
|
|
|
|
|
2024-08-26 14:22:15 +00:00
|
|
|
target_sources(larra PUBLIC ${IMPL_SOURCES})
|
2024-08-25 12:04:55 +00:00
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
install(TARGETS larra
|
2024-08-25 12:04:55 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
2024-08-26 04:29:16 +00:00
|
|
|
write_basic_package_version_file("larraXMPPVersionConfig.cmake"
|
2024-08-25 12:04:55 +00:00
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion)
|
|
|
|
|
|
|
|
configure_package_config_file(
|
2024-08-26 04:29:16 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/cmake/larraXMPPConfig.cmake.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/larraXMPPConfig.cmake"
|
2024-08-25 12:04:55 +00:00
|
|
|
INSTALL_DESTINATION
|
|
|
|
${CMAKE_INSTALL_DATAROOTDIR}/xmpp_client/cmake)
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
install(EXPORT larraXMPPTargets
|
2024-08-25 12:04:55 +00:00
|
|
|
FILE xmppClientLibTargets.cmake
|
2024-08-26 04:29:16 +00:00
|
|
|
NAMESPACE larra::
|
2024-08-25 12:04:55 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xmpp_client/cmake)
|
|
|
|
|
2024-08-26 04:29:16 +00:00
|
|
|
install(FILES "${PROJECT_BINARY_DIR}/larraXMPPConfig.cmake"
|
|
|
|
"${PROJECT_BINARY_DIR}/larraXMPPVersionConfig.cmake"
|
2024-08-25 12:04:55 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/xmpp_client/cmake)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ENABLE_TESTS)
|
|
|
|
find_package(GTest REQUIRED)
|
|
|
|
enable_testing()
|
|
|
|
file(GLOB_RECURSE SOURCES "tests/*.cpp" )
|
2024-08-26 04:29:16 +00:00
|
|
|
add_executable(larra_xmpp_tests)
|
|
|
|
target_sources(larra_xmpp_tests PUBLIC FILE_SET tests TYPE CXX_MODULES
|
2024-08-25 12:04:55 +00:00
|
|
|
FILES ${SOURCES})
|
2024-08-26 04:29:16 +00:00
|
|
|
target_link_libraries(larra_xmpp_tests GTest::gtest_main
|
2024-08-25 12:04:55 +00:00
|
|
|
xmpp_client_lib)
|
2024-08-26 04:29:16 +00:00
|
|
|
set_property(TARGET larra_xmpp_tests PROPERTY CXX_STANDARD 23)
|
2024-08-25 12:04:55 +00:00
|
|
|
include(GoogleTest)
|
2024-08-26 04:29:16 +00:00
|
|
|
gtest_discover_tests(larra_xmpp_tests)
|
2024-08-25 12:04:55 +00:00
|
|
|
endif()
|