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 config is broken. #231

Closed
FrankXie05 opened this issue Apr 21, 2023 · 4 comments · Fixed by #234
Closed

Cmake config is broken. #231

FrankXie05 opened this issue Apr 21, 2023 · 4 comments · Fixed by #234

Comments

@FrankXie05
Copy link

Hi, I'm one of the maintainers of vcpkg, and we recently received a question about libconfg using cmake.
Issue:
There seems to be this problem with the exported cmake usage after we installed libconfig, it fails to link against libconfig++.
Run command ./vcpkg install libconfig:x64-windows --head and output:

libconfig provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(libconfig CONFIG REQUIRED)
    target_link_libraries(main PRIVATE libconfig::libconfig libconfig::libconfig++)

For this reason, I made a patch to separate libconfig and libconfig++.

However, from the code structure, libconfig does not seem to be separated, but is linked to libconfig++.
BUt, it was broken.

foreach(target_name libconfig libconfig++)

NAMESPACE libconfig::

Reproduce steps:
CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
project(test)
add_executable(main main.cpp)
find_package(libconfig CONFIG REQUIRED)
target_link_libraries(main PRIVATE libconfig::libconfig libconfig::libconfig++)

Error:

CMake Error at CMakeLists.txt:5 (target_link_libraries):
  Target "main" links to:

    libconfig::libconfig++

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Related vcpkg issue and PR:
microsoft/vcpkg#30906
microsoft/vcpkg#30980

@hyperrealm

@dg0yt
Copy link
Contributor

dg0yt commented Apr 25, 2023

This question drags in a lot of vcpkg particularities. More general (microsoft/vcpkg#30980 (comment)), please solve this problem and inconsistency:

Target libconfig++ is in namespace and directory libconfig but in config libconfig++.
This makes the target unreachable.

  • find_package(libconfig++) doesn't work.
  • find_package(libconfig) doesn't provide the target.

Consistent patterns would be:

  • Target libconfig++ is in namespace, config and directory libconfig.
  • Target libconfig++ is in namespace, config and directory libconfig++.

I would recommend the first alternative, in particular because they are connected.

@mllusar
Copy link

mllusar commented Oct 4, 2023

Hey ! Is there any new about this issue ? I really need to use libonfig++ under Cmake with vcpkg.

I'm not an advanced programmer, but it seams that all we need need is to rename the namespace.

@FrankXie05
Copy link
Author

@mllusar You can use my PR temporarily microsoft/vcpkg#30980

@dg0yt
Copy link
Contributor

dg0yt commented Oct 21, 2023

  • Target libconfig++ is in namespace, config and directory libconfig.

Implemented in #234.

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

Successfully merging a pull request may close this issue.

3 participants