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

Add linux build instructions #60

Open
wants to merge 6 commits into
base: main
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
47 changes: 47 additions & 0 deletions {{cookiecutter.project_name}}/BUILD_LINUX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Build and Package {{cookiecutter.project_name}}

This document summarizes how to build and package {{cookiecutter.project_name}} on Linux.

{{cookiecutter.project_name}} is a custom Slicer application. Reading the [3D Slicer Developer Documentation](https://slicer.readthedocs.io/en/latest/developer_guide/index.html) may help answer additional questions.

The initial source files were created using [KitwareMedical/SlicerCustomAppTemplate](https://github.com/KitwareMedical/SlicerCustomAppTemplate).

## Clone

```sh
git clone https://github.com/{{cookiecutter.github_organization}}/{{cookiecutter.github_project}}.git
```

## Prerequisites

Install the prerequisites as described in the [Slicer documentation for building on Linux](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/linux.html). This includes development tools, support libraries, and Qt.

## Build

Note: The build process can take hours.

Build:

```sh
cmake \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DQt5_DIR:PATH=/opt/qt/5.15.2/gcc_64/lib/cmake/Qt5 \
-S {{cookiecutter.github_project}} \
-B {{cookiecutter.github_project}}-SuperBuild-Release
cd {{cookiecutter.github_project}}-SuperBuild-Release
make -j<N>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be best as is, though my usual approach is instead

cmake --build . -j<N>

(Actually, I usually also throw in a --config Release for good measure, but I have no idea whether that is useful.)

```

where `<N>` is the number of parallel builds. As a rule of thumb, many use the `number of CPU threads - 1` as the number of parallel builds.
On Ubuntu 20.04, the default Qt5 packages are too old and so the Slicer documentation linked above should have suggested a method of installing Qt 5.15.2;
if you installed it to `/opt/qt`, for example, then an extra option like `-DQt5_DIR:PATH=/opt/qt/5.15.2/gcc_64/lib/cmake/Qt5` would be needed in the `cmake` command above.

Once the application is built, there will be an _inner build_ inside the _superbuild_ folder, located at `{{cookiecutter.app_name}}-SuperBuild-Release/Slicer-build`. The application executable is contained in this _inner build_ folder.

## Package

From the _inner build_ folder:

```sh
make package
Copy link

@Leengit Leengit Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likwwise, it could be best as is, though my usual approach is instead from the superbuild folder

cmake --build . --target package -j<N>

(Also usually including --config Release.)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm wrong. I do that from the inner build folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the advantage is that it's a more platform-independent command.

I like that aspect of it, but I also prefer a simple and easy to remember command.

```
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ The initial source files were created using [KitwareMedical/SlicerCustomAppTempl

- Setup [your git username](https://help.github.com/articles/setting-your-username-in-git) and [your git email](https://help.github.com/articles/setting-your-email-in-git).

- If not already done, email `FirstName LastName <firstname.lastname@{{cookiecutter.github_organization}}.com>` to be granted access to
the [{{cookiecutter.github_organization}}/{{cookiecutter.github_project}}](https://github.com/{{cookiecutter.github_organization}}/{{cookiecutter.github_project}}) repository.

## Checkout

1. Start `Git Bash`
Expand All @@ -35,7 +32,7 @@ Note: use short source and build directory names to avoid the [maximum path leng

## Build

Note: The build process will take approximately 3 hours.
Note: The build process can take hours.

<b>Option 1: CMake GUI and Visual Studio (Recommended)</b>

Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ _List key features_
## Development

- [Contributing](CONTRIBUTING.md)
- [Building](BUILD.md)
- [Building on Windows](BUILD_WINDOWS.md)
- [Building on Linux](BUILD_LINUX.md)

![{{cookiecutter.project_name}} by {{cookiecutter.org_name}}](Applications/{{cookiecutter.app_name}}App/Resources/Images/LogoFull.png?raw=true)
Loading