diff --git a/CMakeLists.txt b/CMakeLists.txt index 8daabc5..41fe9b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,24 @@ project( 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 @@ -19,9 +37,6 @@ set(SOURCES mxml-set.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}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) add_library(MSweet::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) diff --git a/cmake/config.h b/cmake/config.h.in similarity index 77% rename from cmake/config.h rename to cmake/config.h.in index ebcc302..e81b88c 100644 --- a/cmake/config.h +++ b/cmake/config.h.in @@ -24,7 +24,7 @@ * Version number... */ -#define MXML_VERSION "Mini-XML v3.2" +#cmakedefine MXML_VERSION "@MXML_VERSION@" /* @@ -38,25 +38,25 @@ * Long long support... */ -#define HAVE_LONG_LONG 1 +#cmakedefine HAVE_LONG_LONG 1 /* * Do we have the *printf() functions? */ -#define HAVE_SNPRINTF 1 -#define HAVE_VASPRINTF 1 -#define HAVE_VSNPRINTF 1 +#cmakedefine HAVE_SNPRINTF 1 +#cmakedefine HAVE_VASPRINTF 1 +#cmakedefine HAVE_VSNPRINTF 1 /* * Do we have the strXXX() functions? */ -#define HAVE_STRDUP 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRLCPY 1 +#cmakedefine HAVE_STRDUP 1 +#cmakedefine HAVE_STRLCAT 1 +#cmakedefine HAVE_STRLCPY 1 /*