From f633a2af497aa3ee7b8cfa8988d744b7fffe34aa Mon Sep 17 00:00:00 2001 From: bensalem amine Date: Mon, 9 Sep 2024 22:31:49 +0100 Subject: [PATCH] Build: Added from source QT build - 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. --- .github/workflows/cmake-single-platform.yml | 27 +-- .gitmodules | 53 +++-- CMakeLists.txt | 9 +- Documentation/Requirements.txt | 6 + cmake/BuildQt6.cmake | 65 ++++++ cmake/FindDependencies.cmake | 3 - cmake/FindSDL.cmake | 242 ++++++++++++++++++++ cmake/FindSDL_image.cmake | 102 +++++++++ scripts/update_deps.sh | 23 +- vendor/qt | 1 + 10 files changed, 489 insertions(+), 42 deletions(-) create mode 100644 Documentation/Requirements.txt create mode 100644 cmake/BuildQt6.cmake create mode 100644 cmake/FindSDL.cmake create mode 100644 cmake/FindSDL_image.cmake create mode 160000 vendor/qt diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index 0724c72f..414b71e4 100644 --- a/.github/workflows/cmake-single-platform.yml +++ b/.github/workflows/cmake-single-platform.yml @@ -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: @@ -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 @@ -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 \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 9c3e85f4..c3446add 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index bd28f8b8..bc4925fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Documentation/Requirements.txt b/Documentation/Requirements.txt new file mode 100644 index 00000000..07cc1c08 --- /dev/null +++ b/Documentation/Requirements.txt @@ -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) \ No newline at end of file diff --git a/cmake/BuildQt6.cmake b/cmake/BuildQt6.cmake new file mode 100644 index 00000000..11adf08e --- /dev/null +++ b/cmake/BuildQt6.cmake @@ -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}") + + + + + + + + + + + + + + diff --git a/cmake/FindDependencies.cmake b/cmake/FindDependencies.cmake index ad257e40..355eb07d 100644 --- a/cmake/FindDependencies.cmake +++ b/cmake/FindDependencies.cmake @@ -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) diff --git a/cmake/FindSDL.cmake b/cmake/FindSDL.cmake new file mode 100644 index 00000000..a4c86681 --- /dev/null +++ b/cmake/FindSDL.cmake @@ -0,0 +1,242 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindSDL +------- + +Locate the SDL library + + +Imported targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.19 + +This module defines the following :prop_tgt:`IMPORTED` target: + +``SDL::SDL`` + The SDL library, if found + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``SDL_INCLUDE_DIRS`` + where to find SDL.h +``SDL_LIBRARIES`` + the name of the library to link against +``SDL_FOUND`` + if false, do not try to link to SDL +``SDL_VERSION`` + the human-readable string containing the version of SDL if found +``SDL_VERSION_MAJOR`` + SDL major version +``SDL_VERSION_MINOR`` + SDL minor version +``SDL_VERSION_PATCH`` + SDL patch version + +.. versionadded:: 3.19 + Added the ``SDL_INCLUDE_DIRS``, ``SDL_LIBRARIES`` and ``SDL_VERSION[_]`` + variables. + +Cache variables +^^^^^^^^^^^^^^^ + +These variables may optionally be set to help this module find the correct files: + +``SDL_INCLUDE_DIR`` + where to find SDL.h +``SDL_LIBRARY`` + the name of the library to link against + + +Variables for locating SDL +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This module responds to the flag: + +``SDL_BUILDING_LIBRARY`` + If this is defined, then no SDL_main will be linked in because + only applications need main(). + Otherwise, it is assumed you are building an application and this + module will attempt to locate and set the proper link flags + as part of the returned SDL_LIBRARY variable. + + +Obsolete variables +^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 3.19 + +These variables are obsolete and provided for backwards compatibility: + +``SDL_VERSION_STRING`` + the human-readable string containing the version of SDL if found. + Identical to SDL_VERSION + + +Don't forget to include SDLmain.h and SDLmain.m your project for the +OS X framework based version. (Other versions link to -lSDLmain which +this module will try to find on your behalf.) Also for OS X, this +module will automatically add the -framework Cocoa on your behalf. + + + +Additional Note: If you see an empty SDL_LIBRARY_TEMP in your +configuration and no SDL_LIBRARY, it means CMake did not find your SDL +library (SDL.dll, libsdl.so, SDL.framework, etc). Set +SDL_LIBRARY_TEMP to point to your SDL library, and configure again. +Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this +value as appropriate. These values are used to generate the final +SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY +does not get created. + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02 + +On OSX, this will prefer the Framework version (if found) over others. +People will have to manually change the cache values of SDL_LIBRARY to +override this selection or set the CMake environment +CMAKE_INCLUDE_PATH to modify the search paths. + +Note that the header path has changed from SDL/SDL.h to just SDL.h +This needed to change because "proper" SDL convention is #include +"SDL.h", not . This is done for portability reasons +because not all systems place things in SDL/ (see FreeBSD). +#]=======================================================================] + +cmake_policy(PUSH) +cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ + +find_path(SDL_INCLUDE_DIR SDL.h + HINTS + ENV SDLDIR + PATH_SUFFIXES SDL SDL12 SDL11 + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +# SDL-1.1 is the name used by FreeBSD ports... +# don't confuse it for the version number. +find_library(SDL_LIBRARY_TEMP + NAMES SDL SDL-1.1 + HINTS + ENV SDLDIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} +) + +# Hide this cache variable from the user, it's an internal implementation +# detail. The documented library variable for the user is SDL_LIBRARY +# which is derived from SDL_LIBRARY_TEMP further below. +set_property(CACHE SDL_LIBRARY_TEMP PROPERTY TYPE INTERNAL) + +if(NOT SDL_BUILDING_LIBRARY) + if(NOT SDL_INCLUDE_DIR MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDLmain for compatibility even though they don't + # necessarily need it. + find_library(SDLMAIN_LIBRARY + NAMES SDLmain SDLmain-1.1 + HINTS + ENV SDLDIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATHS + /opt + ) + endif() +endif() + +# SDL may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +if(NOT APPLE) + find_package(Threads) +endif() + +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -mwindows +if(MINGW) + set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW") +endif() + +if(SDL_LIBRARY_TEMP) + # For SDLmain + if(SDLMAIN_LIBRARY AND NOT SDL_BUILDING_LIBRARY) + list(FIND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL_MAIN_INDEX) + if(_SDL_MAIN_INDEX EQUAL -1) + set(SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" ${SDL_LIBRARY_TEMP}) + endif() + unset(_SDL_MAIN_INDEX) + endif() + + # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a preused variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + if(APPLE) + set(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa") + endif() + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + if(NOT APPLE) + set(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) + endif() + + # For MinGW library + if(MINGW) + set(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP}) + endif() + + # Set the final string here so the GUI reflects the final state. + set(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found") +endif() + +if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h") + file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}") + unset(SDL_VERSION_MAJOR_LINE) + unset(SDL_VERSION_MINOR_LINE) + unset(SDL_VERSION_PATCH_LINE) + set(SDL_VERSION ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH}) + set(SDL_VERSION_STRING ${SDL_VERSION}) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL + REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR + VERSION_VAR SDL_VERSION_STRING) + +if(SDL_FOUND) + set(SDL_LIBRARIES ${SDL_LIBRARY}) + set(SDL_INCLUDE_DIRS ${SDL_INCLUDE_DIR}) + if(NOT TARGET SDL::SDL) + add_library(SDL::SDL INTERFACE IMPORTED) + set_target_properties(SDL::SDL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${SDL_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${SDL_LIBRARY}") + endif() +endif() + +cmake_policy(POP) diff --git a/cmake/FindSDL_image.cmake b/cmake/FindSDL_image.cmake new file mode 100644 index 00000000..33a0695c --- /dev/null +++ b/cmake/FindSDL_image.cmake @@ -0,0 +1,102 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindSDL_image +------------- + +Locate SDL_image library + +This module defines: + +:: + + SDL_IMAGE_LIBRARIES, the name of the library to link against + SDL_IMAGE_INCLUDE_DIRS, where to find the headers + SDL_IMAGE_FOUND, if false, do not try to link against + SDL_IMAGE_VERSION_STRING - human-readable string containing the + version of SDL_image + + + +For backward compatibility the following variables are also set: + +:: + + SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES) + SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS) + SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND) + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. +#]=======================================================================] + +cmake_policy(PUSH) +cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_ + +if(NOT SDL_IMAGE_INCLUDE_DIR AND SDLIMAGE_INCLUDE_DIR) + set(SDL_IMAGE_INCLUDE_DIR ${SDLIMAGE_INCLUDE_DIR} CACHE PATH "directory cache +entry initialized from old variable name") +endif() +find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h + HINTS + ENV SDLIMAGEDIR + ENV SDLDIR + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include +) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(VC_LIB_PATH_SUFFIX lib/x64) +else() + set(VC_LIB_PATH_SUFFIX lib/x86) +endif() + +if(NOT SDL_IMAGE_LIBRARY AND SDLIMAGE_LIBRARY) + set(SDL_IMAGE_LIBRARY ${SDLIMAGE_LIBRARY} CACHE FILEPATH "file cache entry +initialized from old variable name") +endif() +find_library(SDL_IMAGE_LIBRARY + NAMES SDL_image + HINTS + ENV SDLIMAGEDIR + ENV SDLDIR + PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} +) + +if(SDL_IMAGE_INCLUDE_DIR AND EXISTS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h") + file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MAJOR "${SDL_IMAGE_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MINOR "${SDL_IMAGE_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_PATCH "${SDL_IMAGE_VERSION_PATCH_LINE}") + set(SDL_IMAGE_VERSION_STRING ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH}) + unset(SDL_IMAGE_VERSION_MAJOR_LINE) + unset(SDL_IMAGE_VERSION_MINOR_LINE) + unset(SDL_IMAGE_VERSION_PATCH_LINE) + unset(SDL_IMAGE_VERSION_MAJOR) + unset(SDL_IMAGE_VERSION_MINOR) + unset(SDL_IMAGE_VERSION_PATCH) +endif() + +set(SDL_IMAGE_LIBRARIES ${SDL_IMAGE_LIBRARY}) +set(SDL_IMAGE_INCLUDE_DIRS ${SDL_IMAGE_INCLUDE_DIR}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_image + REQUIRED_VARS SDL_IMAGE_LIBRARIES SDL_IMAGE_INCLUDE_DIRS + VERSION_VAR SDL_IMAGE_VERSION_STRING) + +# for backward compatibility +set(SDLIMAGE_LIBRARY ${SDL_IMAGE_LIBRARIES}) +set(SDLIMAGE_INCLUDE_DIR ${SDL_IMAGE_INCLUDE_DIRS}) +set(SDLIMAGE_FOUND ${SDL_IMAGE_FOUND}) + +mark_as_advanced(SDL_IMAGE_LIBRARY SDL_IMAGE_INCLUDE_DIR) + +cmake_policy(POP) diff --git a/scripts/update_deps.sh b/scripts/update_deps.sh index 575eb2ff..02c7e944 100755 --- a/scripts/update_deps.sh +++ b/scripts/update_deps.sh @@ -1,3 +1,24 @@ #!/bin/bash -git submodule update --init --recursive --force + + +ROOT="$(pwd)" +echo 'Downloading dependencies ...' + +# Initialize dependencies that also need their submodules downloaded as well +for dependency in assimp boost glm googletest imath libdeflate openexr SDL SDL_image stb zlib ; do + git submodule update --init --recursive vendor/$dependency +done + +git submodule update --init vendor/qt +echo 'Dependencies downloaded ...' +if [ -d "$ROOT/vendor/qt" ]; then + cd $ROOT/vendor/qt || exit +else + echo 'Error: The QT directory has not been created by submodule update ...' +fi + + +echo 'Setting up required QT submodules ...' + +./init-repository.pl --force --module-subset=qtbase diff --git a/vendor/qt b/vendor/qt new file mode 160000 index 00000000..63fdac38 --- /dev/null +++ b/vendor/qt @@ -0,0 +1 @@ +Subproject commit 63fdac3852a11acc6d814588c5876eb684c2dc5f