Welcome¶
This is a project aiming at developing a build tool for ATS. It is based on CMake. Currently, it provides some very useful CMake modules for ATS users to simplify building processes. In the near future, it will support downloading artifacts from a server to help you utilize third party ATS libraries.
The project is hosted on GitHub. Welcome to contribute.
Table of Contents¶
Features¶
- It uses CMake, which is cross platform.
- Automatic dependency resolving. This is especially useful, and is first supported by this project.
- Easy to use.
Quick Start¶
Install CMake. You can download them from CMake Website.
Note
Version 2.8.3+ required, since
ATS-CMake
usesCMAKE_CURRENT_LIST_DIR
variableInstall ATS from ATS Website.
Note
You need to setup environment variables
ATSHOME
andPATH
properly.ATS-CMake
use them to locate your currently available ATS binaries. For example:export ATSHOME=/cs/coursedata/cs320/ATS029 export ATSHOMERELOC=ATS-0.2.9 export PATH=$PATH:$ATSHOME/bin
Download this project from GitHub. Particularly,
FindATS.cmake
andATSCC.cmake
.Copy those CMake modules into CMake module dir.
Note
Normally, the module dir is
/usr/share/cmake-x.x.x/Modules
. You can find more information at CMake Website.Start using it!
Hello World¶
Suppose you have a small project containing hello.sats
, hello.dats
and main.dats
. Then, you need to write a CMakeLists.txt
like the following
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
#Specify project name as HELLOWORLD, and project language as C. Yes, it is C
PROJECT (HELLOWORLD C)
#Actually, this makes CMake to find ATSCC.cmake using FindATS.cmake
FIND_PACKAGE (ATS REQUIRED)
#The ATS_FOUND is automatically set by FindATS.cmake module
IF (NOT ATS_FOUND)
MESSAGE (FATAL_ERROR "ATS Not Found!")
ENDIF ()
#ATS_COMIPLE is the core of this project. To put it simple,
#you just specify related SATS/DATS files here, and use a variable
#like TEST_SRC to store the outputs. ATS_COMPILE will analyze their
#dependencies, compile them into C files, and store those C file
#names into TEST_SRC
#You can use ATS_INCLUDE to add search paths for the compiler to
#find proper SATS/HATS files.
ATS_COMPILE (TEST_SRC
hello.sats
hello.dats
main.dats)
#It generate the final file "test" using all the C files in TEST_SRC.
#And this is a standard CMake command
ADD_EXECUTABLE (test ${TEST_SRC})
After you have a correct CMakeLists.txt
, we just need to invoke cmake
. But please make sure that you have a correct project layout.
HelloWorld
| CMakeLists.txt
| hello.dats
| hello.sats
| main.dats
|
\---build
...
Note
I suggest using out-of-source build, which makes everything clean, especially when you want to delete all temp files. See here for more information. I use a ./build
dir for this purpose.
Now, go to ./build
and invoke cmake
. It will generate a makefile
for you under ./build
. You can invoke make
now, to build the project as usual, and congratulations! The output binary will be under ./build
>>> cd ./build
>>> cmake ..
...
>>> make
...
Note
We use cmake ..
because the present working directory is ./build
, while the CMakeLists.txt
is in the parent directory. Therefore, it is cmake ..
instead of cmake .
. Pay attention.
What’s Next¶
In the followings, I will try to cover more use cases, and then look into what’s happening in the CMake modules, so that you can better use them, and even help me develop it.