change cmake build instructions in README.md (#2300)

* change cmake build instructions in README.md


---------

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
waveproc
2025-08-02 18:11:57 -04:00
committed by GitHub
parent f23bbb342c
commit 1c4f7a4b61

View File

@@ -276,14 +276,15 @@ See the `build-with-docker.sh` script for more information on other configurable
#### Installing on OS X using Homebrew #### Installing on OS X using Homebrew
2. Install CMake: `brew install cmake` 1. Install [Homebrew](https://brew.sh/)
3. Install LLVM 17+: `brew install llvm` 2. Install LLVM 17+: `brew install llvm`
4. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git` 3. Install lld: `brew install lld`
5. Enter the C3C directory `cd c3c`. 4. Install CMake: `brew install cmake`
6. Create a build directory `mkdir build` 5. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git`
7. Change directory to the build directory `cd build` 6. Enter the C3C directory `cd c3c`.
8. Set up CMake build for debug: `cmake ..` 7. Set up CMake build for debug: `cmake -B build -S .`
9. Build: `cmake --build .` 8. Build: `cmake --build build`
9. Change directory to the build directory `cd build`
#### Installing on Windows using Scoop #### Installing on Windows using Scoop
@@ -347,13 +348,12 @@ You should now have a `c3c` executable in `build-debug\Debug`.
#### Compiling on Ubuntu 24.04 LTS #### Compiling on Ubuntu 24.04 LTS
1. Make sure you have a C compiler that handles C11 and a C++ compiler, such as GCC or Clang. Git also needs to be installed. 1. Make sure you have a C compiler that handles C11 and a C++ compiler, such as GCC or Clang. Git also needs to be installed.
2. Install LLVM 18 `sudo apt-get install cmake git clang zlib1g zlib1g-dev libllvm18 llvm llvm-dev llvm-runtime liblld-dev liblld-18 libpolly-18-dev` 2. Install LLVM 18 `sudo apt-get install cmake git clang zlib1g zlib1g-dev libllvm18 llvm llvm-dev llvm-runtime liblld-dev liblld-18 libpolly-18-dev`. If you're using Ubuntu 25.04, also install `libpolly-20-dev`.
3. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git` 3. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git`
4. Enter the C3C directory `cd c3c`. 4. Enter the C3C directory `cd c3c`.
5. Create a build directory `mkdir build` 5. Set up CMake build: `cmake -B build -S .`
6. Change directory to the build directory `cd build` 6. Build: `cmake --build build`
7. Set up CMake build: `cmake ..` 7. Change directory to the build directory `cd build`
8. Build: `cmake --build .`
You should now have a `c3c` executable. You should now have a `c3c` executable.
@@ -366,13 +366,12 @@ You can try it out by running some sample code: `./c3c compile ../resources/exam
2. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git` 2. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git`
- If you only need the latest commit, you may want to make a shallow clone instead: `git clone https://github.com/c3lang/c3c.git --depth=1` - If you only need the latest commit, you may want to make a shallow clone instead: `git clone https://github.com/c3lang/c3c.git --depth=1`
3. Enter the directory: `cd c3c` 3. Enter the directory: `cd c3c`
4. Create a build directory: `mkdir build` 4. Create the CMake build cache: `cmake -B build -S .`
5. Enter the build directory: `cd build` 5. Build: `cmake --build build`
6. Create the CMake build cache: `cmake ..` 6. Enter the build directory: `cd build`
7. Build: `cmake --build .`
Your c3c executable should have compiled properly. You may want to test it: `./c3c compile ../resources/examples/hash.c3` Your c3c executable should have compiled properly. You may want to test it: `./c3c compile ../resources/examples/hash.c3`
For a sytem-wide installation, run the following as root: `cmake --install .` For a system-wide installation, run the following as root: `cmake --install .`
#### Compiling on Fedora #### Compiling on Fedora
@@ -382,15 +381,15 @@ For a sytem-wide installation, run the following as root: `cmake --install .`
3. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git` 3. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git`
- If you only need the latest commit, you may want to make a shallow clone: `git clone https://github.com/c3lang/c3c.git --depth=1` - If you only need the latest commit, you may want to make a shallow clone: `git clone https://github.com/c3lang/c3c.git --depth=1`
4. Enter the C3C directory: `cd c3c` 4. Enter the C3C directory: `cd c3c`
5. Create a build directory and navigate into it: `mkdir build && cd build` 5. Create the CMake build cache. The Fedora repositories provide `.so` libraries for lld, so you need to set the C3_LINK_DYNAMIC flag: `cmake -B build -S . -DC3_LINK_DYNAMIC=1`
6. Create the CMake build cache. The Fedora repositories provide `.so` libraries for lld, so you need to set the C3_LINK_DYNAMIC flag: `cmake .. -DC3_LINK_DYNAMIC=1` 6. Build the project: `cmake --build build`
7. Build the project: `cmake --build .` 7. Enter the build directory: `cd build`
The c3c binary should be created in the build directory. You can try it out by running some sample code: `./c3c compile ../resources/examples/hash.c3` The c3c binary should be created in the build directory. You can try it out by running some sample code: `./c3c compile ../resources/examples/hash.c3`
#### Compiling on Arch Linux #### Compiling on Arch Linux
1. Install required project dependencies: `sudo pacman -S curl lld llvm-libs clang cmake git libedit llvm` 1. Install required project dependencies: `sudo pacman -S curl lld llvm-libs clang cmake git libedit llvm libxml2`
2. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git` 2. Clone the C3C repository: `git clone https://github.com/c3lang/c3c.git`
- If you only need the latest commit, you may want to make a shallow clone: `git clone https://github.com/c3lang/c3c.git --depth=1` - If you only need the latest commit, you may want to make a shallow clone: `git clone https://github.com/c3lang/c3c.git --depth=1`
3. Enter the C3C directory: `cd c3c` 3. Enter the C3C directory: `cd c3c`
@@ -400,7 +399,7 @@ cmake -B build \
-D C3_LINK_DYNAMIC=ON \ -D C3_LINK_DYNAMIC=ON \
-D CMAKE_BUILD_TYPE=Release -D CMAKE_BUILD_TYPE=Release
``` ```
5. Build the project: `make -C build`. 5. Build the project: `cmake --build build`.
After compilation, the `c3c` binary will be located in the `build` directory. You can test it by compiling an example: `./build/c3c compile resources/examples/ls.c3`. After compilation, the `c3c` binary will be located in the `build` directory. You can test it by compiling an example: `./build/c3c compile resources/examples/ls.c3`.
@@ -412,11 +411,10 @@ After compilation, the `c3c` binary will be located in the `build` directory. Yo
2. Install or compile LLVM and LLD *libraries* (version 17+ or higher) 2. Install or compile LLVM and LLD *libraries* (version 17+ or higher)
3. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git` 3. Clone the C3C github repository: `git clone https://github.com/c3lang/c3c.git`
4. Enter the C3C directory `cd c3c`. 4. Enter the C3C directory `cd c3c`.
5. Create a build directory `mkdir build` 5. Set up CMake build for debug: `cmake -B build -S .`. At this point you may need to manually
6. Change directory to the build directory `cd build` provide the link path to the LLVM CMake directories, e.g. `cmake -B build -S . -DLLVM_DIR=/usr/local/opt/llvm/lib/cmake/llvm/`
7. Set up CMake build for debug: `cmake ..`. At this point you may need to manually 6. Build: `cmake --build build`
provide the link path to the LLVM CMake directories, e.g. `cmake -DLLVM_DIR=/usr/local/opt/llvm/lib/cmake/llvm/ ..` 7. Change directory to the build directory `cd build`
8. Build: `cmake --build .`
*A note on compiling for Linux/Unix/MacOS: to be able to fetch vendor libraries *A note on compiling for Linux/Unix/MacOS: to be able to fetch vendor libraries
libcurl is needed. The CMake script should detect it if it is available. Note that libcurl is needed. The CMake script should detect it if it is available. Note that