diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad80a89f..f8bd4ca2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: include: - - name: win64_msvc2022 + - name: windows_msvc2022_x64 os: windows-2022 build_type: Release env_cc: '' @@ -34,7 +34,7 @@ jobs: qt_modules: qtimageformats qtmultimedia qtpositioning qtserialport qt_tools: '' conan_package_manager: '' - conan_profile: scwx-win64_msvc2022 + conan_profile: scwx-windows_msvc2022_x64 appimage_arch: '' artifact_suffix: windows-x64 - name: linux_gcc_x64 diff --git a/.gitignore b/.gitignore index 7002668a..cb46cec7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,13 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake _deps + +# Editor directories +.idea/ +.vs/ + +# Python Virtual Environment +.venv/ + +# Specific excludes for Supercell Wx +tools/lib/user-setup.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index bda4b47c..7a2da515 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,10 @@ cmake_minimum_required(VERSION 3.24) set(PROJECT_NAME supercell-wx) + +include(tools/scwx_config.cmake) + +scwx_python_setup() + project(${PROJECT_NAME} VERSION 0.4.9 DESCRIPTION "Supercell Wx is a free, open source advanced weather radar viewer." @@ -11,8 +16,6 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) set(CMAKE_POLICY_DEFAULT_CMP0079 NEW) set(CMAKE_POLICY_DEFAULT_CMP0148 OLD) # aws-sdk-cpp uses FindPythonInterp -include(tools/scwx_config.cmake) - scwx_output_dirs_setup() enable_testing() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..575be130 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,267 @@ +{ + "version": 5, + "cmakeMinimumRequired": { + "major": 3, + "minor": 24, + "patch": 0 + }, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/external/cmake-conan/conan_provider.cmake", + "SCWX_VIRTUAL_ENV": "${sourceDir}/.venv" + } + }, + { + "name": "windows-base", + "inherits": "base", + "hidden": true, + "generator": "Visual Studio 17 2022", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Windows" + ] + } + } + }, + { + "name": "windows-x64-base", + "inherits": "windows-base", + "hidden": true + }, + { + "name": "linux-base", + "inherits": "base", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + } + }, + { + "name": "windows-msvc2022-x64-base", + "inherits": "windows-x64-base", + "hidden": true, + "cacheVariables": { + "CMAKE_PREFIX_PATH": "C:/Qt/6.8.3/msvc2022_64", + "CONAN_HOST_PROFILE": "scwx-windows_msvc2022_x64", + "CONAN_BUILD_PROFILE": "scwx-windows_msvc2022_x64" + } + }, + { + "name": "windows-msvc2022-x64-ninja-base", + "inherits": "windows-msvc2022-x64-base", + "hidden": true, + "generator": "Ninja", + "cacheVariables": { + "CMAKE_PREFIX_PATH": "C:/Qt/6.8.3/msvc2022_64", + "CONAN_HOST_PROFILE": "scwx-windows_msvc2022_x64", + "CONAN_BUILD_PROFILE": "scwx-windows_msvc2022_x64" + } + }, + { + "name": "linux-gcc-base", + "inherits": "linux-base", + "hidden": true, + "cacheVariables": { + "CMAKE_PREFIX_PATH": "/opt/Qt/6.8.3/gcc_64", + "CONAN_HOST_PROFILE": "scwx-linux_gcc-11", + "CONAN_BUILD_PROFILE": "scwx-linux_gcc-11" + }, + "environment": { + "CC": "gcc-11", + "CXX": "g++-11" + } + }, + { + "name": "windows-msvc2022-x64-debug", + "inherits": "windows-msvc2022-x64-base", + "displayName": "Windows MSVC 2022 x64 Debug", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "windows-msvc2022-x64-release", + "inherits": "windows-msvc2022-x64-base", + "displayName": "Windows MSVC 2022 x64 Release", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "windows-msvc2022-x64-ninja-debug", + "inherits": "windows-msvc2022-x64-ninja-base", + "displayName": "Windows MSVC 2022 x64 Ninja Debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "windows-msvc2022-x64-ninja-release", + "inherits": "windows-msvc2022-x64-ninja-base", + "displayName": "Windows MSVC 2022 x64 Ninja Release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "linux-gcc-debug", + "inherits": "linux-gcc-base", + "displayName": "Linux GCC Debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}/Debug/supercell-wx" + } + }, + { + "name": "linux-gcc-release", + "inherits": "linux-gcc-base", + "displayName": "Linux GCC Release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}/Release/supercell-wx" + } + }, + { + "name": "linux-gcc-debug-asan", + "inherits": "linux-gcc-base", + "displayName": "Linux GCC Debug Address Sanitizer", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}/Debug/supercell-wx", + "SCWX_ADDRESS_SANITIZER": { + "type": "BOOL", + "value": "ON" + } + } + }, + { + "name": "linux-gcc-release-asan", + "inherits": "linux-gcc-base", + "displayName": "Linux GCC Release Address Sanitizer", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/${presetName}/Release/supercell-wx", + "SCWX_ADDRESS_SANITIZER": { + "type": "BOOL", + "value": "ON" + } + } + }, + { + "name": "ci-linux-gcc14", + "inherits": "linux-gcc-base", + "displayName": "CI Linux GCC 14", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CONAN_HOST_PROFILE": "scwx-linux_gcc-14", + "CONAN_BUILD_PROFILE": "scwx-linux_gcc-14" + }, + "environment": { + "CC": "gcc-14", + "CXX": "g++-14" + } + }, + { + "name": "ci-linux-clang17", + "inherits": "linux-gcc-base", + "displayName": "CI Linux Clang 17", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CONAN_HOST_PROFILE": "scwx-linux_clang-17", + "CONAN_BUILD_PROFILE": "scwx-linux_clang-17" + }, + "environment": { + "CC": "clang-17", + "CXX": "clang++-17" + } + }, + { + "name": "ci-linux-gcc-arm64", + "inherits": "linux-gcc-base", + "displayName": "CI Linux GCC ARM64", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "CONAN_HOST_PROFILE": "scwx-linux_gcc-11_armv8", + "CONAN_BUILD_PROFILE": "scwx-linux_gcc-11_armv8", + "CMAKE_PREFIX_PATH": "/opt/Qt/6.8.3/gcc_arm64" + }, + "environment": { + "CC": "gcc-11", + "CXX": "g++-11" + } + } + ], + "buildPresets": [ + { + "name": "windows-msvc2022-x64-debug", + "configurePreset": "windows-msvc2022-x64-debug", + "displayName": "Windows MSVC 2022 x64 Debug", + "configuration": "Debug" + }, + { + "name": "windows-msvc2022-x64-release", + "configurePreset": "windows-msvc2022-x64-release", + "displayName": "Windows MSVC 2022 x64 Release", + "configuration": "Release" + }, + { + "name": "linux-gcc-debug", + "configurePreset": "linux-gcc-debug", + "displayName": "Linux GCC Debug", + "configuration": "Debug" + }, + { + "name": "linux-gcc-release", + "configurePreset": "linux-gcc-release", + "displayName": "Linux GCC Release", + "configuration": "Release" + } + ], + "testPresets": [ + { + "name": "windows-msvc2022-x64-debug", + "configurePreset": "windows-msvc2022-x64-debug", + "displayName": "Windows MSVC 2022 x64 Debug", + "configuration": "Debug" + }, + { + "name": "windows-msvc2022-x64-release", + "configurePreset": "windows-msvc2022-x64-release", + "displayName": "Windows MSVC 2022 x64 Release", + "configuration": "Release" + }, + { + "name": "linux-gcc-debug", + "configurePreset": "linux-gcc-debug", + "displayName": "Linux GCC Debug", + "configuration": "Debug" + }, + { + "name": "linux-gcc-release", + "configurePreset": "linux-gcc-release", + "displayName": "Linux GCC Release", + "configuration": "Release" + } + ] +} diff --git a/LICENSE.txt b/LICENSE.txt index 8c9c5fbd..799086a0 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021-2024 Dan Paulat +Copyright (c) 2021-2025 Dan Paulat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/conanfile.py b/conanfile.py index bcf6b365..13a978ca 100644 --- a/conanfile.py +++ b/conanfile.py @@ -37,8 +37,6 @@ class SupercellWxConan(ConanFile): self.options["libcurl"].ca_path = "none" def requirements(self): - self.requires("abseil/20250127.0", override=True) - if self.settings.os == "Linux": self.requires("onetbb/2022.0.0") diff --git a/external/qt6ct.cmake b/external/qt6ct.cmake index 665b5368..cdae0b25 100644 --- a/external/qt6ct.cmake +++ b/external/qt6ct.cmake @@ -46,7 +46,7 @@ target_compile_definitions(qt6ct-common PRIVATE QT6CT_LIBRARY) add_library(qt6ct-widgets STATIC ${qt6ct-widgets-source}) set_target_properties(qt6ct-widgets PROPERTIES VERSION ${QT6CT_VERSION}) -target_link_libraries(qt6ct-widgets PRIVATE Qt6::Widgets Qt6::WidgetsPrivate qt6ct-common) +target_link_libraries(qt6ct-widgets PRIVATE Qt6::Widgets qt6ct-common) target_compile_definitions(qt6ct-widgets PRIVATE QT6CT_LIBRARY) if (MSVC) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..afdd2a37 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +conan +geopandas +GitPython diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 466eddae..aff16705 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -6,7 +6,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) +set(CMAKE_AUTORCC OFF) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -483,11 +483,12 @@ set(PROJECT_SOURCES ${HDR_MAIN} ${SRC_VIEW} ${SHADER_FILES} ${JSON_FILES} - ${RESOURCE_FILES} ${TS_FILES} ${CMAKE_FILES}) set(EXECUTABLE_SOURCES ${SRC_EXE_MAIN}) +qt_add_resources(PROJECT_SOURCES ${RESOURCE_FILES}) + source_group("Header Files\\main" FILES ${HDR_MAIN}) source_group("Source Files\\main" FILES ${SRC_MAIN}) source_group("Header Files\\config" FILES ${HDR_CONFIG}) diff --git a/setup-debug.bat b/setup-debug.bat deleted file mode 100644 index e8076f02..00000000 --- a/setup-debug.bat +++ /dev/null @@ -1,25 +0,0 @@ -call tools\setup-common.bat - -set build_dir=build-debug -set build_type=Debug -set conan_profile=scwx-win64_msvc2022 -set qt_version=6.8.3 -set qt_arch=msvc2022_64 - -conan config install tools/conan/profiles/%conan_profile% -tf profiles -conan install . ^ - --remote conancenter ^ - --build missing ^ - --profile:all %conan_profile% ^ - --settings:all build_type=%build_type% ^ - --output-folder %build_dir%/conan - -mkdir %build_dir% -cmake -B %build_dir% -S . ^ - -DCMAKE_BUILD_TYPE=%build_type% ^ - -DCMAKE_CONFIGURATION_TYPES=%build_type% ^ - -DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/%qt_arch% ^ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake ^ - -DCONAN_HOST_PROFILE=%conan_profile% ^ - -DCONAN_BUILD_PROFILE=%conan_profile% -pause diff --git a/setup-debug.sh b/setup-debug.sh deleted file mode 100755 index 689ac617..00000000 --- a/setup-debug.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -./tools/setup-common.sh - -build_dir=${1:-build-debug} -build_type=Debug -conan_profile=${2:-scwx-linux_gcc-11} -qt_version=6.8.3 -qt_arch=gcc_64 -script_dir="$(dirname "$(readlink -f "$0")")" - -conan config install tools/conan/profiles/${conan_profile} -tf profiles -conan install . \ - --remote conancenter \ - --build missing \ - --profile:all ${conan_profile} \ - --settings:all build_type=${build_type} \ - --output-folder ${build_dir}/conan - -mkdir -p ${build_dir} -cmake -B ${build_dir} -S . \ - -DCMAKE_BUILD_TYPE=${build_type} \ - -DCMAKE_CONFIGURATION_TYPES=${build_type} \ - -DCMAKE_INSTALL_PREFIX=${build_dir}/${build_type}/supercell-wx \ - -DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/${qt_arch} \ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=${script_dir}/external/cmake-conan/conan_provider.cmake \ - -DCONAN_HOST_PROFILE=${conan_profile} \ - -DCONAN_BUILD_PROFILE=${conan_profile} \ - -G Ninja diff --git a/setup-multi.bat b/setup-multi.bat deleted file mode 100644 index b7f0b8df..00000000 --- a/setup-multi.bat +++ /dev/null @@ -1,28 +0,0 @@ -call tools\setup-common.bat - -set build_dir=build -set conan_profile=scwx-win64_msvc2022 -set qt_version=6.8.3 -set qt_arch=msvc2022_64 - -conan config install tools/conan/profiles/%conan_profile% -tf profiles -conan install . ^ - --remote conancenter ^ - --build missing ^ - --profile:all %conan_profile% ^ - --settings:all build_type=Debug ^ - --output-folder %build_dir%/conan -conan install . ^ - --remote conancenter ^ - --build missing ^ - --profile:all %conan_profile% ^ - --settings:all build_type=Release ^ - --output-folder %build_dir%/conan - -mkdir %build_dir% -cmake -B %build_dir% -S . ^ - -DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/%qt_arch% ^ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake ^ - -DCONAN_HOST_PROFILE=%conan_profile% ^ - -DCONAN_BUILD_PROFILE=%conan_profile% -pause diff --git a/setup-release.bat b/setup-release.bat deleted file mode 100644 index e019e204..00000000 --- a/setup-release.bat +++ /dev/null @@ -1,25 +0,0 @@ -call tools\setup-common.bat - -set build_dir=build-release -set build_type=Release -set conan_profile=scwx-win64_msvc2022 -set qt_version=6.8.3 -set qt_arch=msvc2022_64 - -conan config install tools/conan/profiles/%conan_profile% -tf profiles -conan install . ^ - --remote conancenter ^ - --build missing ^ - --profile:all %conan_profile% ^ - --settings:all build_type=%build_type% ^ - --output-folder %build_dir%/conan - -mkdir %build_dir% -cmake -B %build_dir% -S . ^ - -DCMAKE_BUILD_TYPE=%build_type% ^ - -DCMAKE_CONFIGURATION_TYPES=%build_type% ^ - -DCMAKE_PREFIX_PATH=C:/Qt/%qt_version%/%qt_arch% ^ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=external/cmake-conan/conan_provider.cmake ^ - -DCONAN_HOST_PROFILE=%conan_profile% ^ - -DCONAN_BUILD_PROFILE=%conan_profile% -pause diff --git a/setup-release.sh b/setup-release.sh deleted file mode 100755 index 8d2b5fe6..00000000 --- a/setup-release.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -./tools/setup-common.sh - -build_dir=${1:-build-release} -build_type=Release -conan_profile=${2:-scwx-linux_gcc-11} -qt_version=6.8.3 -qt_arch=gcc_64 -script_dir="$(dirname "$(readlink -f "$0")")" - -conan config install tools/conan/profiles/${conan_profile} -tf profiles -conan install . \ - --remote conancenter \ - --build missing \ - --profile:all ${conan_profile} \ - --settings:all build_type=${build_type} \ - --output-folder ${build_dir}/conan - -mkdir -p ${build_dir} -cmake -B ${build_dir} -S . \ - -DCMAKE_BUILD_TYPE=${build_type} \ - -DCMAKE_CONFIGURATION_TYPES=${build_type} \ - -DCMAKE_INSTALL_PREFIX=${build_dir}/${build_type}/supercell-wx \ - -DCMAKE_PREFIX_PATH=/opt/Qt/${qt_version}/${qt_arch} \ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=${script_dir}/external/cmake-conan/conan_provider.cmake \ - -DCONAN_HOST_PROFILE=${conan_profile} \ - -DCONAN_BUILD_PROFILE=${conan_profile} \ - -G Ninja diff --git a/tools/conan/profiles/scwx-win64_msvc2022 b/tools/conan/profiles/scwx-windows_msvc2022_x64 similarity index 100% rename from tools/conan/profiles/scwx-win64_msvc2022 rename to tools/conan/profiles/scwx-windows_msvc2022_x64 diff --git a/tools/configure-environment.bat b/tools/configure-environment.bat new file mode 100644 index 00000000..d386ecc0 --- /dev/null +++ b/tools/configure-environment.bat @@ -0,0 +1,45 @@ +@setlocal enabledelayedexpansion + +@set script_dir=%~dp0 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified Python Virtual Environment +@if not "%~1"=="" ( + if /i "%~1"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f1 + ) +) + +:: Activate Python Virtual Environment +@if defined venv_path ( + echo Activating Python Virtual Environment: %venv_path% + python -m venv %venv_path% + call %venv_path%\Scripts\activate.bat +) + +:: Install Python packages +python -m pip install --upgrade pip +pip install --upgrade -r "%script_dir%\..\requirements.txt" + +:: Configure default Conan profile +@conan profile detect -e + +:: Conan profiles +@set profile_count=1 +@set /a last_profile=profile_count - 1 +@set conan_profile[0]=scwx-windows_msvc2022_x64 + +:: Install Conan profiles +@for /L %%i in (0,1,!last_profile!) do @( + set "profile_name=!conan_profile[%%i]!" + conan config install "%script_dir%\conan\profiles\!profile_name!" -tf profiles +) + +:: Deactivate Python Virtual Environment +@if defined venv_path ( + call %venv_path%\Scripts\deactivate.bat +) + +@pause diff --git a/tools/configure-environment.sh b/tools/configure-environment.sh new file mode 100755 index 00000000..0da64217 --- /dev/null +++ b/tools/configure-environment.sh @@ -0,0 +1,60 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +# Assign user-specified Python Virtual Environment +[ "${1:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${1:-${script_dir}/../.venv}")" + +# Load custom build settings +if [ -f "${script_dir}/lib/user-setup.sh" ]; then + source "${script_dir}/lib/user-setup.sh" +fi + +# Activate Python Virtual Environment +if [ -n "${venv_path:-}" ]; then + python -m venv "${venv_path}" + source "${venv_path}/bin/activate" +fi + +# Detect if a Python Virtual Environment was specified above, or elsewhere +IN_VENV=$(python -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') + +if [ "${IN_VENV}" = "True" ]; then + # In a virtual environment, don't use --user + PIP_FLAGS="--upgrade" +else + # Not in a virtual environment, use --user + PIP_FLAGS="--upgrade --user" +fi + +# Install Python packages +python -m pip install ${PIP_FLAGS} --upgrade pip +pip install ${PIP_FLAGS} -r "${script_dir}/../requirements.txt" + +# Configure default Conan profile +conan profile detect -e + +# Conan profiles +conan_profiles=( + "scwx-linux_clang-17" + "scwx-linux_clang-17_armv8" + "scwx-linux_clang-18" + "scwx-linux_clang-18_armv8" + "scwx-linux_gcc-11" + "scwx-linux_gcc-11_armv8" + "scwx-linux_gcc-12" + "scwx-linux_gcc-12_armv8" + "scwx-linux_gcc-13" + "scwx-linux_gcc-13_armv8" + "scwx-linux_gcc-14" + "scwx-linux_gcc-14_armv8" + ) + +# Install Conan profiles +for profile_name in "${conan_profiles[@]}"; do + conan config install "${script_dir}/conan/profiles/${profile_name}" -tf profiles +done + +# Deactivate Python Virtual Environment +if [ -n "${venv_path:-}" ]; then + deactivate +fi diff --git a/tools/lib/common-paths.bat b/tools/lib/common-paths.bat new file mode 100644 index 00000000..69f6c6fc --- /dev/null +++ b/tools/lib/common-paths.bat @@ -0,0 +1 @@ +@set qt_version=6.8.3 diff --git a/tools/lib/common-paths.sh b/tools/lib/common-paths.sh new file mode 100755 index 00000000..a1f48932 --- /dev/null +++ b/tools/lib/common-paths.sh @@ -0,0 +1,2 @@ +#!/bin/bash +export qt_version=6.8.3 diff --git a/tools/lib/run-cmake-configure.bat b/tools/lib/run-cmake-configure.bat new file mode 100644 index 00000000..424bcc34 --- /dev/null +++ b/tools/lib/run-cmake-configure.bat @@ -0,0 +1,24 @@ +@set script_dir=%~dp0 + +@set cmake_args=-B "%build_dir%" -S "%script_dir%\..\.." ^ + -G "%generator%" ^ + -DCMAKE_PREFIX_PATH="%qt_base%/%qt_version%/%qt_arch%" ^ + -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="%script_dir%\..\..\external\cmake-conan\conan_provider.cmake" ^ + -DCONAN_HOST_PROFILE=%conan_profile% ^ + -DCONAN_BUILD_PROFILE=%conan_profile% ^ + -DSCWX_VIRTUAL_ENV=%venv_path% ^ + -DCMAKE_EXPORT_COMPILE_COMMANDS=on + +@if defined build_type ( + set cmake_args=%cmake_args% ^ + -DCMAKE_BUILD_TYPE=%build_type% ^ + -DCMAKE_CONFIGURATION_TYPES=%build_type% +) else ( + :: CMAKE_BUILD_TYPE isn't used to build, but is required by the Conan CMakeDeps generator + set cmake_args=%cmake_args% ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_CONFIGURATION_TYPES=Debug;Release +) + +@mkdir "%build_dir%" +cmake %cmake_args% diff --git a/tools/lib/run-cmake-configure.sh b/tools/lib/run-cmake-configure.sh new file mode 100755 index 00000000..5e1a3bbf --- /dev/null +++ b/tools/lib/run-cmake-configure.sh @@ -0,0 +1,42 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +cmake_args=( + -B "${build_dir}" + -S "${script_dir}/../.." + -G "${generator}" + -DCMAKE_PREFIX_PATH="${qt_base}/${qt_version}/${qt_arch}" + -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="${script_dir}/../../external/cmake-conan/conan_provider.cmake" + -DCONAN_HOST_PROFILE="${conan_profile}" + -DCONAN_BUILD_PROFILE="${conan_profile}" + -DSCWX_VIRTUAL_ENV="${venv_path}" + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON +) + +if [[ -n "${build_type}" ]]; then + cmake_args+=( + -DCMAKE_BUILD_TYPE="${build_type}" + -DCMAKE_CONFIGURATION_TYPES="${build_type}" + -DCMAKE_INSTALL_PREFIX="${build_dir}/${build_type}/supercell-wx" + ) +else + # CMAKE_BUILD_TYPE isn't used to build, but is required by the Conan CMakeDeps generator + cmake_args+=( + -DCMAKE_BUILD_TYPE="Release" + -DCMAKE_CONFIGURATION_TYPES="Debug;Release" + ) +fi + +# Toggle address sanitizer based on argument +if [ "${address_sanitizer}" != "disabled" ]; then + cmake_args+=( + -DSCWX_ADDRESS_SANITIZER=ON + ) +else + cmake_args+=( + -DSCWX_ADDRESS_SANITIZER=OFF + ) +fi + +mkdir -p "${build_dir}" +cmake "${cmake_args[@]}" diff --git a/tools/lib/setup-common.bat b/tools/lib/setup-common.bat new file mode 100644 index 00000000..9ba510c2 --- /dev/null +++ b/tools/lib/setup-common.bat @@ -0,0 +1,39 @@ +@set script_dir=%~dp0 + +:: Import common paths +@call %script_dir%\common-paths.bat + +:: Activate Python Virtual Environment +@if defined venv_path ( + echo Activating Python Virtual Environment: %venv_path% + python -m venv %venv_path% + call %venv_path%\Scripts\activate.bat +) + +:: Install Python packages +python -m pip install --upgrade pip +pip install --upgrade -r "%script_dir%\..\..\requirements.txt" + +@if defined build_type ( + :: Install Conan profile and packages + call %script_dir%\setup-conan.bat +) else ( + :: Install Conan profile and debug packages + set build_type=Debug + call %script_dir%\setup-conan.bat + + :: Install Conan profile and release packages + set build_type=Release + call %script_dir%\setup-conan.bat + + :: Unset build_type + set build_type= +) + +:: Run CMake Configure +@call %script_dir%\run-cmake-configure.bat + +:: Deactivate Python Virtual Environment +@if defined venv_path ( + call %venv_path%\Scripts\deactivate.bat +) diff --git a/tools/lib/setup-common.sh b/tools/lib/setup-common.sh new file mode 100755 index 00000000..e28978e9 --- /dev/null +++ b/tools/lib/setup-common.sh @@ -0,0 +1,55 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +# Import common paths +source "${script_dir}/common-paths.sh" + +# Load custom build settings +if [ -f "${script_dir}/user-setup.sh" ]; then + source "${script_dir}/user-setup.sh" +fi + +# Activate Python Virtual Environment +if [ -n "${venv_path:-}" ]; then + python -m venv "${venv_path}" + source "${venv_path}/bin/activate" +fi + +# Detect if a Python Virtual Environment was specified above, or elsewhere +IN_VENV=$(python -c 'import sys; print(sys.prefix != getattr(sys, "base_prefix", sys.prefix))') + +if [ "${IN_VENV}" = "True" ]; then + # In a virtual environment, don't use --user + PIP_FLAGS="--upgrade" +else + # Not in a virtual environment, use --user + PIP_FLAGS="--upgrade --user" +fi + +# Install Python packages +python -m pip install ${PIP_FLAGS} pip +pip install ${PIP_FLAGS} -r "${script_dir}/../../requirements.txt" + +if [[ -n "${build_type}" ]]; then + # Install Conan profile and packages + "${script_dir}/setup-conan.sh" +else + # Install Conan profile and debug packages + export build_type=Debug + "${script_dir}/setup-conan.sh" + + # Install Conan profile and release packages + export build_type=Release + "${script_dir}/setup-conan.sh" + + # Unset build_type + unset build_type +fi + +# Run CMake Configure +"${script_dir}/run-cmake-configure.sh" + +# Deactivate Python Virtual Environment +if [ -n "${venv_path:-}" ]; then + deactivate +fi diff --git a/tools/lib/setup-conan.bat b/tools/lib/setup-conan.bat new file mode 100644 index 00000000..e3f4f444 --- /dev/null +++ b/tools/lib/setup-conan.bat @@ -0,0 +1,15 @@ +@set script_dir=%~dp0 + +:: Configure default Conan profile +conan profile detect -e + +:: Install selected Conan profile +conan config install "%script_dir%\..\conan\profiles\%conan_profile%" -tf profiles + +:: Install Conan packages +conan install "%script_dir%\..\.." ^ + --remote conancenter ^ + --build missing ^ + --profile:all %conan_profile% ^ + --settings:all build_type=%build_type% ^ + --output-folder "%build_dir%\conan" diff --git a/tools/lib/setup-conan.sh b/tools/lib/setup-conan.sh new file mode 100755 index 00000000..2ac38ee7 --- /dev/null +++ b/tools/lib/setup-conan.sh @@ -0,0 +1,16 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +# Configure default Conan profile +conan profile detect -e + +# Install selected Conan profile +conan config install "${script_dir}/../conan/profiles/${conan_profile}" -tf profiles + +# Install Conan packages +conan install "${script_dir}/../.." \ + --remote conancenter \ + --build missing \ + --profile:all ${conan_profile} \ + --settings:all build_type=${build_type} \ + --output-folder "${build_dir}/conan" diff --git a/tools/lib/user-setup.example.sh b/tools/lib/user-setup.example.sh new file mode 100644 index 00000000..5ea76d24 --- /dev/null +++ b/tools/lib/user-setup.example.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Example user setup script. Copy as user-setup.sh and modify as required. + +# gcc-13 is not the default gcc version +export CC=/usr/bin/gcc-13 +export CXX=/usr/bin/c++-13 + +# Override conan profile to be gcc-13 +export conan_profile=scwx-linux_gcc-13 diff --git a/tools/scwx_config.cmake b/tools/scwx_config.cmake index 0919b22e..8373418b 100644 --- a/tools/scwx_config.cmake +++ b/tools/scwx_config.cmake @@ -17,3 +17,39 @@ macro(scwx_output_dirs_setup) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/Debug/lib) endmacro() + +macro(scwx_python_setup) + set(SCWX_VIRTUAL_ENV "" CACHE STRING "Python Virtual Environment") + + # Use a Python Virtual Environment + if (SCWX_VIRTUAL_ENV) + set(ENV{VIRTUAL_ENV} "${SCWX_VIRTUAL_ENV}") + + if (WIN32) + set(Python3_EXECUTABLE "$ENV{VIRTUAL_ENV}/Scripts/python.exe") + else() + set(Python3_EXECUTABLE "$ENV{VIRTUAL_ENV}/bin/python") + endif() + + message(STATUS "Using virtual environment: $ENV{VIRTUAL_ENV}") + else() + message(STATUS "Python virtual environment undefined") + endif() + + # Find Python + find_package(Python3 REQUIRED COMPONENTS Interpreter) + + # Verify we're using the right Python + message(STATUS "Python executable: ${Python3_EXECUTABLE}") + message(STATUS "Python version: ${Python3_VERSION}") + + # Only if we are in an application defined virtual environment + if (SCWX_VIRTUAL_ENV) + # Setup pip + set(PIP_ARGS install --upgrade -r "${CMAKE_SOURCE_DIR}/requirements.txt") + + # Install requirements + execute_process(COMMAND ${Python3_EXECUTABLE} -m pip ${PIP_ARGS} + RESULT_VARIABLE PIP_RESULT) + endif() +endmacro() diff --git a/tools/setup-common.bat b/tools/setup-common.bat deleted file mode 100644 index bada34ed..00000000 --- a/tools/setup-common.bat +++ /dev/null @@ -1,4 +0,0 @@ -pip install --upgrade conan -pip install --upgrade geopandas -pip install --upgrade GitPython -conan profile detect -e diff --git a/tools/setup-common.sh b/tools/setup-common.sh deleted file mode 100755 index 2533d6ec..00000000 --- a/tools/setup-common.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -pip install --upgrade --user conan -pip install --upgrade --user geopandas -pip install --upgrade --user GitPython -conan profile detect -e diff --git a/tools/setup-debug-msvc2022.bat b/tools/setup-debug-msvc2022.bat new file mode 100644 index 00000000..9ef029a3 --- /dev/null +++ b/tools/setup-debug-msvc2022.bat @@ -0,0 +1,26 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-debug-msvc2022 +@set build_type=Debug +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Visual Studio 17 2022 +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-debug-ninja.bat b/tools/setup-debug-ninja.bat new file mode 100644 index 00000000..182c7956 --- /dev/null +++ b/tools/setup-debug-ninja.bat @@ -0,0 +1,26 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-debug-ninja +@set build_type=Debug +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Ninja +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-debug.sh b/tools/setup-debug.sh new file mode 100755 index 00000000..9b896d40 --- /dev/null +++ b/tools/setup-debug.sh @@ -0,0 +1,16 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +export build_dir="$(readlink -f "${1:-${script_dir}/../build-debug}")" +export build_type=Debug +export conan_profile=${2:-scwx-linux_gcc-11} +export generator=Ninja +export qt_base=/opt/Qt +export qt_arch=gcc_64 +export address_sanitizer=${4:-disabled} + +# Assign user-specified Python Virtual Environment +[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")" + +# Perform common setup +"${script_dir}/lib/setup-common.sh" diff --git a/tools/setup-multi-msvc2022.bat b/tools/setup-multi-msvc2022.bat new file mode 100644 index 00000000..87e19fd3 --- /dev/null +++ b/tools/setup-multi-msvc2022.bat @@ -0,0 +1,25 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-msvc2022 +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Visual Studio 17 2022 +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-multi-ninja.bat b/tools/setup-multi-ninja.bat new file mode 100644 index 00000000..8962fc2b --- /dev/null +++ b/tools/setup-multi-ninja.bat @@ -0,0 +1,25 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-ninja +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Ninja Multi-Config +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-multi.sh b/tools/setup-multi.sh new file mode 100755 index 00000000..05a6cad5 --- /dev/null +++ b/tools/setup-multi.sh @@ -0,0 +1,18 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +export build_dir="$(readlink -f "${1:-${script_dir}/../build-debug}")" +export conan_profile=${2:-scwx-linux_gcc-11} +export generator="Ninja Multi-Config" +export qt_base=/opt/Qt +export qt_arch=gcc_64 + +# Assign user-specified Python Virtual Environment +[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")" + +# FIXME: aws-sdk-cpp fails to configure using Ninja Multi-Config +echo "Ninja Multi-Config is not supported in Linux" +read -p "Press Enter to continue..." + +# Perform common setup +# "${script_dir}/lib/setup-common.sh" diff --git a/tools/setup-release-msvc2022.bat b/tools/setup-release-msvc2022.bat new file mode 100644 index 00000000..a4f805cc --- /dev/null +++ b/tools/setup-release-msvc2022.bat @@ -0,0 +1,26 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-release-msvc2022 +@set build_type=Release +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Visual Studio 17 2022 +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-release-ninja.bat b/tools/setup-release-ninja.bat new file mode 100644 index 00000000..96ba0e55 --- /dev/null +++ b/tools/setup-release-ninja.bat @@ -0,0 +1,26 @@ +@set script_dir=%~dp0 + +@set build_dir=%script_dir%\..\build-release-ninja +@set build_type=Release +@set conan_profile=scwx-windows_msvc2022_x64 +@set generator=Ninja +@set qt_base=C:/Qt +@set qt_arch=msvc2022_64 +@set venv_path=%script_dir%\..\.venv + +:: Assign user-specified build directory +@if not "%~1"=="" set build_dir=%~f1 + +:: Assign user-specified Python Virtual Environment +@if not "%~2"=="" ( + if /i "%~2"=="none" ( + set venv_path= + ) else ( + set venv_path=%~f2 + ) +) + +:: Perform common setup +@call %script_dir%\lib\setup-common.bat + +@pause diff --git a/tools/setup-release.sh b/tools/setup-release.sh new file mode 100755 index 00000000..e7e10db0 --- /dev/null +++ b/tools/setup-release.sh @@ -0,0 +1,16 @@ +#!/bin/bash +script_dir="$(dirname "$(readlink -f "$0")")" + +export build_dir="$(readlink -f "${1:-${script_dir}/../build-release}")" +export build_type=Release +export conan_profile=${2:-scwx-linux_gcc-11} +export generator=Ninja +export qt_base=/opt/Qt +export qt_arch=gcc_64 +export address_sanitizer=${4:-disabled} + +# Assign user-specified Python Virtual Environment +[ "${3:-}" = "none" ] && unset venv_path || export venv_path="$(readlink -f "${3:-${script_dir}/../.venv}")" + +# Perform common setup +"${script_dir}/lib/setup-common.sh"