Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link PROJ to CMAKE #4122

Closed
monkeybuttlipstick opened this issue Apr 19, 2024 · 3 comments
Closed

Link PROJ to CMAKE #4122

monkeybuttlipstick opened this issue Apr 19, 2024 · 3 comments

Comments

@monkeybuttlipstick
Copy link

Hii, I'm a new learner to C++ and I'm struggling with linking proj lib to cmake.
I used : sudo apt-get install libproj-dev to download proj, and I tried to link to proj as https://proj.org/en/9.4/development/cmake.html suggested:
`cmake_minimum_required(VERSION 3.28)
project(transform_crs)

set(CMAKE_CXX_STANDARD 17)

find_package(PROJ REQUIRED CONFIG)

add_executable(transform_crs main.cpp)

target_link_libraries(transform_crs PRIVATE PROJ::proj)`

And it gives error:` Could not find a package configuration file provided by "PROJ" with any of
the following names:

PROJConfig.cmake
proj-config.cmake

Add the installation prefix of "PROJ" to CMAKE_PREFIX_PATH or set
"PROJ_DIR" to a directory containing one of the above files. If "PROJ"
provides a separate development package or SDK, be sure it has been
installed.`

I wonder what's the correct way to link PROJ in cmakelist then? Thank you so much for your time and help and sry this is a very basic problem. ^O^, there's not much info online about this, I'd be really appreciated you can help me with it.

@rouault
Copy link
Member

rouault commented Apr 19, 2024

which Linux distribution and PROJ version do you use ? PROJ Cmake config files are only available in recent enough PROJ version

@monkeybuttlipstick
Copy link
Author

@rouault Hiii, the info as follows:
Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04
PROJ: (8.2.1-1).

@rouault
Copy link
Member

rouault commented Apr 23, 2024

ok, the issue is that Ubuntu 22.04 has built PROJ using autotools and not CMake, so the CMake config files aren't available in that distribution. You will need to use a FindPROJ.cmake module in your project, like https://github.com/OSGeo/gdal/blob/master/cmake/modules/packages/FindPROJ.cmake

@rouault rouault closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants