From 525865705119be05b858789c3b5ee2189b51a8e2 Mon Sep 17 00:00:00 2001 From: Lance Wallis Date: Mon, 17 Jun 2024 19:40:32 -0500 Subject: [PATCH] Cmake configure for config.h. --- CMakeLists.txt | 32 +++++++++++++++++++++++++++++++- cmakeconfig.h.in | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 cmakeconfig.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f5dd4b..d989a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.19) # First to support Apple Silicon. -project(mxml C) +project(mxml LANGUAGES C VERSION 4.0.4) enable_testing() # Don't allow source tree pollution. @@ -18,6 +18,36 @@ if(WIN32) ) endif(WIN32) +# ==================== CONFIG.H ==================== +# For now this is not thorough, but enough to work for +# the vast majority of cases. + +include(CheckIncludeFile) +include(CheckTypeSize) + +set(MXML_VERSION ${CMAKE_PROJECT_VERSION}) + +if(SIZEOF_LONG_LONG EQUAL "8") + option(HAVE_LONG_LONG_INT "Enable LONG LONG" ON) +else() + option(HAVE_LONG_LONG_INT "Enable LONG LONG" OFF) +endif() + +if (WIN32) + option(HAVE_PTHREAD_H "Disable PTHREAD for windows." OFF) +else() + option(HAVE_PTHREAD_H "Enable PTHREAD as it's probably available." ON) +endif() + +# For now assume inline on. +option(inline "Enable inline function support." ON) + +configure_file(cmakeconfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h + @ONLY +) + +# ==================== /CONFIG.H ==================== + set(MXML_PRIVATE mxml-attr.c mxml-file.c diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in new file mode 100644 index 0000000..bb4d6fc --- /dev/null +++ b/cmakeconfig.h.in @@ -0,0 +1,42 @@ +// +// A CMake compatible version for config.h.in -> config.h +// + +#ifndef MXML_CONFIG_H +# define MXML_CONFIG_H +# include +# include +# include +# include +# include + + +// +// Version number +// + +#cmakedefine MXML_VERSION "@CMAKE_PROJECT_VERSION@" + + +// +// Inline function support +// + +#cmakedefine inline + + +// +// Long long support +// + +#cmakedefine01 HAVE_LONG_LONG_INT + + +// +// Have ? +// + +#cmakedefine01 HAVE_PTHREAD_H + + +#endif // !MXML_CONFIG_H