Skip to content

Bridge to CMake to handle pre-built automake libraries from 'common' #12

@Miha22

Description

@Miha22

There has to be note to create/generate: AUTHORS Changelog NEWS, config (for autoheader) and "m4" dir, and issue in utils.c to include <sys/time> but not time

Suggesting improvements in makefiles (.am), instead of forcing to have folder 'common' would be better to have relative include $(srcdir) in AM_CPPFLAGS.

1) AM_CPPFLAGS = -I$(srcdir)/rb_tree 
AM_CPPFLAGS = -I$(srcdir)/rb_tree 

instead of 

AM_CPPFLAGS = -I$(top_srcdir)/common/libinterval3/rb_tree

2) 

libinterval3_la_SOURCES = \
	interval_tree.c

libinterval3_la_LIBADD = rb_tree/librbtree.la \
			$(CONDITIONAL_LIBS)

instead of

libinterval3_la_LIBADD = $(top_builddir)/common/libinterval3/rb_tree/librbtree.la \
			$(CONDITIONAL_LIBS)

3) Remove header from 
libinterval3_la_SOURCES = \
	interval_tree.c interval_tree.h


because headers dont belong in *_SOURCES. They should only be included in AM_CPPFLAGS of needed.

4) Add short CmakeLists.txt

add_library(cccommon
    libpatricia/patricia.c
    //rest if needed kuje libinterval3/interval_tree.h (for interval tree the red black tree as well)
)

# Add include directories
target_include_directories(cccommon PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/libpatricia
    .... // the rest if needed like ${CMAKE_CURRENT_SOURCE_DIR}/libcsv
    etc.
)

-------------------------
In improved case user can submodule the cc-common to any directory such as **lib/cccommon**. 

In the source proeject CMakeLists.txt to add subdirectory to invoke short CMakeLists.txt and link it.

add_subdirectory(lib/cccommon)
target_include_directories(my_project_name PRIVATE
    ${CMAKE_SOURCE_DIR}/lib/cccommon
    ${CMAKE_SOURCE_DIR}/lib/cccommon/libpatricia
    // and the rest like ${CMAKE_SOURCE_DIR}/lib/cccommon/libcsv
    //etc.
)

------------------------
packges: autoconf automake libtool
----------------------------
autoreconf -i
 ./configure
make
-------------
cmake -S . -B
cmake --build build

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions