Add CMakeLists.txt stuff

This commit is contained in:
Dmitry Ilyin 2021-02-27 12:40:49 +03:00
parent ab78fd816f
commit e11139a18c
2 changed files with 57 additions and 0 deletions

55
CMakeLists.txt Normal file
View File

@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.8)
set(VERSION 3.2)
project(
mxml
VERSION ${VERSION}
LANGUAGES C)
set(SOURCES
mxml-attr.c
mxml-entity.c
mxml-file.c
mxml-get.c
mxml-index.c
mxml-node.c
mxml-private.c
mxml-search.c
mxml-set.c
mxml-string.c)
set(HEADERS mxml-private.h)
configure_file(config.h.in config.h)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
add_library(MSweet::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
# install library
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES
DESTINATION include)
install(
EXPORT ${PROJECT_NAME}Targets
DESTINATION lib/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE MSweet::)
install(FILES mxml.h DESTINATION include)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES ${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME})

2
mxmlConfig.cmake Normal file
View File

@ -0,0 +1,2 @@
include(CMakeFindDependencyMacro)
include("${CMAKE_CURRENT_LIST_DIR}/mxmlTargets.cmake")