Skip to content

Commit

Permalink
MMVII: Rewrite MMVII compilation and packaging for Windows with libproj
Browse files Browse the repository at this point in the history
  • Loading branch information
meynardc committed Jun 20, 2024
1 parent 4525fab commit 558603e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
55 changes: 38 additions & 17 deletions .github/workflows/build_mmvii.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Qt and clang
run: |
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions MMVII/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MMVII-PhgrProj/
MMVII-PhgrProj*/
MMVII-Tmp-Dir-Glob/
Tmp-MM-Dir/
/share/
.*.d
!bin/
bin/*
Expand Down
24 changes: 9 additions & 15 deletions MMVII/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,30 @@ 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()


# Threads
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
#######################################################
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 558603e

Please sign in to comment.