Skip to content

Commit

Permalink
Build: Added from source QT build
Browse files Browse the repository at this point in the history
- Allows to build QT from the same toolchain than the executable, and not rely on the system libraries.

- This fixes incompatible linking symbols in case the user needs to compile with older versions of his compiler to access CUDA features.
  • Loading branch information
HamilcarR committed Sep 18, 2024
1 parent 5804760 commit f633a2a
Show file tree
Hide file tree
Showing 10 changed files with 489 additions and 42 deletions.
27 changes: 5 additions & 22 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Tests
name: Build and Tests

on:
push:
Expand All @@ -11,29 +9,16 @@ on:
branches: [ "master" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: RelWithDebInfo
BUILD_TESTS : ON

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.3.*'
host: 'linux'
target: 'desktop'
arch: 'gcc_64'
install-deps : 'true'

- name: Install Axomae dependencies
run: |
cd ${{github.workspace}} && ./scripts/update_deps.sh
Expand All @@ -43,20 +28,18 @@ jobs:
sudo apt-get install -y libgl1-mesa-dev libglew-dev
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/../build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DAXOMAE_BUILD_TESTS:BOOL=${{env.BUILD_TESTS}} -DAXOMAE_LUT_MEDIUMP:BOOL=ON
run: cmake -B ${{github.workspace}}/../build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DAXOMAE_BUILD_TESTS:BOOL=${{env.BUILD_TESTS}} -DAXOMAE_LUT_MEDIUMP:BOOL=ON -DAXOMAE_FROMSOURCE_QT_BUILD=ON

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/../build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/../build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}


#####################################################
# For debugging , opens an ssh cli
# - name: Setup tmate session
# if: success() || failure()
# uses: mxschmitt/action-tmate@v3
53 changes: 38 additions & 15 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,59 +1,82 @@
[submodule "vendor/stb"]
path = vendor/stb
url = https://github.com/nothings/stb
ignore = all

[submodule "vendor/googletest"]
path = vendor/googletest
url = https://github.com/google/googletest
ignore = all
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/glm"]
path = vendor/glm
url = https://github.com/g-truc/glm
ignore = all
branch = v1.0.1
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/boost"]
path = vendor/boost
url = https://github.com/boostorg/boost
ignore = all
branch = boost-1.86.0
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/assimp"]
path = vendor/assimp
url = https://github.com/assimp/assimp
ignore = all
branch = v5.4.2
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/googletest"]
path = vendor/googletest
url = https://github.com/google/googletest
ignore = all
branch = v1.15.2
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/openexr"]
path = vendor/openexr
url = https://github.com/AcademySoftwareFoundation/openexr
ignore = all
branch = v3.2.4
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/zlib"]
path = vendor/zlib
url = https://github.com/madler/zlib
ignore = all
branch = v1.3.1
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/imath"]
path = vendor/imath
url = https://github.com/AcademySoftwareFoundation/Imath
ignore = all
branch = v3.1.9
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/libdeflate"]
path = vendor/libdeflate
url = https://github.com/ebiggers/libdeflate
ignore = all
url = https://github.com/ebiggers/libdeflate
branch = v1.9
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/SDL_image"]
path = vendor/SDL_image
url = https://github.com/libsdl-org/SDL_image
branch = SDL2
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/SDL"]
path = vendor/SDL
url = https://github.com/libsdl-org/SDL
branch = SDL2
ignore = all
fetchRecurseSubmodules = true

[submodule "vendor/qt"]
path = vendor/qt
url = https://code.qt.io/qt/qt5.git
branch = 6.8.0
ignore = all
fetchRecurseSubmodules = false
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ option(AXOMAE_LUT_HIGHP "Enable high precision when computing lookup tables." OF
option(AXOMAE_LUT_MEDIUMP "Enable medium precision when computing lookup tables." ON)
option(AXOMAE_LUT_LOWP "Enable low precision when computing lookup tables." OFF)
option(AXOMAE_BUILD_TESTS "Build unit tests." ON)

option(AXOMAE_FROMSOURCE_QT_BUILD "Build QT from source." ON)
#****************************************************************************************************
# Dependencies
if(AXOMAE_FROMSOURCE_QT_BUILD)
include(cmake/BuildQt6.cmake)
else()
find_package(Qt6 COMPONENTS Gui REQUIRED)
find_package(Qt6 COMPONENTS OpenGLWidgets REQUIRED)
find_package(Qt6 COMPONENTS Widgets REQUIRED)
endif()
include(cmake/FindDependencies.cmake)

if(NOT CUDAToolkit_FOUND)
Expand Down
6 changes: 6 additions & 0 deletions Documentation/Requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Ninja (only for building QT6 from source)
QT6
GCC (version depends on desired cuda version if gpgpu used)
Opengl
Glew
Cuda (if AXOMAE_USE_CUDA set to ON)
65 changes: 65 additions & 0 deletions cmake/BuildQt6.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

set(QT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/vendor/qt)
set(QT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/qt)
set(QTBASE_BUILD_DIR ${QT_BUILD_DIR}/qtbase)
set(QTBASE_SOURCE_DIR ${QT_SOURCE_DIR}/qtbase)

message(STATUS "Building QT from source : ${QT_SOURCE_DIR}")
message(STATUS "Build directory is : ${QT_BUILD_DIR}")

message(STATUS "Initializing qt repository ...")

message(STATUS "Configuring qtbase...")
if(NOT EXISTS "${QT_BUILD_DIR}")
file(MAKE_DIRECTORY ${QT_BUILD_DIR})
endif()
execute_process(COMMAND bash ${QT_SOURCE_DIR}/configure
-submodules qtbase
-prefix ${QT_BUILD_DIR}

WORKING_DIRECTORY ${QT_BUILD_DIR}
ERROR_VARIABLE ERROR_MSG
)

message(STATUS ${ERROR_MSG})

message(STATUS "Building qtbase ...")
execute_process(COMMAND cmake --build . --parallel 4
WORKING_DIRECTORY ${QT_BUILD_DIR}
)

message(STATUS "Installing qtbase ...")
execute_process(COMMAND cmake --install .
WORKING_DIRECTORY ${QT_BUILD_DIR}
)


list(APPEND CMAKE_MODULE_PATH ${QT_BUILD_DIR}/lib/cmake)
list(APPEND CMAKE_PREFIX_PATH ${QT_BUILD_DIR}/lib/cmake)
message(STATUS "Setting up local qt build path ...")
find_package(Qt6
COMPONENTS Gui OpenGLWidgets Widgets
REQUIRED
PATHS ${CMAKE_PREFIX_PATH}
CONFIG
NO_DEFAULT_PATH
)

message(STATUS "Qt6_DIR: ${Qt6_DIR}")
message(STATUS "Qt6Gui_DIR: ${Qt6Gui_DIR}")
message(STATUS "Qt6OpenGLWidgets_DIR: ${Qt6OpenGLWidgets_DIR}")
message(STATUS "Qt6Widgets_DIR: ${Qt6Widgets_DIR}")














3 changes: 0 additions & 3 deletions cmake/FindDependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
find_package(Qt6 COMPONENTS Gui REQUIRED)
find_package(Qt6 COMPONENTS OpenGLWidgets REQUIRED)
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
find_package(CUDAToolkit)
Expand Down
Loading

0 comments on commit f633a2a

Please sign in to comment.