Unify config generation logic
MODIFY
.gitignore
.gitignore
.dirstamp
Makefile.in
aclocal.m4
-config.h
-config.h.in
config.log
config.status
configure
-liblcf-*.tar.*
libtool
stamp-h1
*.la
@@ -22,7 +19,6 @@ stamp-h1
# cmake build method
bin/
-builds/liblcf-config.cmake
CMakeCache.txt
CMakeFiles/
*.cmake
@@ -65,6 +61,11 @@ Makefile
*.a
*.o
*.pc
+config.h
+builds/liblcf-config.cmake
# tests
test_runner*
+
+# distribution archives
+liblcf-*.tar.*

MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -336,17 +336,19 @@ set_property(TARGET lcf PROPERTY DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
set_property(TARGET lcf PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
# icu or fallback to iconv
+set(LCF_SUPPORT_ICU 0)
if(LIBLCF_WITH_ICU)
find_package(ICU COMPONENTS i18n uc data REQUIRED)
target_link_libraries(lcf ICU::i18n ICU::uc ICU::data)
list(APPEND LIBLCF_DEPS "icu-i18n")
- set(LCF_SUPPORT_ICU "1")
+ set(LCF_SUPPORT_ICU 1)
else()
find_package(Iconv REQUIRED)
target_link_libraries(lcf Iconv::Iconv)
endif()
# expat
+set(LCF_SUPPORT_XML 0)
if(LIBLCF_WITH_XML)
find_package(expat CONFIG)
if(expat_FOUND)
@@ -357,7 +359,7 @@ if(LIBLCF_WITH_XML)
target_link_libraries(lcf EXPAT::EXPAT)
endif()
list(APPEND LIBLCF_DEPS "expat")
- set(LCF_SUPPORT_XML "1")
+ set(LCF_SUPPORT_XML 1)
endif()
# mime types
@@ -365,7 +367,7 @@ if(LIBLCF_UPDATE_MIMEDB AND NOT CMAKE_CROSSCOMPILING)
find_program(UPDATE_MIME_DATABASE update-mime-database)
endif()
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake.config.h.in" "src/lcf/config.h" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/builds/config.h.in" "src/lcf/config.h" @ONLY)
target_sources(lcf PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src/lcf/config.h)
# .so version

MODIFY
Makefile.am
Makefile.am
@@ -23,7 +23,7 @@ lcfthirdpartyincludedir = $(includedir)/lcf/third_party
lib_LTLIBRARIES = liblcf.la
liblcf_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
- -I$(builddir)/autogen \
+ -I$(builddir)/src \
-I$(srcdir)/src \
-I$(srcdir)/src/generated
liblcf_la_CXXFLAGS = \
@@ -307,7 +307,7 @@ lcfthirdpartyinclude_HEADERS = \
src/lcf/third_party/span.h \
src/lcf/third_party/string_view.h
-nodist_lcfinclude_HEADERS = autogen/lcf/config.h
+nodist_lcfinclude_HEADERS = src/lcf/config.h
check_PROGRAMS = test_runner
test_runner_SOURCES = \

DELETE
builds/cmake.config.h.in
-/* Generated by cmake */
-
-/* Enable encoding detection (ICU) */
-#cmakedefine01 LCF_SUPPORT_ICU
-
-/* Enable XML reading support (expat) */
-#cmakedefine01 LCF_SUPPORT_XML
-

RENAME
builds/autoconf.config.h.in
builds/config.h.in
+/* Generated by the buildsystem DO NOT EDIT */
/* Enable encoding detection (ICU) */
#define LCF_SUPPORT_ICU @LCF_SUPPORT_ICU@

MODIFY
builds/liblcf-config.cmake.in
builds/liblcf-config.cmake.in
@@ -66,15 +66,12 @@ if(LIBLCF_FOUND)
if(NOT TARGET liblcf::liblcf)
add_library(liblcf::liblcf UNKNOWN IMPORTED)
- set(LIBLCF_LIBRARY_DEPS "@AX_PACKAGE_REQUIRES_PRIVATE@")
- string(REPLACE " " ";" LIBLCF_LIBRARY_DEPS "${LIBLCF_LIBRARY_DEPS}")
-
- foreach(dep ${LIBLCF_LIBRARY_DEPS})
- if(dep STREQUAL "icu-i18n")
+ if(@LCF_SUPPORT_ICU@)
find_package(ICU COMPONENTS i18n uc data REQUIRED QUIET)
list(APPEND LIBLCF_LIBRARIES ${ICU_LIBRARIES})
list(APPEND LIBLCF_LINK_LIBRARIES ICU::i18n ICU::uc ICU::data)
- elseif(dep STREQUAL "expat")
+ endif()
+ if(@LCF_SUPPORT_XML@)
find_package(expat CONFIG QUIET)
if(expat_FOUND)
list(APPEND LIBLCF_LINK_LIBRARIES expat::expat)
@@ -85,7 +82,6 @@ if(LIBLCF_FOUND)
endif()
list(APPEND LIBLCF_LIBRARIES ${EXPAT_LIBRARIES})
endif()
- endforeach()
set_target_properties(liblcf::liblcf PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
@@ -116,7 +112,7 @@ if(LIBLCF_FOUND)
COMPILE_FEATURES cxx_std_14)
endif()
- mark_as_advanced(LIBLCF_LIBRARY_DEPS LIBLCF_LINK_LIBRARIES)
+ mark_as_advanced(LIBLCF_LINK_LIBRARIES)
endif()
endif()

MODIFY
configure.ac
configure.ac
@@ -24,13 +24,13 @@ AM_CONDITIONAL(CROSS_COMPILING,[test "x$cross_compiling" = "xyes"])
AC_SUBST([LCF_SUPPORT_ICU],[0])
AC_ARG_ENABLE([icu],[AS_HELP_STRING([--disable-icu],[Disable ICU encoding detection (fallback to iconv) [default=no]])])
AS_IF([test "x$enable_icu" != "xno"],[
- AX_PKG_CHECK_MODULES([ICU],[],[icu-i18n],[AC_SUBST([LCF_SUPPORT_ICU],[1])])
+ AX_PKG_CHECK_MODULES([ICU],[],[icu-i18n],[LCF_SUPPORT_ICU=1])
])
AC_SUBST([LCF_SUPPORT_XML],[0])
AC_ARG_ENABLE([xml],[AS_HELP_STRING([--disable-xml],[Disable XML reading support (expat) [default=no]])])
AS_IF([test "x$enable_xml" != "xno"],[
- AX_PKG_CHECK_MODULES([EXPAT],[],[expat >= 2.1],[AC_SUBST([LCF_SUPPORT_XML],[1])])
+ AX_PKG_CHECK_MODULES([EXPAT],[],[expat >= 2.1],[LCF_SUPPORT_XML=1])
])
AM_CONDITIONAL(SUPPORT_XML,[test $LCF_SUPPORT_XML == 1])
@@ -77,6 +77,6 @@ AC_SUBST([CMAKE_DEBUG_POSTFIX])
AC_CONFIG_FILES([Makefile
builds/liblcf.pc
builds/liblcf-config.cmake
- autogen/lcf/config.h:builds/autoconf.config.h.in])
+ src/lcf/config.h:builds/config.h.in])
AC_OUTPUT

Unify config generation logic