diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 64ede0af2f..67b045c72d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,13 +17,6 @@ "customizations": { "vscode": { "settings": { - "cmake.configureArgs": [ - "-DSLIC3R_GTK=3", - "-DBBL_RELEASE_TO_PUBLIC=1", - "-DBBL_INTERNAL_TESTING=0", - "-DSLIC3R_STATIC=1", - "-DCMAKE_PREFIX_PATH=${workspaceFolder}/deps/build/destdir/usr/local" - ] }, // Add the IDs of extensions you want installed when the container is created. diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index db95d67040..6d85551c35 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -76,6 +76,7 @@ jobs: - /opt/ghc:/opt/ghc1 - /usr/local/share/boost:/usr/local/share/boost1 strategy: + fail-fast: false matrix: variant: - arch: x86_64 diff --git a/.github/workflows/build_check_cache.yml b/.github/workflows/build_check_cache.yml index c262eeeadb..a97962aa7e 100644 --- a/.github/workflows/build_check_cache.yml +++ b/.github/workflows/build_check_cache.yml @@ -33,8 +33,7 @@ jobs: - name: set outputs id: set_outputs env: - # todo: this is mad! refactor other build scripts to use same name - dep-folder-name: ${{ inputs.os == 'windows-latest' && '/OrcaSlicer_dep' || inputs.os == 'macos-14' && '' || inputs.os != 'macos-14' && '/destdir' || '' }} + dep-folder-name: ${{ inputs.os != 'macos-14' && '/OrcaSlicer_dep' || '' }} output-cmd: ${{ inputs.os == 'windows-latest' && '$env:GITHUB_OUTPUT' || '"$GITHUB_OUTPUT"'}} run: | echo cache-key=${{ inputs.os }}-cache-orcaslicer_deps-build-${{ hashFiles('deps/**') }} >> ${{ env.output-cmd }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bd575188d..9c81a18992 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,11 @@ endif () project(OrcaSlicer) +# Backward compatibility for old CMake versions +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_VERSION VERSION_LESS "3.25") + set(LINUX ON CACHE BOOL "" FORCE) +endif () + include("version.inc") include(GNUInstallDirs) include(CMakeDependentOption) @@ -67,6 +72,12 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (default Release)" FORCE) endif() +if (DEFINED BBL_RELEASE_TO_PUBLIC) + add_compile_definitions("BBL_RELEASE_TO_PUBLIC=${BBL_RELEASE_TO_PUBLIC}") +else () + add_compile_definitions("BBL_RELEASE_TO_PUBLIC=$") +endif () + find_package(Git) if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") if(DEFINED ENV{git_commit_hash} AND NOT "$ENV{git_commit_hash}" STREQUAL "") @@ -93,13 +104,9 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") endif() if(DEFINED ENV{SLIC3R_STATIC}) - set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC}) + set(SLIC3R_STATIC_INITIAL $ENV{SLIC3R_STATIC}) else() - if (MSVC OR MINGW OR APPLE) - set(SLIC3R_STATIC_INITIAL 1) - else() - set(SLIC3R_STATIC_INITIAL 0) - endif() + set(SLIC3R_STATIC_INITIAL 1) endif() option(SLIC3R_STATIC "Compile OrcaSlicer with static libraries (Boost, TBB, glew)" ${SLIC3R_STATIC_INITIAL}) @@ -117,7 +124,7 @@ CMAKE_DEPENDENT_OPTION(SLIC3R_DESKTOP_INTEGRATION "Allow perfoming desktop integ set(OPENVDB_FIND_MODULE_PATH "" CACHE PATH "Path to OpenVDB installation's find modules.") -set(SLIC3R_GTK "2" CACHE STRING "GTK version to use with wxWidgets on Linux") +set(SLIC3R_GTK "3" CACHE STRING "GTK version to use with wxWidgets on Linux") set(IS_CROSS_COMPILE FALSE) @@ -131,6 +138,10 @@ if (${COLORED_OUTPUT}) endif () if (APPLE) + list(LENGTH CMAKE_OSX_ARCHITECTURES _arch_len) + if (_arch_len GREATER 1) + message(FATAL_ERROR "OrcaSlicer only supports building for one architecture at a time. Please make sure only one architecture is specified in CMAKE_OSX_ARCHITECTURES") + endif () set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) list(FIND CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} _arch_idx) @@ -150,6 +161,14 @@ option(SLIC3R_BUILD_SANDBOXES "Build development sandboxes" OFF) option(BUILD_TESTS "Build unit tests" OFF) option(ORCA_TOOLS "Build Orca tools" OFF) +if (FLATPAK) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++20") + set(SLIC3R_PCH OFF CACHE BOOL "" FORCE) + set(SLIC3R_FHS ON CACHE BOOL "" FORCE) + set(BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(SLIC3R_DESKTOP_INTEGRATION OFF CACHE BOOL "" FORCE) +endif () + if (IS_CROSS_COMPILE) message("Detected cross compilation setup. Tests and encoding checks will be forcedly disabled!") set(SLIC3R_PERL_XS OFF CACHE BOOL "" FORCE) @@ -173,6 +192,13 @@ if(SLIC3R_DESKTOP_INTEGRATION) add_definitions(-DSLIC3R_DESKTOP_INTEGRATION) endif () +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + message(STATUS "Automatically setting CMAKE_INSTALL_PREFIX") + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_BINARY_DIR}/OrcaSlicer") +endif() + +message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") + if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(IS_CLANG_CL TRUE) @@ -218,24 +244,61 @@ if (NOT MSVC) add_compile_options(-fsigned-char) endif () -# Display and check CMAKE_PREFIX_PATH -message(STATUS "SLIC3R_STATIC: ${SLIC3R_STATIC}") -if (NOT "${CMAKE_PREFIX_PATH}" STREQUAL "") - message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH} (from cache or command line)") - set(PREFIX_PATH_CHECK ${CMAKE_PREFIX_PATH}) -elseif (NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") - message(STATUS "CMAKE_PREFIX_PATH: $ENV{CMAKE_PREFIX_PATH} (from environment)") - set(PREFIX_PATH_CHECK $ENV{CMAKE_PREFIX_PATH}) +if ("${DEP_BUILD_DIR}" STREQUAL "") + get_filename_component(BIN_DIR_NAME ${CMAKE_BINARY_DIR} NAME) + if (APPLE AND BIN_DIR_NAME STREQUAL "${CMAKE_OSX_ARCHITECTURES}") + file(RELATIVE_PATH BIN_DIR_NAME ${CMAKE_BINARY_DIR}/../.. ${CMAKE_BINARY_DIR}) + endif () + set(DEP_BUILD_DIR "${CMAKE_SOURCE_DIR}/deps/${BIN_DIR_NAME}" CACHE PATH "Path to dependencies build directory" FORCE) + message(STATUS "DEP_BUILD_DIR: ${DEP_BUILD_DIR} (generated automatically and saved to cache)") + set(AUTOGENERATED_DEP_BUILD_DIR ${DEP_BUILD_DIR} CACHE PATH "Provides the last autogenerated DEP_BUILD_DIR" FORCE) else () - message(STATUS "CMAKE_PREFIX_PATH: (default)") + message(STATUS "DEP_BUILD_DIR: ${DEP_BUILD_DIR} (from cache or command line)") endif () +if ("${CMAKE_PREFIX_PATH}" STREQUAL "" OR "${CMAKE_PREFIX_PATH}" STREQUAL "${AUTOGENERATED_PREFIX_PATH}") + if (DEFINED AUTOGENERATED_DEP_BUILD_DIR AND NOT "${DEP_BUILD_DIR}" STREQUAL "${AUTOGENERATED_DEP_BUILD_DIR}") + message(STATUS "CMAKE_PREFIX_PATH is being re-generated due to DEP_BUILD_DIR being manually updated") + set(REGEN_DESTDIR TRUE) + unset(AUTOGENERATED_DEP_BUILD_DIR CACHE) + endif () +else () + unset(AUTOGENERATED_PREFIX_PATH CACHE) +endif () + +# Display and check CMAKE_PREFIX_PATH +if ("${CMAKE_PREFIX_PATH}" STREQUAL "" OR REGEN_DESTDIR) + set(CMAKE_PREFIX_PATH "${DEP_BUILD_DIR}/OrcaSlicer_dep/usr/local" CACHE PATH "Path to dependencies install directory" FORCE) + message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH} (generated automatically and saved to cache)") + set(AUTOGENERATED_PREFIX_PATH ${CMAKE_PREFIX_PATH} CACHE STRING "Provides the last autogenerated CMAKE_PREFIX_PATH" FORCE) + unset(REGEN_DESTDIR CACHE) +else () + message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH} (from cache or command line)") +endif () +set(PREFIX_PATH_CHECK ${CMAKE_PREFIX_PATH}) + +# the CMAKE_PREFIX_PATH environment variable is separate from the CMAKE_PREFIX_PATH cache variable and provides additional paths to search for libraries. +if (NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") + message(STATUS "CMAKE_PREFIX_PATH: $ENV{CMAKE_PREFIX_PATH} (from environment)") + list(APPEND PREFIX_PATH_CHECK $ENV{CMAKE_PREFIX_PATH}) +endif () + +# Check all directories in CMAKE_PREFIX_PATH variables foreach (DIR ${PREFIX_PATH_CHECK}) if (NOT EXISTS "${DIR}") message(WARNING "CMAKE_PREFIX_PATH element doesn't exist: ${DIR}") endif () endforeach () +if (APPLE) + set(CMAKE_MACOSX_RPATH ON CACHE BOOL "") + set(CMAKE_MACOSX_BUNDLE ON CACHE BOOL "") +endif () + +if (APPLE AND CMAKE_MACOSX_RPATH AND "${CMAKE_INSTALL_RPATH}" STREQUAL "") + set(CMAKE_INSTALL_RPATH ${CMAKE_PREFIX_PATH}) +endif () + # Add our own cmake module path. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}") @@ -276,7 +339,11 @@ if(WIN32) endif() else() # Try to use the default Windows 10 SDK path. - set(WIN10SDK_INCLUDE_PATH "$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}") + if (DEFINED ENV{WindowsSdkDir} AND DEFINED ENV{WindowsSDKVersion}) + set(WIN10SDK_INCLUDE_PATH "$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}") + else () + set(WIN10SDK_INCLUDE_PATH "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0") + endif () if (NOT EXISTS "${WIN10SDK_INCLUDE_PATH}/winrt/windows.graphics.printing3d.h") message("${WIN10SDK_INCLUDE_PATH}/winrt/windows.graphics.printing3d.h was not found") message("STL fixing by the Netfabb service will not be compiled") diff --git a/build_linux.sh b/build_linux.sh index a696177938..e2da74482d 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -10,10 +10,12 @@ function usage() { echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-h][-i][-j N][-p][-r][-s][-t][-u][-l][-L]" echo " -1: limit builds to one core (where possible)" echo " -j N: limit builds to N cores (where possible)" - echo " -b: build in debug mode" + echo " -b: build in Debug mode" echo " -c: force a clean build" echo " -C: enable ANSI-colored compile output (GNU/Clang only)" echo " -d: download and build dependencies in ./deps/ (build prerequisite)" + echo " -D: dry run" + echo " -e: build in RelWithDebInfo mode" echo " -h: prints this help text" echo " -i: build the Orca Slicer AppImage (optional)" echo " -p: boost ccache hit rate by disabling precompiled headers (default: ON)" @@ -31,7 +33,9 @@ function usage() { SLIC3R_PRECOMPILED_HEADERS="ON" unset name -while getopts ":1j:bcCdhiprstulL" opt ; do +BUILD_DIR=build +BUILD_CONFIG=Release +while getopts ":1j:bcCdDehiprstulL" opt ; do case ${opt} in 1 ) export CMAKE_BUILD_PARALLEL_LEVEL=1 @@ -40,7 +44,8 @@ while getopts ":1j:bcCdhiprstulL" opt ; do export CMAKE_BUILD_PARALLEL_LEVEL=$OPTARG ;; b ) - BUILD_DEBUG="1" + BUILD_DIR=build-dbg + BUILD_CONFIG=Debug ;; c ) CLEAN_BUILD=1 @@ -51,6 +56,13 @@ while getopts ":1j:bcCdhiprstulL" opt ; do d ) BUILD_DEPS="1" ;; + D ) + DRY_RUN="1" + ;; + e ) + BUILD_DIR=build-dbginfo + BUILD_CONFIG=RelWithDebInfo + ;; h ) usage exit 1 ;; @@ -112,6 +124,21 @@ function check_available_memory_and_disk() { fi } +function print_and_run() { + cmd=() + # Remove empty arguments, leading and trailing spaces + for item in "$@" ; do + if [[ -n $item ]]; then + cmd+=( "$(echo "${item}" | xargs)" ) + fi + done + + echo "${cmd[@]}" + if [[ -z "${DRY_RUN}" ]] ; then + "${cmd[@]}" + fi +} + # cmake 4.x compatibility workaround export CMAKE_POLICY_VERSION_MINIMUM=3.5 @@ -137,7 +164,7 @@ else source "./scripts/linux.d/${DISTRIBUTION}" fi -echo "FOUND_GTK3=${FOUND_GTK3}" +echo "FOUND_GTK3_DEV=${FOUND_GTK3_DEV}" if [[ -z "${FOUND_GTK3_DEV}" ]] ; then echo "Error, you must install the dependencies before." echo "Use option -u with sudo" @@ -176,51 +203,27 @@ fi if [[ -n "${BUILD_DEPS}" ]] ; then echo "Configuring dependencies..." read -r -a BUILD_ARGS <<< "${DEPS_EXTRA_BUILD_ARGS}" - BUILD_ARGS+=(-DDEP_WX_GTK3=ON) if [[ -n "${CLEAN_BUILD}" ]] then - rm -fr deps/build + print_and_run rm -fr deps/$BUILD_DIR fi - mkdir -p deps/build - if [[ -n "${BUILD_DEBUG}" ]] ; then - # build deps with debug and release else cmake will not find required sources - mkdir -p deps/build/release - set -x - cmake -S deps -B deps/build/release "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G Ninja \ - -DSLIC3R_PCH="${SLIC3R_PRECOMPILED_HEADERS}" \ - -DDESTDIR="${SCRIPT_PATH}/deps/build/destdir" \ - -DDEP_DOWNLOAD_DIR="${SCRIPT_PATH}/deps/DL_CACHE" \ - "${COLORED_OUTPUT}" \ - "${BUILD_ARGS[@]}" - set +x - cmake --build deps/build/release - BUILD_ARGS+=(-DCMAKE_BUILD_TYPE=Debug) + mkdir -p deps/$BUILD_DIR + if [[ $BUILD_CONFIG != Release ]] ; then + BUILD_ARGS+=(-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}") fi - set -x - cmake -S deps -B deps/build "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G Ninja \ - -DSLIC3R_PCH="${SLIC3R_PRECOMPILED_HEADERS}" \ - -DDESTDIR="${SCRIPT_PATH}/deps/build/destdir" \ - -DDEP_DOWNLOAD_DIR="${SCRIPT_PATH}/deps/DL_CACHE" \ - "${COLORED_OUTPUT}" \ - "${BUILD_ARGS[@]}" - set +x - cmake --build deps/build + print_and_run cmake -S deps -B deps/$BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G Ninja "${COLORED_OUTPUT}" "${BUILD_ARGS[@]}" + print_and_run cmake --build deps/$BUILD_DIR fi if [[ -n "${BUILD_ORCA}" ]] ; then echo "Configuring OrcaSlicer..." if [[ -n "${CLEAN_BUILD}" ]] ; then - rm -fr build + print_and_run rm -fr $BUILD_DIR fi read -r -a BUILD_ARGS <<< "${ORCA_EXTRA_BUILD_ARGS}" - if [[ -n "${FOUND_GTK3_DEV}" ]] ; then - BUILD_ARGS+=(-DSLIC3R_GTK=3) - fi - if [[ -n "${BUILD_DEBUG}" ]] ; then - BUILD_ARGS+=(-DCMAKE_BUILD_TYPE=Debug -DBBL_INTERNAL_TESTING=1) - else - BUILD_ARGS+=(-DBBL_RELEASE_TO_PUBLIC=1 -DBBL_INTERNAL_TESTING=0) + if [[ $BUILD_CONFIG != Release ]] ; then + BUILD_ARGS+=(-DCMAKE_BUILD_TYPE="${BUILD_CONFIG}") fi if [[ -n "${BUILD_TESTS}" ]] ; then BUILD_ARGS+=(-DBUILD_TESTS=ON) @@ -229,35 +232,22 @@ if [[ -n "${BUILD_ORCA}" ]] ; then BUILD_ARGS+=(-DORCA_UPDATER_SIG_KEY="${ORCA_UPDATER_SIG_KEY}") fi - echo "Configuring OrcaSlicer..." - set -x - cmake -S . -B build "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G "Ninja Multi-Config" \ - -DSLIC3R_PCH="${SLIC3R_PRECOMPILED_HEADERS}" \ - -DCMAKE_PREFIX_PATH="${SCRIPT_PATH}/deps/build/destdir/usr/local" \ - -DSLIC3R_STATIC=1 \ - -DORCA_TOOLS=ON \ - "${COLORED_OUTPUT}" \ - "${BUILD_ARGS[@]}" - set +x + print_and_run cmake -S . -B $BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G "Ninja Multi-Config" \ +-DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \ +-DORCA_TOOLS=ON \ +"${COLORED_OUTPUT}" \ +"${BUILD_ARGS[@]}" echo "done" echo "Building OrcaSlicer ..." - if [[ -n "${BUILD_DEBUG}" ]] ; then - cmake --build build --config Debug --target OrcaSlicer - else - cmake --build build --config Release --target OrcaSlicer - fi + print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer echo "Building OrcaSlicer_profile_validator .." - if [[ -n "${BUILD_DEBUG}" ]] ; then - cmake --build build --config Debug --target OrcaSlicer_profile_validator - else - cmake --build build --config Release --target OrcaSlicer_profile_validator - fi + print_and_run cmake --build $BUILD_DIR --config "${BUILD_CONFIG}" --target OrcaSlicer_profile_validator ./scripts/run_gettext.sh echo "done" fi if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then - pushd build > /dev/null + pushd $BUILD_DIR > /dev/null echo "[9/9] Generating Linux app..." build_linux_image="./src/build_linux_image.sh" if [[ -e ${build_linux_image} ]] ; then @@ -265,7 +255,7 @@ if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then if [[ -n "${BUILD_IMAGE}" ]] ; then extra_script_args="-i" fi - ${build_linux_image} ${extra_script_args} + print_and_run ${build_linux_image} ${extra_script_args} echo "done" fi diff --git a/build_release.bat b/build_release.bat index 6317e277c9..f751c17e5a 100644 --- a/build_release.bat +++ b/build_release.bat @@ -31,8 +31,8 @@ if "%1"=="slicer" ( ) echo "building deps.." -echo cmake ../ -G "Visual Studio 16 2019" -A x64 -DDESTDIR="%CD%/OrcaSlicer_dep" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo% -cmake ../ -G "Visual Studio 16 2019" -A x64 -DDESTDIR="%CD%/OrcaSlicer_dep" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo% +echo cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% +cmake ../ -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% cmake --build . --config %build_type% --target deps -- -m if "%1"=="deps" exit /b 0 @@ -43,8 +43,8 @@ cd %WP% mkdir %build_dir% cd %build_dir% -echo cmake .. -G "Visual Studio 16 2019" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=%build_type% -cmake .. -G "Visual Studio 16 2019" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 %SIG_FLAG% -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=%build_type% -DWIN10SDK_PATH="C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0" +echo cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% +cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=%build_type% %SIG_FLAG% cmake --build . --config %build_type% --target ALL_BUILD -- -m cd .. call scripts/run_gettext.bat diff --git a/build_release_macos.sh b/build_release_macos.sh index e336da09c7..e42490f1bd 100755 --- a/build_release_macos.sh +++ b/build_release_macos.sh @@ -109,8 +109,6 @@ echo PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_BUILD_DIR="$PROJECT_DIR/build/$ARCH" DEPS_DIR="$PROJECT_DIR/deps" -DEPS_BUILD_DIR="$DEPS_DIR/build/$ARCH" -DEPS="$DEPS_BUILD_DIR/OrcaSlicer_deps" # For Multi-config generators like Ninja and Xcode export BUILD_DIR_CONFIG_SUBDIR="/$BUILD_CONFIG" @@ -133,8 +131,6 @@ function build_deps() { if [ "1." != "$BUILD_ONLY". ]; then cmake "${DEPS_DIR}" \ -G "${DEPS_CMAKE_GENERATOR}" \ - -DDESTDIR="$DEPS" \ - -DOPENSSL_ARCH="darwin64-${_ARCH}-cc" \ -DCMAKE_BUILD_TYPE="$BUILD_CONFIG" \ -DCMAKE_OSX_ARCHITECTURES:STRING="${_ARCH}" \ -DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET}" @@ -172,15 +168,9 @@ function build_slicer() { if [ "1." != "$BUILD_ONLY". ]; then cmake "${PROJECT_DIR}" \ -G "${SLICER_CMAKE_GENERATOR}" \ - -DBBL_RELEASE_TO_PUBLIC=1 \ -DORCA_TOOLS=ON \ ${ORCA_UPDATER_SIG_KEY:+-DORCA_UPDATER_SIG_KEY="$ORCA_UPDATER_SIG_KEY"} \ - -DCMAKE_PREFIX_PATH="$DEPS/usr/local" \ - -DCMAKE_INSTALL_PREFIX="$PWD/OrcaSlicer" \ -DCMAKE_BUILD_TYPE="$BUILD_CONFIG" \ - -DCMAKE_MACOSX_RPATH=ON \ - -DCMAKE_INSTALL_RPATH="${DEPS}/usr/local" \ - -DCMAKE_MACOSX_BUNDLE=ON \ -DCMAKE_OSX_ARCHITECTURES="${_ARCH}" \ -DCMAKE_OSX_DEPLOYMENT_TARGET="${OSX_DEPLOYMENT_TARGET}" fi diff --git a/build_release_vs2022.bat b/build_release_vs2022.bat index b9c377488f..ce4390f621 100644 --- a/build_release_vs2022.bat +++ b/build_release_vs2022.bat @@ -37,7 +37,6 @@ setlocal DISABLEDELAYEDEXPANSION cd deps mkdir %build_dir% cd %build_dir% -set DEPS=%CD%/OrcaSlicer_dep set "SIG_FLAG=" if defined ORCA_UPDATER_SIG_KEY set "SIG_FLAG=-DORCA_UPDATER_SIG_KEY=%ORCA_UPDATER_SIG_KEY%" @@ -47,7 +46,7 @@ if "%1"=="slicer" ( echo "building deps.." echo on -cmake ../ -G "Visual Studio 17 2022" -A x64 -DDESTDIR="%DEPS%" -DCMAKE_BUILD_TYPE=%build_type% -DDEP_DEBUG=%debug% -DORCA_INCLUDE_DEBUG_INFO=%debuginfo% +cmake ../ -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=%build_type% cmake --build . --config %build_type% --target deps -- -m @echo off @@ -60,7 +59,7 @@ mkdir %build_dir% cd %build_dir% echo on -cmake .. -G "Visual Studio 17 2022" -A x64 -DBBL_RELEASE_TO_PUBLIC=1 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_PREFIX_PATH="%DEPS%/usr/local" -DCMAKE_INSTALL_PREFIX="./OrcaSlicer" -DCMAKE_BUILD_TYPE=%build_type% -DWIN10SDK_PATH="%WindowsSdkDir%Include\%WindowsSDKVersion%\" +cmake .. -G "Visual Studio 17 2022" -A x64 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type% cmake --build . --config %build_type% --target ALL_BUILD -- -m @echo off cd .. diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake index 432d731d28..56661ffd33 100644 --- a/cmake/modules/FindGLEW.cmake +++ b/cmake/modules/FindGLEW.cmake @@ -152,7 +152,7 @@ find_library(GLEW_STATIC_LIBRARY_RELEASE PATHS ENV GLEW_ROOT) find_library(GLEW_STATIC_LIBRARY_DEBUG - NAMES GLEWds glewd glewds glew32ds + NAMES GLEWds GLEWd glewd glewds glew32ds PATH_SUFFIXES lib lib64 PATHS ENV GLEW_ROOT) diff --git a/cmake/modules/FindNLopt.cmake b/cmake/modules/FindNLopt.cmake index 912ce8d30a..42b47f218b 100644 --- a/cmake/modules/FindNLopt.cmake +++ b/cmake/modules/FindNLopt.cmake @@ -3,13 +3,6 @@ #// #// Description: #// cmake module for finding NLopt installation -#// NLopt installation location is defined by environment variable $NLOPT -#// -#// following variables are defined: -#// NLopt_DIR - NLopt installation directory -#// NLopt_INCLUDE_DIR - NLopt header directory -#// NLopt_LIBRARY_DIR - NLopt library directory -#// NLopt_LIBS - NLopt library files #// #// Example usage: #// find_package(NLopt 1.4 REQUIRED) @@ -17,114 +10,27 @@ #// #//------------------------------------------------------------------------- +include(FindPackageHandleStandardArgs) -set(NLopt_FOUND FALSE) -set(NLopt_ERROR_REASON "") -set(NLopt_DEFINITIONS "") -unset(NLopt_LIBS CACHE) - -set(NLopt_DIR $ENV{NLOPT}) -if(NOT NLopt_DIR) - - set(NLopt_FOUND TRUE) - - set(_NLopt_LIB_NAMES "nlopt") - find_library(NLopt_LIBS - NAMES ${_NLopt_LIB_NAMES}) - if(NOT NLopt_LIBS) - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt library '${_NLopt_LIB_NAMES}'.") - else() - get_filename_component(NLopt_DIR ${NLopt_LIBS} PATH) - endif() - unset(_NLopt_LIB_NAMES) - - set(_NLopt_HEADER_FILE_NAME "nlopt.hpp") - find_file(_NLopt_HEADER_FILE - NAMES ${_NLopt_HEADER_FILE_NAME}) - if(NOT _NLopt_HEADER_FILE) - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt header file '${_NLopt_HEADER_FILE_NAME}'.") - endif() - unset(_NLopt_HEADER_FILE_NAME) - - if(NOT NLopt_FOUND) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} NLopt not found in system directories (and environment variable NLOPT is not set).") - else() - get_filename_component(NLopt_INCLUDE_DIR ${_NLopt_HEADER_FILE} DIRECTORY ) - endif() - - unset(_NLopt_HEADER_FILE CACHE) - -else() - - set(NLopt_FOUND TRUE) - - set(NLopt_INCLUDE_DIR "${NLopt_DIR}/include") - if(NOT EXISTS "${NLopt_INCLUDE_DIR}") - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Directory '${NLopt_INCLUDE_DIR}' does not exist.") - endif() - - set(NLopt_LIBRARY_DIR "${NLopt_DIR}/lib") - if(NOT EXISTS "${NLopt_LIBRARY_DIR}") - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Directory '${NLopt_LIBRARY_DIR}' does not exist.") - endif() - - set(_NLopt_LIB_NAMES "nlopt_cxx") - find_library(NLopt_LIBS - NAMES ${_NLopt_LIB_NAMES} - PATHS ${NLopt_LIBRARY_DIR} - NO_DEFAULT_PATH) - if(NOT NLopt_LIBS) - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt library '${_NLopt_LIB_NAMES}' in '${NLopt_LIBRARY_DIR}'.") - endif() - unset(_NLopt_LIB_NAMES) - - set(_NLopt_HEADER_FILE_NAME "nlopt.hpp") - find_file(_NLopt_HEADER_FILE - NAMES ${_NLopt_HEADER_FILE_NAME} - PATHS ${NLopt_INCLUDE_DIR} - NO_DEFAULT_PATH) - if(NOT _NLopt_HEADER_FILE) - set(NLopt_FOUND FALSE) - set(NLopt_ERROR_REASON "${NLopt_ERROR_REASON} Cannot find NLopt header file '${_NLopt_HEADER_FILE_NAME}' in '${NLopt_INCLUDE_DIR}'.") - endif() - unset(_NLopt_HEADER_FILE_NAME) - unset(_NLopt_HEADER_FILE CACHE) - -endif() - - -# make variables changeable -mark_as_advanced( - NLopt_INCLUDE_DIR - NLopt_LIBRARY_DIR - NLopt_LIBS - NLopt_DEFINITIONS - ) +unset(_q) +if (NLopt_FIND_QUIETLY) + set(_q QUIET) +endif () +find_package(NLopt ${NLopt_VERSION} CONFIG ${_q}) +find_package_handle_standard_args(NLopt CONFIG_MODE) # report result -if(NLopt_FOUND) - message(STATUS "Found NLopt in '${NLopt_DIR}'.") - message(STATUS "Using NLopt include directory '${NLopt_INCLUDE_DIR}'.") - message(STATUS "Using NLopt library '${NLopt_LIBS}'.") - add_library(NLopt::nlopt INTERFACE IMPORTED) - set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_LINK_LIBRARIES ${NLopt_LIBS}) - set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${NLopt_INCLUDE_DIR}) - set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${NLopt_DEFINITIONS}") - # target_link_libraries(Nlopt::Nlopt INTERFACE ${NLopt_LIBS}) - # target_include_directories(Nlopt::Nlopt INTERFACE ${NLopt_INCLUDE_DIR}) - # target_compile_definitions(Nlopt::Nlopt INTERFACE ${NLopt_DEFINITIONS}) -else() - if(NLopt_FIND_REQUIRED) - message(FATAL_ERROR "Unable to find requested NLopt installation:${NLopt_ERROR_REASON}") - else() - if(NOT NLopt_FIND_QUIETLY) - message(STATUS "NLopt was not found:${NLopt_ERROR_REASON}") - endif() - endif() +if(NLopt_FOUND AND NOT _q) + get_filename_component(NLOPT_LIBRARY_DIRS ${NLOPT_LIBRARY_DIRS} ABSOLUTE) + get_filename_component(NLOPT_INCLUDE_DIRS ${NLOPT_INCLUDE_DIRS} ABSOLUTE) + + message(STATUS "Found NLopt in '${NLOPT_LIBRARY_DIRS}'.") + message(STATUS "Using NLopt include directory '${NLOPT_INCLUDE_DIRS}'.") + + get_target_property(_configs NLopt::nlopt IMPORTED_CONFIGURATIONS) + foreach (_config ${_configs}) + get_target_property(_lib NLopt::nlopt IMPORTED_LOCATION_${_config}) + message(STATUS "Found NLopt ${_config} library: ${_lib}") + endforeach () endif() diff --git a/cmake/modules/Findlibnoise.cmake b/cmake/modules/Findlibnoise.cmake index f40ce0fabd..74e3a5ea1e 100644 --- a/cmake/modules/Findlibnoise.cmake +++ b/cmake/modules/Findlibnoise.cmake @@ -1,15 +1,41 @@ find_path(LIBNOISE_INCLUDE_DIR libnoise/noise.h) -find_library(LIBNOISE_LIBRARY NAMES libnoise libnoise_static liblibnoise_static) +find_library(LIBNOISE_LIBRARY_RELEASE NAMES libnoise libnoise_static liblibnoise_static) +find_library(LIBNOISE_LIBRARY_DEBUG NAMES libnoised libnoise_staticd liblibnoise_staticd) + +set(libnoise_LIB_FOUND FALSE) +if (LIBNOISE_LIBRARY_RELEASE OR LIBNOISE_LIBRARY_DEBUG) + set(libnoise_LIB_FOUND TRUE) +endif () + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(libnoise DEFAULT_MSG - LIBNOISE_LIBRARY + libnoise_LIB_FOUND LIBNOISE_INCLUDE_DIR ) if(libnoise_FOUND) add_library(noise::noise STATIC IMPORTED) + set_target_properties(noise::noise PROPERTIES - IMPORTED_LOCATION "${LIBNOISE_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LIBNOISE_INCLUDE_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBNOISE_INCLUDE_DIR}" ) + if (NOT libnoise_FIND_QUIETLY) + message(STATUS "Found libnoise include directory: ${LIBNOISE_INCLUDE_DIR}") + if (LIBNOISE_LIBRARY_RELEASE) + message(STATUS "Found libnoise RELEASE library: ${LIBNOISE_LIBRARY_RELEASE}") + endif () + if (LIBNOISE_LIBRARY_DEBUG) + message(STATUS "Found libnoise DEBUG library: ${LIBNOISE_LIBRARY_DEBUG}") + endif () + endif () + + if (LIBNOISE_LIBRARY_RELEASE) + set_property(TARGET noise::noise APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(noise::noise PROPERTIES IMPORTED_LOCATION_RELEASE ${LIBNOISE_LIBRARY_RELEASE}) + endif () + + if (LIBNOISE_LIBRARY_DEBUG) + set_property(TARGET noise::noise APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(noise::noise PROPERTIES IMPORTED_LOCATION_DEBUG ${LIBNOISE_LIBRARY_DEBUG}) + endif () endif() \ No newline at end of file diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index df099e7db4..13f3945d0c 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -36,6 +36,11 @@ endif() project(OrcaSlicer-deps) +# Backward compatibility for old CMake versions +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_VERSION VERSION_LESS "3.25") + set(LINUX ON CACHE BOOL "" FORCE) +endif () + include(ExternalProject) include(ProcessorCount) @@ -44,9 +49,36 @@ if (NPROC EQUAL 0) set(NPROC 1) endif () -set(DESTDIR "${CMAKE_CURRENT_BINARY_DIR}/destdir" CACHE PATH "Destination directory") set(DEP_DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/DL_CACHE CACHE PATH "Path for downloaded source packages.") set(FLATPAK FALSE CACHE BOOL "Toggles various build settings for flatpak, like /usr/local in DESTDIR or not building wxwidgets") + +if ("${DESTDIR}" STREQUAL "" OR "${DESTDIR}" STREQUAL "${AUTOGENERATED_DESTDIR}") + if (LINUX AND (NOT DEFINED USE_OLD_DESTDIR_PREV OR USE_OLD_DESTDIR_PREV) AND EXISTS "${CMAKE_BINARY_DIR}/destdir/usr/local" AND NOT EXISTS "${CMAKE_BINARY_DIR}/OrcaSlicer_dep/usr/local") + set(USE_OLD_DESTDIR TRUE) + message(WARNING "You are using an old directory name for dependencies that is being deprecated. " + "Please remove the \"destdir\" directory and rebuild to update to the new name. " + "The current \"destdir\" directory will be used until then.") + endif () + if (NOT USE_OLD_DESTDIR AND USE_OLD_DESTDIR_PREV) + set(REGEN_DESTDIR TRUE) + endif () +else () + unset(AUTOGENERATED_DESTDIR CACHE) +endif () + +if ("${DESTDIR}" STREQUAL "" OR REGEN_DESTDIR) + if (USE_OLD_DESTDIR) # backward compatibility for old directory name + set(DESTDIR "${CMAKE_BINARY_DIR}/destdir" CACHE PATH "Path to dependencies install directory" FORCE) + else () + set(DESTDIR "${CMAKE_BINARY_DIR}/OrcaSlicer_dep" CACHE PATH "Path to dependencies install directory" FORCE) + endif () + set(DESTDIR_MSG "(generated automatically and saved to cache)") + set(AUTOGENERATED_DESTDIR ${DESTDIR} CACHE STRING "Provides the last autogenerated destdir" FORCE) + unset(REGEN_DESTDIR CACHE) +else () + set(DESTDIR_MSG "(from cache or command line)") +endif () + if (NOT FLATPAK) set(DESTDIR "${DESTDIR}/usr/local/") endif() @@ -56,15 +88,32 @@ get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if (_is_multi) option(DEP_DEBUG "Build debug variants (only applicable on Windows)" OFF) option(ORCA_INCLUDE_DEBUG_INFO "Includes debug information in a release build (like RelWithDebInfo) in a way that works with multi-configuration generators and incompatible dependencies. DEP_DEBUG option takes priority over this." OFF) + option(AUTO_DEBUG_WORKAROUND "Automatically sets DEP_DEBUG and ORCA_INCLUDE_DEBUG_INFO based on CMAKE_BUILD_TYPE" ON) + + if (AUTO_DEBUG_WORKAROUND) + set(DEP_DEBUG OFF) + set(ORCA_INCLUDE_DEBUG_INFO OFF) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DEP_DEBUG ON) + message(STATUS "DEP_DEBUG has been automatically turned ON due to CMAKE_BUILD_TYPE being set to Debug") + elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set(ORCA_INCLUDE_DEBUG_INFO ON) + message(STATUS "ORCA_INCLUDE_DEBUG_INFO has been automatically turned ON due to CMAKE_BUILD_TYPE being set to RelWithDebInfo") + endif () + endif () endif () if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - option(DEP_WX_GTK3 "Build wxWidgets against GTK3" OFF) + option(DEP_WX_GTK3 "Build wxWidgets against GTK3" ON) endif() set(IS_CROSS_COMPILE FALSE) if (APPLE) + list(LENGTH CMAKE_OSX_ARCHITECTURES _arch_len) + if (_arch_len GREATER 1) + message(FATAL_ERROR "OrcaSlicer only supports building for one architecture at a time. Please make sure only one architecture is specified in CMAKE_OSX_ARCHITECTURES") + endif () set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_APPBUNDLE LAST) list(FIND CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} _arch_idx) @@ -87,7 +136,7 @@ endif () # Slic3r compiles with a different version which will cause runtime errors. # option(DEP_BUILD_IGL_STATIC "Build IGL as a static library. Might cause link errors and increase binary size." OFF) -message(STATUS "OrcaSlicer deps DESTDIR: ${DESTDIR}") +message(STATUS "OrcaSlicer deps DESTDIR: ${DESTDIR} ${DESTDIR_MSG}") message(STATUS "OrcaSlicer download dir for source packages: ${DEP_DOWNLOAD_DIR}") message(STATUS "OrcaSlicer deps debug build: ${DEP_DEBUG}") @@ -144,39 +193,26 @@ if (NOT IS_CROSS_COMPILE OR NOT APPLE) BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j} INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release ) -elseif(FLATPAK) - # the only reason this is here is because of the HACK at the bottom for ci - # - # note for future devs: shared libs may actually create a size reduction - # but orcaslicer_deps tends to get really funny regarding linking after that (notably boost) - # so, as much as I would like to use that, it's not happening - ExternalProject_Add( - dep_${projectname} - EXCLUDE_FROM_ALL ON - INSTALL_DIR ${DESTDIR} - DOWNLOAD_DIR ${DEP_DOWNLOAD_DIR}/${projectname} - ${_gen} - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:STRING=${DESTDIR} - -DCMAKE_MODULE_PATH:STRING=${PROJECT_SOURCE_DIR}/../cmake/modules - -DCMAKE_PREFIX_PATH:STRING=${DESTDIR} - -DCMAKE_DEBUG_POSTFIX:STRING=d - -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} - -DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE} - -DBUILD_SHARED_LIBS:BOOL=OFF - ${_cmake_osx_arch} - "${_configs_line}" - ${DEP_CMAKE_OPTS} - ${P_ARGS_CMAKE_ARGS} - ${P_ARGS_UNPARSED_ARGUMENTS} - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release -- ${_build_j} - INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config Release - # HACK: save space after each compile job, because CI - # reasoning: cmake changes directory after this command, so just keep only the folders - # so that it can navigate out - COMMAND find "${CMAKE_BINARY_DIR}/dep_${projectname}-prefix/" -type f -delete - ) + + if (FLATPAK) + # Free up space during flatpak builds to prevent running out of space during CI/CD + + # note for future devs: shared libs may actually create a size reduction + # but orcaslicer_deps tends to get really funny regarding linking after that (notably boost) + # so, as much as I would like to use that, it's not happening + ExternalProject_Add_Step(dep_${projectname} free_download_space + DEPENDEES download # do after download + COMMENT "Freeing Space: Removing source archive" + WORKING_DIRECTORY ${DEP_DOWNLOAD_DIR} + COMMAND ${CMAKE_COMMAND} -E rm -r ${projectname} + ) + ExternalProject_Add_Step(dep_${projectname} free_build_space + DEPENDEES install # do after install + COMMENT "Freeing Space: Removing source and build files" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dep_${projectname}-prefix/src + COMMAND ${CMAKE_COMMAND} -E rm -rf dep_${projectname} dep_${projectname}-build + ) + endif () else() ExternalProject_Add( dep_${projectname} @@ -320,10 +356,10 @@ if (NOT JPEG_FOUND) set(JPEG_PKG dep_JPEG) endif() -# flatpak builds wxwidgets separately +# flatpak builds wxwidgets separately, so it is not included in the deps target set(WXWIDGETS_PKG "") +include(wxWidgets/wxWidgets.cmake) if (NOT FLATPAK) - include(wxWidgets/wxWidgets.cmake) set(WXWIDGETS_PKG "dep_wxWidgets") endif() diff --git a/deps/OpenSSL/OpenSSL.cmake b/deps/OpenSSL/OpenSSL.cmake index 45f82ec589..79465747e8 100644 --- a/deps/OpenSSL/OpenSSL.cmake +++ b/deps/OpenSSL/OpenSSL.cmake @@ -8,7 +8,7 @@ else() if(WIN32) set(_cross_arch "VC-WIN64A") elseif(APPLE) - set(_cross_arch "darwin64-arm64-cc") + set(_cross_arch "darwin64-${CMAKE_OSX_ARCHITECTURES}-cc") endif() endif() diff --git a/deps/wxWidgets/wxWidgets.cmake b/deps/wxWidgets/wxWidgets.cmake index 247381726c..e45979fb42 100644 --- a/deps/wxWidgets/wxWidgets.cmake +++ b/deps/wxWidgets/wxWidgets.cmake @@ -1,5 +1,7 @@ set(_wx_toolkit "") -set(_wx_private_font "-DwxUSE_PRIVATE_FONTS=1") +set(_wx_debug_postfix "") +set(_wx_shared -DwxBUILD_SHARED=OFF) +set(_wx_flatpak_patch "") if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(_gtk_ver 2) @@ -9,6 +11,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") endif () set(_wx_toolkit "-DwxBUILD_TOOLKIT=gtk${_gtk_ver}") + if (FLATPAK) + set(_wx_debug_postfix "d") + set(_wx_shared -DwxBUILD_SHARED=ON -DBUILD_SHARED_LIBS:BOOL=ON) + set(_wx_flatpak_patch PATCH_COMMAND ${PATCH_CMD} ${CMAKE_CURRENT_LIST_DIR}/0001-flatpak.patch) + endif () endif() if (MSVC) @@ -17,34 +24,29 @@ else () set(_wx_edge "-DwxUSE_WEBVIEW_EDGE=OFF") endif () -# Note: The flatpak build builds wxwidgets separately due to CI size constraints. -# ANY CHANGES MADE IN HERE MUST ALSO BE REFLECTED IN `scripts/flatpak/io.github.SoftFever.OrcaSlicer.yml`. -# ** THIS INCLUDES BUILD ARGS. ** -# ...if you can find a way around this size limitation, be my guest. - orcaslicer_add_cmake_project( wxWidgets GIT_REPOSITORY "https://github.com/SoftFever/Orca-deps-wxWidgets" GIT_SHALLOW ON DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} ${JPEG_PKG} + ${_wx_flatpak_patch} CMAKE_ARGS -DwxBUILD_PRECOMP=ON ${_wx_toolkit} - "-DCMAKE_DEBUG_POSTFIX:STRING=" + "-DCMAKE_DEBUG_POSTFIX:STRING=${_wx_debug_postfix}" -DwxBUILD_DEBUG_LEVEL=0 -DwxBUILD_SAMPLES=OFF - -DwxBUILD_SHARED=OFF + ${_wx_shared} -DwxUSE_MEDIACTRL=ON -DwxUSE_DETECT_SM=OFF -DwxUSE_UNICODE=ON - ${_wx_private_font} + -DwxUSE_PRIVATE_FONTS=ON -DwxUSE_OPENGL=ON -DwxUSE_WEBREQUEST=ON -DwxUSE_WEBVIEW=ON ${_wx_edge} -DwxUSE_WEBVIEW_IE=OFF -DwxUSE_REGEX=builtin - -DwxUSE_LIBXPM=builtin -DwxUSE_LIBSDL=OFF -DwxUSE_XTEST=OFF -DwxUSE_STC=OFF @@ -53,7 +55,6 @@ orcaslicer_add_cmake_project( -DwxUSE_ZLIB=sys -DwxUSE_LIBJPEG=sys -DwxUSE_LIBTIFF=OFF - -DwxUSE_NANOSVG=OFF -DwxUSE_EXPAT=sys ) diff --git a/scripts/flatpak/io.github.softfever.OrcaSlicer.yml b/scripts/flatpak/io.github.softfever.OrcaSlicer.yml index 6b4d26dd4a..5bb8d7fe63 100755 --- a/scripts/flatpak/io.github.softfever.OrcaSlicer.yml +++ b/scripts/flatpak/io.github.softfever.OrcaSlicer.yml @@ -64,219 +64,54 @@ modules: url: https://github.com/FreeSpacenav/libspnav/releases/download/v1.2/libspnav-1.2.tar.gz sha256: 093747e7e03b232e08ff77f1ad7f48552c06ac5236316a5012db4269951c39db - - name: orca_wxwidgets - buildsystem: simple - build-commands: - - | - mkdir builddir && cd builddir - cmake ../ -GNinja \ - -DwxBUILD_PRECOMP=ON \ - -DwxBUILD_TOOLKIT=gtk3 \ - -DwxBUILD_DEBUG_LEVEL=0 \ - -DwxBUILD_SAMPLES=OFF \ - -DwxBUILD_SHARED=ON \ - -DwxUSE_MEDIACTRL=ON \ - -DwxUSE_DETECT_SM=OFF \ - -DwxUSE_UNICODE=ON \ - -DwxUSE_PRIVATE_FONTS=ON \ - -DwxUSE_OPENGL=ON \ - -DwxUSE_WEBREQUEST=ON \ - -DwxUSE_WEBVIEW=ON \ - -DwxUSE_WEBVIEW_EDGE=OFF \ - -DwxUSE_WEBVIEW_IE=OFF \ - -DwxUSE_REGEX=builtin \ - -DwxUSE_LIBSDL=OFF \ - -DwxUSE_XTEST=OFF \ - -DwxUSE_STC=OFF \ - -DwxUSE_AUI=ON \ - -DwxUSE_LIBPNG=sys \ - -DwxUSE_ZLIB=sys \ - -DwxUSE_LIBJPEG=sys \ - -DwxUSE_LIBTIFF=OFF \ - -DwxUSE_EXPAT=sys \ - -DBUILD_SHARED_LIBS:BOOL=ON \ - -DCMAKE_INSTALL_PREFIX:STRING=/app \ - -DCMAKE_PREFIX_PATH=/app \ - -DCMAKE_BUILD_TYPE=Release - cmake --build . --target install -j$FLATPAK_BUILDER_N_JOBS - sources: - - type: git - url: https://github.com/SoftFever/Orca-deps-wxWidgets - branch: master - path: ../ - - type: file - path: patches/0001-Enable-using-a-dark-theme-when-Gnome-dark-style-is-s.patch - dest-filename: wxwidgets-dark-theme.patch - - type: shell - commands: - - patch -p1 < wxwidgets-dark-theme.patch - cleanup: - - "*.la" - - "*.a" - - "*.cmake" - - /include - - /app/bin/* - - name: orca_deps + build-options: + build-args: + - --share=network # allow cmake to download the needed deps + env: + BUILD_DIR: deps/build_flatpak buildsystem: simple build-commands: # start build - | - mkdir -p deps/build_flatpak && cd deps/build_flatpak - cmake ../ \ - -DDEP_WX_GTK3=ON \ + cmake -S deps -B $BUILD_DIR \ + -DFLATPAK=ON \ -DDEP_DOWNLOAD_DIR=/run/build/orca_deps/external-packages \ -DCMAKE_PREFIX_PATH=/app \ -DDESTDIR=/app \ - -DFLATPAK=ON \ -DCMAKE_INSTALL_PREFIX=/app - cmake --build . --parallel - rm -rf /run/build/orca_deps/external-packages - + - cmake --build $BUILD_DIR --parallel --target dep_wxWidgets + - cmake --build $BUILD_DIR --parallel + - rm -rf /run/build/orca_deps/external-packages + cleanup: - /app/include - "*.a" - "*.la" sources: - # - - # Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* . - # -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest. - # - # NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/ - # - - # OrcaSlicer Source Archive - type: dir - path: ../../ + path: ../../deps + dest: deps - # Blosc - type: file - url: https://github.com/tamasmeszaros/c-blosc/archive/refs/heads/v1.17.0_tm.zip - dest: external-packages/Blosc - sha256: dcb48bf43a672fa3de6a4b1de2c4c238709dad5893d1e097b8374ad84b1fc3b3 - - # Cereal - - type: file - url: https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.0.zip - dest: external-packages/Cereal - sha256: 71642cb54658e98c8f07a0f0d08bf9766f1c3771496936f6014169d3726d9657 - - # CGAL - - type: file - url: https://github.com/CGAL/cgal/archive/refs/tags/v5.4.zip - dest: external-packages/CGAL - sha256: d7605e0a5a5ca17da7547592f6f6e4a59430a0bc861948974254d0de43eab4c0 - - # GMP - - type: file - url: https://github.com/SoftFever/OrcaSlicer_deps/releases/download/gmp-6.2.1/gmp-6.2.1.tar.bz2 - dest: external-packages/GMP - sha256: eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c - - # curl - - type: file - url: https://github.com/curl/curl/archive/refs/tags/curl-7_75_0.zip - dest: external-packages/CURL - sha256: a63ae025bb0a14f119e73250f2c923f4bf89aa93b8d4fafa4a9f5353a96a765a - - # MPFR - - type: file - url: https://www.mpfr.org/mpfr-4.2.2/mpfr-4.2.2.tar.bz2 - dest: external-packages/MPFR - sha256: 9ad62c7dc910303cd384ff8f1f4767a655124980bb6d8650fe62c815a231bb7b - - # NLopt - - type: file - url: https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz - dest: external-packages/NLopt - sha256: c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae - - # OCCT - - type: file - url: https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_6_0.zip - dest: external-packages/OCCT - sha256: 28334f0e98f1b1629799783e9b4d21e05349d89e695809d7e6dfa45ea43e1dbc - - # OpenCSG - - type: file - url: https://github.com/floriankirsch/OpenCSG/archive/refs/tags/opencsg-1-4-2-release.zip - dest: external-packages/OpenCSG - sha256: 51afe0db79af8386e2027d56d685177135581e0ee82ade9d7f2caff8deab5ec5 - - # OpenCV - - type: file - url: https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz - dest: external-packages/OpenCV - sha256: 1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277 - - # OpenEXR - - type: file - url: https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v2.5.5.zip - dest: external-packages/OpenEXR - sha256: 0307a3d7e1fa1e77e9d84d7e9a8694583fbbbfd50bdc6884e2c96b8ef6b902de - - # OpenSSL - - type: file - url: https://github.com/openssl/openssl/archive/OpenSSL_1_1_1w.tar.gz - dest: external-packages/OpenSSL - sha256: 2130e8c2fb3b79d1086186f78e59e8bc8d1a6aedf17ab3907f4cb9ae20918c41 - - # OpenVDB - - type: file - url: https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip - dest: external-packages/OpenVDB - sha256: f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81 - - # Qhull - - type: file - url: https://github.com/qhull/qhull/archive/v8.0.1.zip - dest: external-packages/Qhull - sha256: 5287f5edd6a0372588f5d6640799086a4033d89d19711023ef8229dd9301d69b - - # TBB - - type: file - url: https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.5.0.zip - dest: external-packages/TBB - sha256: 83ea786c964a384dd72534f9854b419716f412f9d43c0be88d41874763e7bb47 - - # Boost - - type: file - url: https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz - dest: external-packages/Boost - sha256: 4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95 - - # GLFW - - type: file - url: https://github.com/glfw/glfw/archive/refs/tags/3.3.7.zip - dest: external-packages/GLFW - sha256: e02d956935e5b9fb4abf90e2c2e07c9a0526d7eacae8ee5353484c69a2a76cd0 - # libnoise - - type: file - url: https://github.com/SoftFever/Orca-deps-libnoise/archive/refs/tags/1.0.zip - dest: external-packages/libnoise - sha256: 96ffd6cc47898dd8147aab53d7d1b1911b507d9dbaecd5613ca2649468afd8b6 + path: patches/0001-Enable-using-a-dark-theme-when-Gnome-dark-style-is-s.patch + dest: deps/wxWidgets + dest-filename: 0001-flatpak.patch - name: OrcaSlicer buildsystem: simple build-commands: - | - mkdir -p build_flatpak - CXXFLAGS=-std=gnu++20 cmake . -B build_flatpak \ - -DSLIC3R_PCH=OFF \ - -DSLIC3R_FHS=ON \ - -DSLIC3R_GTK=3 \ - -DSLIC3R_STATIC=ON \ - -DBUILD_TESTS=OFF \ - -DSLIC3R_DESKTOP_INTEGRATION=OFF \ - -DCMAKE_BUILD_TYPE=Release \ + cmake . -B build_flatpak \ -DFLATPAK=ON \ - -DBBL_RELEASE_TO_PUBLIC=1 \ + -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/app \ -DCMAKE_INSTALL_PREFIX=/app - CXXFLAGS=-std=gnu++20 cmake --build build_flatpak --target OrcaSlicer -j$FLATPAK_BUILDER_N_JOBS - ./scripts/run_gettext.sh - CXXFLAGS=-std=gnu++20 cmake --build build_flatpak --target install -j$FLATPAK_BUILDER_N_JOBS + - cmake --build build_flatpak --target OrcaSlicer -j$FLATPAK_BUILDER_N_JOBS + - ./scripts/run_gettext.sh + - cmake --build build_flatpak --target install -j$FLATPAK_BUILDER_N_JOBS cleanup: - /include @@ -292,16 +127,29 @@ modules: install -Dm755 umount /app/bin sources: - # - - # Section bellow fetches all OrcaSlicer dependencies before the build process and stores them in external-packages/*/* . - # -DDEP_DOWNLOAD_DIR is set in the build process which has to match with dest. - # - # NOTE: The url, dest folder name and sha256 must match from OrcaSlicer's cmake scripts and folder names in OrcaSlicer/deps/ - # - - # OrcaSlicer Source Archive - - type: dir - path: ../../ + - type: dir + path: ../../cmake + dest: cmake + - type: dir + path: ../../deps_src + dest: deps_src + - type: dir + path: ../../resources + dest: resources + - type: dir + path: ../../src + dest: src + + - type: file + path: ../../CMakeLists.txt + - type: file + path: ../../LICENSE.txt + - type: file + path: ../../version.inc + - type: file + path: ../run_gettext.sh + dest: scripts # AppData metainfo for Gnome Software & Co. - type: file diff --git a/scripts/linux.d/arch b/scripts/linux.d/arch index 48aafb587b..2cdde3ed3c 100644 --- a/scripts/linux.d/arch +++ b/scripts/linux.d/arch @@ -1,7 +1,5 @@ #!/bin/bash # these are the Arch Linux specific build functions -export FOUND_GTK3 -FOUND_GTK3=$(pacman -Q gtk3) # Addtional Dev packages for OrcaSlicer export REQUIRED_DEV_PACKAGES=( @@ -45,4 +43,4 @@ then fi export FOUND_GTK3_DEV -FOUND_GTK3_DEV=${FOUND_GTK3} +FOUND_GTK3_DEV=$(pacman -Q gtk3) diff --git a/scripts/linux.d/clear-linux-os b/scripts/linux.d/clear-linux-os index 9174634867..2481da19ec 100644 --- a/scripts/linux.d/clear-linux-os +++ b/scripts/linux.d/clear-linux-os @@ -1,7 +1,5 @@ #!/bin/bash # these are the Clear Linux specific build functions -export FOUND_GTK3 -FOUND_GTK3=$(find /usr/lib64/libgtk-3.so.* 2>/dev/null | tail -n 1 || true) # Addtional bundles for OrcaSlicer export REQUIRED_BUNDLES=( diff --git a/scripts/linux.d/debian b/scripts/linux.d/debian index 206856a6f4..ca090d670d 100644 --- a/scripts/linux.d/debian +++ b/scripts/linux.d/debian @@ -1,6 +1,4 @@ #!/bin/bash -export FOUND_GTK3 -FOUND_GTK3=$(dpkg -l libgtk* | grep gtk-3 || echo '') REQUIRED_DEV_PACKAGES=( autoconf diff --git a/scripts/linux.d/fedora b/scripts/linux.d/fedora index b49e0cda22..553675a125 100644 --- a/scripts/linux.d/fedora +++ b/scripts/linux.d/fedora @@ -1,6 +1,4 @@ #!/bin/bash -export FOUND_GTK3 -FOUND_GTK3=$(rpm -qa | grep -P '^gtk3' || true) REQUIRED_DEV_PACKAGES=( autoconf diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33cf83734f..270a7742c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,8 @@ add_subdirectory(dev-utils) # add_subdirectory(avrdude) # Note: semver and hints are now included from deps_src/CMakeLists.txt +find_package(libnoise REQUIRED) + add_subdirectory(libslic3r) if (SLIC3R_GUI) diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 14af89a92b..ccda6e17de 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -564,7 +564,6 @@ set(OCCT_LIBS TKernel ) -find_package(libnoise REQUIRED) target_link_libraries(libslic3r PUBLIC admesh diff --git a/src/libslic3r/libslic3r_version.h.in b/src/libslic3r/libslic3r_version.h.in index a0e82cd9d3..750e092d28 100644 --- a/src/libslic3r/libslic3r_version.h.in +++ b/src/libslic3r/libslic3r_version.h.in @@ -10,7 +10,6 @@ #endif #define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@" //#define SLIC3R_RC_VERSION "@SLIC3R_VERSION@" -#define BBL_RELEASE_TO_PUBLIC @BBL_RELEASE_TO_PUBLIC@ #define BBL_INTERNAL_TESTING @BBL_INTERNAL_TESTING@ #define ORCA_CHECK_GCODE_PLACEHOLDERS @ORCA_CHECK_GCODE_PLACEHOLDERS@ diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 71e7991a55..703509fb11 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -687,7 +687,6 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SLIC3R_GUI_SOURCES}) encoding_check(libslic3r_gui) -find_package(libnoise REQUIRED) target_link_libraries(libslic3r_gui libslic3r cereal::cereal imgui imguizmo minilzo GLEW::GLEW OpenGL::GL hidapi ${wxWidgets_LIBRARIES} glfw libcurl OpenSSL::SSL OpenSSL::Crypto noise::noise) if (MSVC) diff --git a/version.inc b/version.inc index 0ca14c629e..d6c6b293b3 100644 --- a/version.inc +++ b/version.inc @@ -4,9 +4,6 @@ set(SLIC3R_APP_NAME "OrcaSlicer") set(SLIC3R_APP_KEY "OrcaSlicer") -if(NOT DEFINED BBL_RELEASE_TO_PUBLIC) -set(BBL_RELEASE_TO_PUBLIC "1") -endif() if(NOT DEFINED BBL_INTERNAL_TESTING) set(BBL_INTERNAL_TESTING "0") endif()