From 558603e0f562e9d36ad7afb2d2c04f9f61b41b01 Mon Sep 17 00:00:00 2001 From: Christophe Meynard Date: Thu, 20 Jun 2024 15:05:18 +0200 Subject: [PATCH] MMVII: Rewrite MMVII compilation and packaging for Windows with libproj --- .github/workflows/build_mmvii.yml | 55 +++++++++++++++++++++---------- MMVII/.gitignore | 1 + MMVII/CMakeLists.txt | 24 +++++--------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_mmvii.yml b/.github/workflows/build_mmvii.yml index 57030b06d9..68ad735860 100644 --- a/.github/workflows/build_mmvii.yml +++ b/.github/workflows/build_mmvii.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Qt and clang run: | @@ -78,18 +78,23 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Install libproj - run: vcpkg install proj --triplet x64-windows - # vcpkg-pkgconfig-get-modules proj --triplet x64-windows-release + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + + - name: Install PROJ with miniconda + run: conda install -y proj + if: steps.cache-conda-gdal.outputs.cache-hit != 'true' - name: Install Qt uses: jurplel/install-qt-action@v3 with: cache: true - - name: Configure CMake + - name: Configure CMake for mm3d run: cmake -B build -DWITH_CCACHE=OFF -DCMAKE_BUILD_TYPE=Release -DWITH_QT5=ON -DCMAKE_INSTALL_PREFIX=${{github.workspace}} - name: Cache mm3d build @@ -105,9 +110,19 @@ jobs: - if: ${{ steps.cache-mm3d-windows.outputs.cache-hit != 'true' }} name: Build elise.lib and mm3d run: cmake --build build --config Release --target INSTALL -j 4 + + - name: Force save mm3d build cache + uses: actions/cache/save@v3 + if: always() + with: + path: | + lib/elise.lib + lib/ANN.lib + bin/mm3d.exe + key: ${{ runner.os }}-build-mm3d-${{ hashFiles('src/**/*.cpp','src/**/*.h','include/**/*.h','!src/util/GIT_defines.cpp') }} - name: Configure CMake for MMVII - run: cmake -S MMVII -B MMVII/build -DCMAKE_INSTALL_PREFIX=${{github.workspace}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake + run: cmake -S MMVII -B MMVII/build -DCMAKE_PREFIX_PATH=C:/Miniconda/envs/test/Library - name: Build MMVII run: cmake --build MMVII/build --config Release -j 4 --target full @@ -119,21 +134,27 @@ jobs: - name: Package shell: bash run: | - env - mkdir -p bin/platforms bin/imageformats MMVII/bin/platforms - cp ${Qt5_Dir}/plugins/platforms/qwindows.dll MMVII/bin/platforms/ - DEST=$(pwd)/bin + rm -fr MMVII/bin/Makefile* MMVII/bin/*.makefile MMVII/bin/MMVII-* MMVII/bin/P2007.lib MMVII/MMVII-TestDir/Tmp/ + mkdir -p micmac/include micmac/MMVII + cp -a bin/ binaire-aux/ micmac/ + cp -a include/XML_MicMac include/XML_GEN/ include/qt micmac/include/ + cp -a MMVII/MMVII-LocalParameters/ MMVII/MMVII-RessourceDir/ MMVII/MMVII-TestDir/ MMVII/bin/ MMVII/share/ micmac/MMVII/ + mkdir -p micmac/bin/platforms micmac/bin/imageformats micmac/MMVII/bin/platforms + MMVII_BINDIR=$(pwd)/micmac/MMVII/bin + MM3D_BINDIR=$(pwd)/micmac/bin + cp ${Qt5_Dir}/plugins/platforms/qwindows.dll ${MMVII_BINDIR}/platforms/ + cd /C/Miniconda/envs/test/Library/bin/ + cp deflate.dll Lerc.dll libcrypto-3-x64.dll libcurl.dll liblzma.dll libssh2.dll proj_9_3.dll sqlite3.dll tiff.dll zlib.dll zstd.dll ${MMVII_BINDIR}/ cd $Qt5_Dir/bin - cp Qt5Core.dll Qt5Gui.dll Qt5Xml.dll Qt5OpenGL.dll Qt5Widgets.dll $DEST/ + cp Qt5Core.dll Qt5Gui.dll Qt5Xml.dll Qt5OpenGL.dll Qt5Widgets.dll ${MM3D_BINDIR}/ cd $Qt5_Dir/plugins - cp platforms/qwindows.dll $DEST/platforms/ - cp imageformats/*.dll $DEST/imageformats/ + cp platforms/qwindows.dll ${MM3D_BINDIR}/platforms/ + cp imageformats/*.dll ${MM3D_BINDIR}/imageformats/ cd $GITHUB_WORKSPACE - ls -lrt bin MMVII/bin - name: Create Zip - run: 7z a mmvii_windows.zip bin\ binaire-aux\ include\XML_MicMac\ include\XML_GEN\ include\qt MMVII\MMVII-LocalParameters\ MMVII\MMVII-RessourceDir\ MMVII\bin\MMVII.exe MMVII\bin\vMMVII.exe MMVII\bin\platforms - + run: 7z a mmvii_windows.zip micmac + - name: Remove previous Windows MMVII build release env: GH_TOKEN: ${{ github.token }} diff --git a/MMVII/.gitignore b/MMVII/.gitignore index 9841a88dbb..6cfae0b931 100755 --- a/MMVII/.gitignore +++ b/MMVII/.gitignore @@ -20,6 +20,7 @@ MMVII-PhgrProj/ MMVII-PhgrProj*/ MMVII-Tmp-Dir-Glob/ Tmp-MM-Dir/ +/share/ .*.d !bin/ bin/* diff --git a/MMVII/CMakeLists.txt b/MMVII/CMakeLists.txt index 099652a891..ea2eaf8c42 100644 --- a/MMVII/CMakeLists.txt +++ b/MMVII/CMakeLists.txt @@ -34,16 +34,17 @@ endif() ## Dependencies ####################################################### +# PROJ find_package(PROJ QUIET) -if (PROJ_FOUND) - message(STATUS "Found PROJ") - set(PROJ_LIB PROJ::proj) -else() - # FindPkgConfig +if (NOT PROJ_FOUND) + # needed on Ubuntu find_package(PkgConfig) - # libPROJ pkg_search_module(PROJ REQUIRED proj) - set(PROJ_LIB ${PROJ_LIBRARIES}) +endif() + +if (CMAKE_HOST_WIN32) + find_file(PROJ_PROJ_DB_FILE proj.db PATHS ${PROJ_DIR} ${PROJ_BINARY_DIRS}/../share/proj NO_DEFAULT_PATH) + file(COPY ${PROJ_PROJ_DB_FILE} DESTINATION ${MMVII_SOURCE_DIR}/share/proj) endif() @@ -51,16 +52,12 @@ endif() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) - - - # OpenMP: Optional, included in GNU C++, separate package for CLANG. find_package(OpenMP) if((NOT OpenMP_CXX_FOUND) AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) message(STATUS "OpenMP not found: did you install libomp-dev ?") endif() - ####################################################### ## Compilation toolchain ####################################################### @@ -125,9 +122,7 @@ file(GLOB mmv2_headers "${mmv2_include_dir}/*.h" "${mmv2_include_dir}/*/*.h" "${ ####################################################### add_library(P2007 "${mmv2_libsrcs}" "${mmv2_headers}") target_include_directories(P2007 PRIVATE "${mmv2_include_dir};${mmv1_include_dir};${EIGEN3_INCLUDE_PATH};${PROJ_INCLUDE_DIRS}") -target_link_libraries(P2007 PRIVATE MMVII_compiler_flags Threads::Threads) - -target_link_libraries(P2007 PRIVATE ${PROJ_LIB}) +target_link_libraries(P2007 PRIVATE MMVII_compiler_flags Threads::Threads ${PROJ_LIBRARIES}) # Force parallel compilation with MSVC if(MSVC) @@ -147,7 +142,6 @@ else() endif() target_include_directories(MMVII PRIVATE "${MMVII_SOURCE_DIR}/include" ) - target_link_libraries(MMVII PRIVATE MMVII_compiler_flags Threads::Threads P2007 ${mmv1_libs} ${mmv2_extlibs}) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.1") target_link_libraries(MMVII PRIVATE -lstdc++fs)