Skip to content

Commit

Permalink
Make config.h generatable for CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
widgetii committed Feb 27, 2021
1 parent dd246ab commit 7d3223e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
21 changes: 18 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
Expand Down
16 changes: 8 additions & 8 deletions cmake/config.h → cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Version number...
*/

#define MXML_VERSION "Mini-XML v3.2"
#cmakedefine MXML_VERSION "@MXML_VERSION@"


/*
Expand All @@ -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


/*
Expand Down

0 comments on commit 7d3223e

Please sign in to comment.