Cmake

From the project home page, http://www.cmake.org/

CMake is a the cross-platform, open-source build system. CMake is a family
of tools designed to build, test and package software. CMake is used to
control the software compilation process using simple platform and compiler
independent configuration files. CMake generates native makefiles and
workspaces that can be used in the compiler environment of your choice.

Put simply, CMake is another alternative to the widely used but usually cumbersome autotools suite.

"What does this have to do with Tcl?" you may wonder...

Here is a simple CMakeLists.txt file that you can use to build a stubs-enabled Tcl extension on any platform that supports it and runs CMake:

#
# Your project here...
#
project (my_extension C)


# in 2.6+, stubs are split off into a separate file
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
  find_package (TclStub REQUIRED)
ELSE (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
  find_package(TCL REQUIRED)
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)


# list out the sources for your project
set (SRCS my_extension.c more_code.c etc.c)

# define a target library
add_library (my_extension SHARED ${SRCS})


# this forces the target library not to begin with "lib"
set_target_properties (my_extension PROPERTIES PREFIX "")


#
# set the C flags you'll need, specify that the stub library
# should be linked into your project, and set the include paths
#
add_definitions (-DUSE_TCL_STUBS)
target_link_libraries (my_extension ${TCL_STUB_LIBRARY})
include_directories (${TCL_INCLUDE_PATH})

For more information on stub-enabled extensions, see the Stubs page.


Twylite 2011-04-19 The Coffee project (http://dev.crypt.co.za/coffee/home ) is an experiment in building Tcl 8.6 using CMake. As of today it can build a static tclsh for WIN32 from Tcl 8.6 trunk (Fossil checkout ef35e2c747) using CMake 2.8.4 and either NMake or the MSVC10 IDE (.sln).