54 lines
1.5 KiB
CMake
54 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
project(xmlrpcpp)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
add_compile_options(-Wall -Wextra -Wpedantic -fPIC)
|
|
endif()
|
|
|
|
add_library(xmlrpcpp
|
|
src/XmlRpcClient.cpp
|
|
src/XmlRpcDispatch.cpp
|
|
src/XmlRpcServer.cpp
|
|
src/XmlRpcServerConnection.cpp
|
|
src/XmlRpcServerMethod.cpp
|
|
src/XmlRpcSocket.cpp
|
|
src/XmlRpcSource.cpp
|
|
src/XmlRpcUtil.cpp
|
|
src/XmlRpcValue.cpp
|
|
)
|
|
|
|
target_include_directories(xmlrpcpp
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
|
|
)
|
|
|
|
# --- Cài đặt thư viện vào hệ thống khi chạy make install ---
|
|
install(TARGETS xmlrpcpp
|
|
EXPORT xmlrpcpp-targets
|
|
ARCHIVE DESTINATION lib # Thư viện tĩnh .a
|
|
LIBRARY DESTINATION lib # Thư viện động .so
|
|
RUNTIME DESTINATION bin # File thực thi (nếu có)
|
|
INCLUDES DESTINATION include # Cài đặt include
|
|
)
|
|
|
|
install(
|
|
DIRECTORY include/
|
|
DESTINATION include/
|
|
)
|
|
|
|
# --- Xuất export set xmlrpcpp-targets thành file CMake module ---
|
|
# --- Tạo file lib/cmake/xmlrpcpp/xmlrpcpp-targets.cmake ---
|
|
# --- File này chứa cấu hình giúp project khác có thể dùng ---
|
|
# --- Find_package(xmlrpcpp REQUIRED) ---
|
|
# --- Target_link_libraries(my_app PRIVATE xmlrpcpp::xmlrpcpp) ---
|
|
install(EXPORT xmlrpcpp-targets
|
|
FILE xmlrpcpp-targets.cmake
|
|
NAMESPACE xmlrpcpp::
|
|
DESTINATION lib/cmake/xmlrpcpp
|
|
)
|