Make config.h generatable for CMake

This commit is contained in:
Dmitry Ilyin 2021-02-27 14:01:38 +03:00
parent dd246ab5f0
commit 7d3223e14b
2 changed files with 26 additions and 11 deletions

View File

@ -7,6 +7,24 @@ project(
VERSION ${VERSION} VERSION ${VERSION}
LANGUAGES C) 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 set(SOURCES
mxml-attr.c mxml-attr.c
mxml-entity.c mxml-entity.c
@ -19,9 +37,6 @@ set(SOURCES
mxml-set.c mxml-set.c
mxml-string.c) mxml-string.c)
#configure_file(config.h.in config.h)
set(HEADERS mxml-private.h cmake/config.h)
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS}) add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_library(MSweet::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) add_library(MSweet::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

View File

@ -24,7 +24,7 @@
* Version number... * Version number...
*/ */
#define MXML_VERSION "Mini-XML v3.2" #cmakedefine MXML_VERSION "@MXML_VERSION@"
/* /*
@ -38,25 +38,25 @@
* Long long support... * Long long support...
*/ */
#define HAVE_LONG_LONG 1 #cmakedefine HAVE_LONG_LONG 1
/* /*
* Do we have the *printf() functions? * Do we have the *printf() functions?
*/ */
#define HAVE_SNPRINTF 1 #cmakedefine HAVE_SNPRINTF 1
#define HAVE_VASPRINTF 1 #cmakedefine HAVE_VASPRINTF 1
#define HAVE_VSNPRINTF 1 #cmakedefine HAVE_VSNPRINTF 1
/* /*
* Do we have the strXXX() functions? * Do we have the strXXX() functions?
*/ */
#define HAVE_STRDUP 1 #cmakedefine HAVE_STRDUP 1
#define HAVE_STRLCAT 1 #cmakedefine HAVE_STRLCAT 1
#define HAVE_STRLCPY 1 #cmakedefine HAVE_STRLCPY 1
/* /*