--- ./CMakeLists.txt.orig +++ ./CMakeLists.txt @@ -1,10 +1,11 @@ cmake_policy(SET CMP0091 NEW) project(libarcus) cmake_minimum_required(VERSION 3.20) -find_package(standardprojectsettings REQUIRED) -find_package(protobuf 3.17.1 REQUIRED) +include(CMakePackageConfigHelpers) +find_package(Protobuf REQUIRED) + set(arcus_SRCS src/Socket.cpp src/SocketListener.cpp @@ -13,14 +14,20 @@ src/Error.cpp ) +set(arcus_HDRS + include/Arcus/Socket.h + include/Arcus/SocketListener.h + include/Arcus/Types.h + include/Arcus/MessageTypeStore.h + include/Arcus/Error.h +) + if(BUILD_SHARED_LIBS) add_library(Arcus SHARED ${arcus_SRCS}) else() add_library(Arcus STATIC ${arcus_SRCS}) endif() -use_threads(Arcus) - target_include_directories(Arcus PUBLIC $ @@ -41,3 +48,33 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") target_compile_definitions(Arcus PRIVATE -DARCUS_DEBUG) endif() + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +set_target_properties(Arcus PROPERTIES + FRAMEWORK FALSE + VERSION ${ARCUS_VERSION} + PUBLIC_HEADER "${arcus_HDRS}" +) + +configure_package_config_file(ArcusConfig.cmake.in ${CMAKE_BINARY_DIR}/ArcusConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus) +write_basic_package_version_file(${CMAKE_BINARY_DIR}/ArcusConfigVersion.cmake VERSION ${ARCUS_VERSION} COMPATIBILITY SameMajorVersion) + +install(FILES + ${CMAKE_BINARY_DIR}/ArcusConfig.cmake + ${CMAKE_BINARY_DIR}/ArcusConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus +) + +install(TARGETS Arcus + EXPORT Arcus-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Arcus +) + +install(EXPORT Arcus-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus +) +