diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..050e24f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,48 @@ +set (PACKAGE Mk4tcl) +project (${PACKAGE}) +cmake_minimum_required (VERSION 3.10) + +option (BUILD_SHARED_LIBS "Build Shared Libraries." ON) + +# Set up some variables that we can use in our code. +set (VERSION 1.0) +add_definitions (-DHAVE_CONFIG_H) +include_directories (${CMAKE_CURRENT_BINARY_DIR}) + +include (CheckTypeSize) +CHECK_TYPE_SIZE("long" SIZEOF_LONG) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +# Fix for static library linking to shared library on 64 bit systems: +# with -fPIC +IF(UNIX AND NOT WIN32) + FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) + IF(CMAKE_UNAME) + EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) + SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL + "processor type (i386 and x86_64)") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + ADD_DEFINITIONS(-fPIC) + ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + ENDIF(CMAKE_UNAME) +ENDIF(UNIX AND NOT WIN32) + +add_subdirectory(src) +add_subdirectory(tcl) + +# the following lines are needed to build debian/ubuntu packages. +set (CPACK_DEBIAN_PACKAGE_NAME ${PACKAGE}) +set (CPACK_DEBIAN_PACKAGE_VERSION ${VERSION}) +set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) +set (CPACK_DEBIAN_PACKAGE_DEPENDS "tcl8.6 (>=8.6.5)") +set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Sam Bromley ") +set (CPACK_DEBIAN_PACKAGE_DESCRIPTION "Metakit for Tcl") +set (CPACK_DEBIAN_PACKAGE_SECTION "devel") +set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +set (DEBIAN_PACKAGE_BUILDS_DEPENDS "tcl8.6-dev (>=8.6.5)") +set (CPACK_GENERATOR "DEB") +set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PATH_PREFIX}/${PACKAGE}/") +set (CPACK_COMPONENTS_ALL libraries headers executables) +set (CPACK_SET_DESTDIR TRUE) +include(CPack) diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..f2cbdd7 --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,15 @@ +/* Name of package */ +#cmakedefine PACKAGE @PACKAGE@ +/* Define to the address where bug reports for this package should be sent. */ +#cmakedefine PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@ +/* Define to the full name of this package. */ +#cmakedefine PACKAGE_NAME @PACKAGE_NAME@ +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING @PACKAGE_STRING@ +/* Define to the one symbol short name of this package. */ +#cmakedefine PACKAGE_TARNAME @PACKAGE_TARNAME@ +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION @PACKAGE_VERSION@ +/* Version number of package */ +#cmakedefine VERSION @VERSION@ +#cmakedefine SIZEOF_LONG @SIZEOF_LONG@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..f71865b --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,48 @@ +include_directories(../include) +include_directories(.) + +########### next target ############### +set (mk_SRCS + column.cpp + column.h + custom.cpp + custom.h + derived.cpp + derived.h + fileio.cpp + field.cpp + field.h + format.cpp + format.h + handler.cpp + handler.h + header.h + persist.cpp + persist.h + remap.cpp + remap.h + std.cpp + std.h + store.cpp + store.h + string.cpp + table.cpp + univ.cpp + univ.h + view.cpp + viewx.cpp +) + +#MSVC needs static .lib files to work properly +IF(WIN32 OR MSVC) + add_library(mk SHARED ${mk_SRCS}) +else(WIN32 OR MSVC) + add_library(mk SHARED ${mk_SRCS}) +ENDIF(WIN32 OR MSVC) + +set_target_properties (mk PROPERTIES VERSION 1.0 SOVERSION 1 INSTALL_RPATH_USE_LINK_PATH on INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + +########### install files ############### + +# Targets +install(TARGETS mk DESTINATION lib COMPONENT libraries) diff --git a/tcl/CMakeLists.txt b/tcl/CMakeLists.txt new file mode 100644 index 0000000..44ba894 --- /dev/null +++ b/tcl/CMakeLists.txt @@ -0,0 +1,55 @@ +include (FindTclStub) +option (USE_TCL_STUBS "Enable use of TCL stubs library") + +include (FindPkgConfig) +ADD_DEFINITIONS("-std=c++11") + +include (FindTclStub) +if (USE_TCL_STUBS) +ADD_DEFINITIONS("-DUSE_TCL_STUBS") +endif (USE_TCL_STUBS) + +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}) + +include_directories(${TCL_INCLUDE_PATH}) +include_directories(../include) + +include_directories(.) + +set (Mk4tcl_SRCS + ../src/custom.cpp + ../src/column.cpp + ../src/derived.cpp + ../src/field.cpp + ../src/fileio.cpp + ../src/format.cpp + ../src/handler.cpp + ../src/persist.cpp + ../src/remap.cpp + ../src/std.cpp + ../src/store.cpp + ../src/string.cpp + ../src/table.cpp + ../src/univ.cpp + ../src/view.cpp + ../src/viewx.cpp + mk4tcl.cpp + mk4tcl.h + mk4too.cpp +) + +add_library(Mk4tcl SHARED ${Mk4tcl_SRCS}) + +if (USE_TCL_STUBS) + target_link_libraries(Mk4tcl ${TCL_STUB_LIBRARY}) +else (USE_TCL_STUBS) + target_link_libraries(Mk4tcl ${TCL_LIBRARY}) +endif (USE_TCL_STUBS) + +set_target_properties (Mk4tcl PROPERTIES VERSION 0.1 SOVERSION 0 PREFIX "" INSTALL_RPATH_USE_LINK_PATH on INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/${PACKAGE}") + +install(TARGETS Mk4tcl DESTINATION lib/${PACKAGE}) + +install(FILES + pkgIndex.tcl + DESTINATION lib/${PACKAGE}) diff --git a/tcl/pkgIndex.tcl b/tcl/pkgIndex.tcl new file mode 100644 index 0000000..a7c0396 --- /dev/null +++ b/tcl/pkgIndex.tcl @@ -0,0 +1,3 @@ +package ifneeded Mk4tcl 2.4.9.7 \ + [list load [file join $dir Mk4tcl.so] Mk4tcl] +