Examples

I will try to cover more usage details in the following examples.

Multiple Executables

This project involves multiple executables in one project. Source files can be found here.

SimpleUsage
|   CMakeLists.txt
|   gcd.dats                    # compute GCD using lambda
|   lambda.dats                 # implementation of simple lambda calculas
|   lambda.sats                 # definition of simple lambda calculas
|   lambda_env.dats             # lambda evaluation environment
|   prime.dats                  # compute prime number using lambda
|
\---build                               # out-of-source build dir
        ...

What we want are two executables, gcd and prime.

CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT (SIMPLE_USAGE C)

FIND_PACKAGE (ATS REQUIRED)
IF (NOT ATS_FOUND)
	MESSAGE (FATAL_ERROR "ATS Not Found!")
ENDIF ()

SET (LAMBDA lambda.sats lambda.dats lambda_env.dats)

ATS_COMPILE (GCD_SRC ${LAMBDA} gcd.dats)
ATS_COMPILE (PRIME_SRC ${LAMBDA} prime.dats)

ADD_EXECUTABLE (gcd ${GCD_SRC})
ADD_EXECUTABLE (prime ${PRIME_SRC})

Local CMake Modules

Sometimes, you may want to use these CMake moduls locally. I will modify the last example with locally loaded ATS modules. Source files can be found here.

LocalModule
|   CMakeLists.txt
|   gcd.dats
|   lambda.dats
|   lambda.sats
|   lambda_env.dats
|   prime.dats
|
+---build
\---cmake
        ATSCC.cmake
        FindATS.cmake

I put the CMake modules under ${CMAKE_CURRENT_SOURCE_DIR}/cmake. And the CMakeLists.txt should be updated as follows.

CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT (SIMPLE_USAGE C)

SET (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
INCLUDE (ATSCC)

FIND_PACKAGE (ATS REQUIRED)
IF (NOT ATS_FOUND)
	MESSAGE (FATAL_ERROR "ATS Not Found!")
ENDIF ()

SET (LAMBDA lambda.sats lambda.dats lambda_env.dats)

ATS_COMPILE (GCD_SRC ${LAMBDA} gcd.dats)
ATS_COMPILE (PRIME_SRC ${LAMBDA} prime.dats)

ADD_EXECUTABLE (gcd ${GCD_SRC})
ADD_EXECUTABLE (prime ${PRIME_SRC})