Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use cmake_minimum instead of cmake_policy #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.12)
project(VCalcBase)

# Ensure tool dependencies.
Expand Down
64 changes: 8 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,18 @@ The base cmake setup for VCalc assignment.
Author: Braedy Kuzma ([email protected])
Updated by: Deric Cheung ([email protected])

# Usage
## Installing MLIR
In this assignment and your final project you will be working with MLIR and LLVM.
Due to the complex nature (and size) of the project we did not want to include
MLIR as a subproject. Therefore, there is some additional setup required to get your
build up and running.
# Building
CMake will use the environment variables ANTLR_INS, ANTLR_JAR, and MLIR_DIR
to find locally installed builds of ANTLR and MLIR.
See the [setup document](https://webdocs.cs.ualberta.ca/~c415/setup/)
to find out how to install these packages on your machine.

### On a personal machine
The first thing you should do is have a look into the `configureLLVM.sh` script
in the scripts folder and understand as much as possible. We'll touch some
things briefly here that are better explained there. The steps here will expect
you have some knowledge of what's going on inside the script.

1. Checkout LLVM to your machine
1. `cd $HOME`
1. `git clone https://github.com/llvm/llvm-project.git`
1. `cd llvm-project`
1. `git checkout llvmorg-16.0.4`
1. Build MLIR
1. `mkdir build`
1. `cd build`
1. ```cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="Native" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON
```
1. `cmake --build . --target check-mlir`
1. Add these configuration lines to your ``~/.bashrc`` on linux or
``~/.zprofile`` on MacOS to setup the next steps. You should restart your
terminal after editing these files.
```bash
export MLIR_INS="$HOME/llvm-project/build/"
export MLIR_DIR="$MLIR_INS/lib/cmake/mlir/" # Don't change me.
export PATH="$MLIR_INS/bin:$PATH" # Don't change me
```
1. CMake should automatically pick up your built mlir now. You should return
to the assignment specification to complete setup.

### On university machines
You won't be building MLIR on the university machines: AICT wouldn't be very
happy with you. Instead, we are providing a **RELEASE** build available for
everyone.
1. Follow the instructions on the [setup
page](https://webdocs.cs.ualberta.ca/~c415/setup/) for the CS computers and
MLIR/LLVM will be available to you.

## Building
### Linux
1. Install git, java (only the runtime is necessary), and cmake (>= v3.0).
- Until now, cmake has found the dependencies without issues. If you
encounter an issue, let a TA know and we can fix it.
1. Make a directory that you intend to build the project in and change into
that directory.
1. Run `cmake <path-to-VCalc-Base>`.
1. Run `make`.
1. Done.
2. Run `cmake <path-to-VCalcBase>`.
3. Run `make`.

## Pulling in upstream changes
# Pulling in upstream changes
If there are updates to your assignment you can retrieve them using the
instructions here.
1. Add the upstream as a remote using `git remote add upstream <clone-link>`.
Expand Down
37 changes: 14 additions & 23 deletions cmake/get_antlr.cmake
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
# A module to obtain the ANTLR C++ runtime. It attempts to find a locally installed copy of the
# runtime pointed to by an environment variable called ANTLR_INS. Can swap in get_antlr_manual
# if you'd rather have it auto-install a copy just for this project (more space).

# CMake module that finds a previously installed copy of the ANTLR C++ runtime required when linking
# a generated lexer/parser. Creates the variable ANTLR_INCLUDE_DIRS to add to your target's
# include directories, adds the antlr library path to the project, allows your target to link
# against antlr4-runtime, creates ANTLR_JAR for generating grammars, and creates an antlr target
# that you can add via add_dependencies to make sure everything has happened already.
# A module to obtain the ANTLR C++ runtime. It attempts to find a locally installed
# copy of the runtime pointed to by an environment variable called ANTLR_INS.
# The module also looks for the environment variable ANTLR_JAR, which is used
# to generate the lexer and parser.
# Creates the variable ANTLR_INCLUDE_DIRS to add to your target's include
# directories, adds the antlr library path to the project, allows your target
# to link against antlr4-runtime, and creates an antlr target that you can add
# via add_dependencies to make sure everything has happened already.

# Get the environment variable that tells us where the manual install was.
if (NOT DEFINED ENV{ANTLR_INS})
message(FATAL_ERROR "Did you forget to install ANTLR? The ANTLR_INS environment variable was "
"not set.")
message(FATAL_ERROR "Did you forget to install ANTLR?"
"The ANTLR_INS environment variable was not set.")
endif()
file(TO_CMAKE_PATH "$ENV{ANTLR_INS}" _ANTLR_DIR)

# Set the directory for binaries.
file(TO_CMAKE_PATH "${_ANTLR_DIR}/bin" BIN_DIR) # Join dir.
set(BIN_DIR ${BIN_DIR} CACHE PATH "ANTLR jar directory.") # Set for internal use.

# Download ANTLR executable, saves us from ensuring people have java build tools (e.g. Maven)...
file(TO_CMAKE_PATH "${BIN_DIR}/antlr-4.13.0-complete.jar" ANTLR_JAR)
if (NOT EXISTS "${ANTLR_JAR}")
message(STATUS "Downloading ANTLR generator...")
file(
DOWNLOAD
http://www.antlr.org/download/antlr-4.13.0-complete.jar
"${ANTLR_JAR}"
SHOW_PROGRESS
)
file(TO_NATIVE_PATH "${BIN_DIR}" BIN_DIR_NATIVE) # Transform for display.
message(STATUS "Downloaded ANTLR jar destination: ${BIN_DIR_NATIVE}")
# Find the ANTLR binary
if (NOT DEFINED ENV{ANTLR_JAR})
message(FATAL_ERROR "The ANTLR_JAR environment variable is not set")
endif()
set(ANTLR_JAR "$ENV{ANTLR_JAR}")

# Check that the base include path exists.
if (NOT EXISTS "${_ANTLR_DIR}/include/antlr4-runtime/")
Expand Down
79 changes: 0 additions & 79 deletions cmake/get_antlr_manual.cmake

This file was deleted.