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

CMAKE find_package() error #1593

Closed
Sky-Ero opened this issue Jun 13, 2019 · 8 comments
Closed

CMAKE find_package() error #1593

Sky-Ero opened this issue Jun 13, 2019 · 8 comments

Comments

@Sky-Ero
Copy link

Sky-Ero commented Jun 13, 2019

I have cmake error while trying link SFML:

cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME mol)
project(${PROJECT_NAME})

set(CMAKE_CXX_STANDARD 17)
set(SFML_DIR "lib/SFML-2.5/lib/cmake/SFML")

find_package(SFML 2.5 COMPONENTS graphics audio system main REQUIRED)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} sfml-graphics sfml-audio sfml-system sfml-main)

Error look like this:

  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2.5".

  The following configuration files were considered but not accepted:

    H:/projects/mol/lib/SFML-2.5/lib/cmake/SFML/SFMLConfig.cmake, version: 2.5.1 (32bit)

How I can fix it?

@1aam2am1
Copy link
Contributor

Sfml is statically linked or shared?
I don't remember but you have static version but try finding shared or vice versa.

@Bromeon
Copy link
Member

Bromeon commented Jun 16, 2019

A user of Thor reported the same issue -- I'm using the same find_package() call.

From the CMake documentation (emphasis mine):

When the [version] argument is given, Config mode will only find a version of the package that claims compatibility with the requested version (format is major[.minor[.patch[.tweak]]]). If the EXACT option is given only a version of the package claiming an exact match of the requested version may be found. CMake does not establish any convention for the meaning of version numbers. Package version numbers are checked by “version” files provided by the packages themselves. For a candidate package configuration file .cmake the corresponding version file is located next to it and named either -version.cmake or Version.cmake. If no such version file is available then the configuration file is assumed to not be compatible with any requested version.

Since SFML does not provide this version file, versions not matching exactly (e.g. 2.5 and 2.5.1) are by default incompatible. Pretty confusing if you ask me, but in line with CMake's philosophy of requiring extra boilerplate for basic features.

As I see it, the options are either to provide this version file, or to document a recommended way of how to invoke find_package() when using SFML.

@Sky-Ero
Copy link
Author

Sky-Ero commented Jun 16, 2019

@Bromeon I tried other versions (2, 2.5, 2.5.1), but none of the options fit.
@1aam2am1 shared

@eXpl0it3r
Copy link
Member

Mismatch between x86 and x64?

@Sky-Ero
Copy link
Author

Sky-Ero commented Jun 18, 2019

@eXpl0it3r How can I check this?

@eXpl0it3r
Copy link
Member

Check what version of SFML you downloaded or built and make sure that you pick the matching CMake generator.

@Sky-Ero
Copy link
Author

Sky-Ero commented Jun 26, 2019

@eXpl0it3r
You were right. I used the wrong compiler in this project. Thank you!

@eXpl0it3r
Copy link
Member

Glad to hear that you figured it out. So far I've only seen this issue with architecture mismatches, so I'll close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants