Compare commits

...

5 Commits

Author SHA1 Message Date
Dmitry Ilyin
1cf32d3abc
Merge 7d3223e14b into 95445118c2 2024-10-05 08:43:30 +05:00
Dmitry Ilyin
7d3223e14b Make config.h generatable for CMake 2021-02-27 14:01:38 +03:00
Dmitry Ilyin
dd246ab5f0 Move CMake stuff to separate directory 2021-02-27 13:10:39 +03:00
Dmitry Ilyin
bc02a80705 Fix paths 2021-02-27 12:51:28 +03:00
Dmitry Ilyin
e11139a18c Add CMakeLists.txt stuff 2021-02-27 12:40:49 +03:00
3 changed files with 143 additions and 0 deletions

67
CMakeLists.txt Normal file
View File

@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.8)
set(VERSION 3.2)
project(
mxml
VERSION ${VERSION}
LANGUAGES C)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(CheckTypeSize)
check_type_size("long long" HAVE_LONG_LONG)
include(CheckFunctionExists)
check_function_exists(snprintf HAVE_SNPRINTF)
check_function_exists(vasprintf HAVE_VASPRINTF)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(strdup HAVE_STRDUP)
check_function_exists(strlcat HAVE_STRLCAT)
check_function_exists(strlcpy HAVE_STRLCPY)
set(MXML_VERSION "Mini-XML v${VERSION}")
configure_file(cmake/config.h.in config.h)
set(HEADERS mxml-private.h ${CMAKE_CURRENT_BINARY_DIR}/config.h)
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)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
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 cmake/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME})

74
cmake/config.h.in Normal file
View File

@ -0,0 +1,74 @@
/*
* Xcode configuration file for Mini-XML, a small XML file parsing library.
*
* https://www.msweet.org/mxml
*
* Copyright © 2003-2020 by Michael R Sweet.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
*/
/*
* Include necessary headers...
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
/*
* Version number...
*/
#cmakedefine MXML_VERSION "@MXML_VERSION@"
/*
* Inline function support...
*/
#define inline
/*
* Long long support...
*/
#cmakedefine HAVE_LONG_LONG 1
/*
* Do we have the *printf() functions?
*/
#cmakedefine HAVE_SNPRINTF 1
#cmakedefine HAVE_VASPRINTF 1
#cmakedefine HAVE_VSNPRINTF 1
/*
* Do we have the strXXX() functions?
*/
#cmakedefine HAVE_STRDUP 1
#cmakedefine HAVE_STRLCAT 1
#cmakedefine HAVE_STRLCPY 1
/*
* Do we have threading support?
*/
#define HAVE_PTHREAD_H 1
/*
* Define prototypes for string functions as needed...
*/
extern char *_mxml_strdupf(const char *, ...);
extern char *_mxml_vstrdupf(const char *, va_list);

2
cmake/mxmlConfig.cmake Normal file
View File

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