[PROJ] cmake find_package() fails to find PROJ6 installed with MacPorts
Tom O'Reilly
oreilly at mbari.org
Wed Jun 1 16:02:39 PDT 2022
Hi Mike et al,
I've installed proj6, proj8, and proj9 with MacPorts, into directories /opt/local/lib/proj6, /opt/local/lib/proj8, and /opt/local/lib/proj9.
I wrote a minimal CMakeLists.txt file to test find_package(PROJ), and verify that;
find_package(PROJ CONFIG) works for proj9, but not for proj8 or proj6.
So this is more-or-less consistent with what you guys say - thank you!
Here's the CMakeLists.txt:
#[[
Test capability of find_package(PROJ) to find various
MacPort-installed proj versions
]]
cmake_minimum_required(VERSION 3.18)
project(cmake-test)
if (APPLE)
# Assume MacPorts default install location in /opt/local
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
# Must set PROJ_ROOT to point at directory containing proj-versionX
# so that find_package() works
# MacPorts puts projX files in /opt/local/lib/projX
set(PROJ_ROOT /opt/local/lib)
endif(APPLE)
message("find_package(PROJ)")
find_package(PROJ CONFIG REQUIRED)
message("done with find_package(PROJ)")
message("PROJ_LIBRARIES: ${PROJ_LIBRARIES}, PROJ_VERSION: ${PROJ_VERSION}")
message("DONE")
The proj*config.cmake file needed to support find_package(PROJ CONFIG) are only found under proj9:
find /opt/local/lib -iname 'proj*config.cmake'
/opt/local/lib/proj9/lib/cmake/proj4/proj4-config.cmake
/opt/local/lib/proj9/lib/cmake/proj/proj-config.cmake
Thanks!
Tom
--------------------------------------------------
Thomas C. O'Reilly
Monterey Bay Aquarium Research Institute
7700 Sandholdt Road
Moss Landing, California 95039-9644
831-775-1766 (voice)
831-775-1620 (FAX)
oreilly at mbari.org (email)
http://www.mbari.org (World-wide Web)
"The machine does not isolate us from the great mysteries
of nature, but plunges us more deeply into them."
- ANTOINE DE SAINT-EXUPERY
"Wind, Sand, and Stars" (1939)
----- Original Message -----
From: "Mike Taves" <mwtoews at gmail.com>
To: "Tom O'Reilly" <oreilly at mbari.org>
Cc: "Even Rouault" <even.rouault at spatialys.com>, "proj" <proj at lists.osgeo.org>
Sent: Wednesday, June 1, 2022 2:34:41 PM
Subject: Re: [PROJ] cmake find_package() fails to find PROJ6 installed with MacPorts
On Thu, 2 Jun 2022 at 07:55, Tom O'Reilly <oreilly at mbari.org> wrote:
>
> My project needs proj6, but as a test of cmake I installed proj9 with MacPorts - and find_package(Proj9 CONFIG REQUIRED) fails just as before.
> Question - if the installed proj9 provides CONFIG support, I presume there is a proj9-config.cmake or Proj9Config.cmake file somewhere. Where would I look for this file? I see /opt/local/lib/proj9 - but the file is not in there. Would this file be in there if proj9 supports CONFIG mode or is there some other place to look?
Use the following:
find_package(PROJ CONFIG REQUIRED)
target_link_libraries(MyApp PRIVATE PROJ::proj)
See https://proj.org/development/cmake.html for more
More information about the PROJ
mailing list