diff --git a/CMakeLists.txt b/CMakeLists.txt index 774dce8de81..cee5158b395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22.1) +cmake_minimum_required(VERSION 3.25) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake @@ -117,6 +117,8 @@ if(CMAKE_CROSSCOMPILING AND ANDROID) endif() set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$") # https://cmake.org/cmake/help/latest/policy/CMP0168.html#policy:CMP0168 if(POLICY CMP0168) @@ -288,6 +290,11 @@ endif() cmake_dependent_option(QGC_BUILD_DEPENDENCIES "Force Building of Dependencies." OFF "NOT CMAKE_CROSSCOMPILING;NOT MACOS_UNIVERSAL_BUILD" ON) +include(CPM) +if(CMAKE_CROSSCOMPILING OR ANDROID OR MACOS_UNIVERSAL_BUILD) + set(CPM_DOWNLOAD_ALL ON CACHE BOOL "Download all Dependencies" FORCE) +endif() + ####################################################### # Custom Build Configuration ####################################################### diff --git a/cmake/find-modules/FindShapelib.cmake b/cmake/find-modules/FindShapelib.cmake index cb1341cab54..344374e2f35 100644 --- a/cmake/find-modules/FindShapelib.cmake +++ b/cmake/find-modules/FindShapelib.cmake @@ -59,9 +59,9 @@ mark_as_advanced(Shapelib_INCLUDE_DIR Shapelib_LIBRARY) if(Shapelib_FOUND) set(Shapelib_INCLUDE_DIRS "${Shapelib_INCLUDE_DIR}") set(Shapelib_LIBRARIES "${Shapelib_LIBRARY}") - if(NOT TARGET SHAPELIB::shp) - add_library(SHAPELIB::shp UNKNOWN IMPORTED) - set_target_properties(SHAPELIB::shp PROPERTIES + if(NOT TARGET shapelib::shp) + add_library(shapelib::shp UNKNOWN IMPORTED) + set_target_properties(shapelib::shp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Shapelib_INCLUDE_DIR}" IMPORTED_LINK_INTERFACE_LANGUAGES C IMPORTED_LOCATION "${Shapelib_LIBRARY}") diff --git a/src/AnalyzeView/CMakeLists.txt b/src/AnalyzeView/CMakeLists.txt index ca0f6d6e2db..c8f4d194366 100644 --- a/src/AnalyzeView/CMakeLists.txt +++ b/src/AnalyzeView/CMakeLists.txt @@ -102,12 +102,39 @@ endif() #===========================================================================# -include(CPM) +set(EXIV2_VERSION 0.28.3) + +if(NOT QGC_BUILD_DEPENDENCIES) + if(MSVC) + set(EXIV2_RELEASE_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-2019msvc64.zip") + elseif(LINUX) + set(EXIV2_RELEASE_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-Linux64.tar.gz") + elseif(MACOS) + set(EXIV2_RELEASE_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-Darwin.tar.gz") + endif() +endif() + +if(EXIV2_RELEASE_URL) + include(CPM) + CPMAddPackage( + NAME exiv2 + URL ${EXIV2_RELEASE_URL} + VERSION ${EXIV2_VERSION} + DOWNLOAD_ONLY + ) + + if(exiv2_ADDED) + target_include_directories(AnalyzeView PRIVATE ${exiv2_SOURCE_DIR}/include) + target_link_directories(AnalyzeView PUBLIC ${exiv2_SOURCE_DIR}/lib) + target_link_libraries(AnalyzeView PRIVATE exiv2) + return() + endif() +endif() # https://github.com/libexpat/libexpat/releases/download/R_2_6_4/expat-win32bin-2.6.4.zip CPMFindPackage( - NAME expat + NAME EXPAT VERSION 2.2.6 GITHUB_REPOSITORY libexpat/libexpat GIT_TAG "R_2_6_4" @@ -123,25 +150,16 @@ CPMFindPackage( "EXPAT_SHARED_LIBS OFF" ) -# if(MSVC) -# set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-2019msvc64.zip") -# elseif(LINUX) -# set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-Linux64.tar.gz") -# elseif(MACOS) -# set(EXIV2_URL "https://github.com/Exiv2/exiv2/releases/download/v${EXIV2_VERSION}/exiv2-${EXIV2_VERSION}-Darwin.tar.gz") -# endif() - if(TARGET EXPAT::EXPAT) set(_EXIV2_ENABLE_XMP ON) else() set(_EXIV2_ENABLE_XMP OFF) endif() -CPMAddPackage( +CPMFindPackage( NAME exiv2 - VERSION 0.28 + VERSION ${EXIV2_VERSION} GITHUB_REPOSITORY Exiv2/exiv2 - GIT_TAG v0.28.3 OPTIONS "EXIV2_ENABLE_XMP ${_EXIV2_ENABLE_XMP}" "EXIV2_ENABLE_EXTERNAL_XMP OFF" @@ -161,7 +179,7 @@ CPMAddPackage( "EXIV2_BUILD_UNIT_TESTS OFF" "EXIV2_BUILD_FUZZ_TESTS OFF" "EXIV2_BUILD_DOC OFF" - "BUILD_WITH_CCACHE ON" + "BUILD_WITH_CCACHE OFF" ) if(TARGET Exiv2::exiv2lib) diff --git a/src/Geo/CMakeLists.txt b/src/Geo/CMakeLists.txt index d69317eb727..54f13f58ca6 100644 --- a/src/Geo/CMakeLists.txt +++ b/src/Geo/CMakeLists.txt @@ -22,9 +22,17 @@ if(LINUX AND EXISTS "/usr/share/cmake/geographiclib") endif() include(CPM) -CPMAddPackage( +# CPMAddPackage( +# NAME geographiclib +# VERSION 2.5 +# URL https://sourceforge.net/projects/geographiclib/files/distrib-C%2B%2B/GeographicLib-2.5.tar.gz/download +# DOWNLOAD_ONLY +# SOURCE_SUBDIR src +# ) + +CPMFindPackage( NAME geographiclib - VERSION 2.3 + VERSION 2.5 GITHUB_REPOSITORY geographiclib/geographiclib GIT_TAG r2.5 OPTIONS @@ -43,6 +51,8 @@ CPMAddPackage( "PKGDIR OFF" "DOCDIR OFF" "EXAMPLEDIR OFF" + EXCLUDE_FROM_ALL + SYSTEM ) if(TARGET GeographicLib::GeographicLib) diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index 6dab435ac8a..d0c9e046fea 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -78,7 +78,7 @@ if(WIN32) endif() CPMFindPackage( - NAME sdl2 + NAME SDL2 VERSION 2.0.20 GITHUB_REPOSITORY libsdl-org/SDL GIT_TAG release-2.30.11 @@ -118,4 +118,6 @@ CPMFindPackage( if(TARGET SDL2::SDL2-static) target_link_libraries(Joystick PRIVATE SDL2::SDL2-static) +elseif(TARGET SDL2::SDL2) + target_link_libraries(Joystick PRIVATE SDL2::SDL2) endif() diff --git a/src/Utilities/CMakeLists.txt b/src/Utilities/CMakeLists.txt index 1ced593bbcf..ff278ea3ee6 100644 --- a/src/Utilities/CMakeLists.txt +++ b/src/Utilities/CMakeLists.txt @@ -63,15 +63,20 @@ endif() #===========================================================================# include(CPM) -CPMFindPackage( - NAME shapelib - VERSION 1.6.0 +CPMAddPackage( + NAME Shapelib + VERSION 1.6.1 GITHUB_REPOSITORY OSGeo/shapelib - GIT_TAG v1.6.1 OPTIONS "BUILD_SHAPELIB_CONTRIB OFF" "BUILD_APPS OFF" "BUILD_TESTING OFF" ) -target_link_libraries(Utilities PRIVATE shp) +if(Shapelib_ADDED) + if(TARGET shp) + target_link_libraries(Utilities PRIVATE shp) + elseif(TARGET shapelib::shp) + target_link_libraries(Utilities PRIVATE shapelib::shp) + endif() +endif() diff --git a/src/Utilities/Compression/CMakeLists.txt b/src/Utilities/Compression/CMakeLists.txt index 29456af7c2d..5358afbf6df 100644 --- a/src/Utilities/Compression/CMakeLists.txt +++ b/src/Utilities/Compression/CMakeLists.txt @@ -23,7 +23,7 @@ target_include_directories(Compression PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) include(CPM) CPMFindPackage( - NAME zlib + NAME ZLIB VERSION 1.3.1 GITHUB_REPOSITORY madler/zlib OPTIONS @@ -35,7 +35,12 @@ CPMFindPackage( "ZLIB_USE_STATIC_LIBS ON" ) -target_link_libraries(Compression PRIVATE zlibstatic) +if(ZLIB_ADDED) + target_link_libraries(Compression PRIVATE zlibstatic) +else() + find_package(Qt6ZlibPrivate REQUIRED) + target_link_libraries(Compression PRIVATE Qt6::ZlibPrivate) +endif() #===========================================================================#