cpm icon indicating copy to clipboard operation
cpm copied to clipboard

How to use external packages on cpm.rocks?

Open shuaimu opened this issue 8 years ago • 1 comments

I tried for a couple of hours and did not find a solution.

For example, this package: yaml-cpp is on the website: http://www.cpm.rocks/mod/gh/jbeder/yaml-cpp

In my CMakelist.txt:

CPM_AddModule("yaml-cpp"
        GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp"
        GIT_TAG "origin/master"
        USE_EXISTING_VER TRUE
        )

Running cmake will alert me:

A module (yaml-cpp) failed to define its name!

Same goes with many other packages on the website. I found that it seems only that is a wrapper instead of the actual code repo would work. For example, the "cpm-boost" works.

shuaimu avatar Mar 08 '17 02:03 shuaimu

I think the core issue is that CPM doesn't recognize the external CMake project as a valid CPM module. As in CPM_InitModule("yaml-cpp") was never issued from the project at https://github.com/jbeder/yaml-cpp. If memory serves, externals were created in order to wrap non-CMake projects. The expectation being that CMake projects themselves could just add the CPM machinery. However, I don't believe that external CMake projects should add the CPM machinery, they should be wrapped at a higher level in CPM.

I agree that this behavior should be modified so that one could specify a true 'external-to-CPM' in addition to a 'CPM-External' that simply knows how to build the project. Unfortunately my head has been out of CMake script for over 2 years now and don't have the context to drive these changes forward. What may suit your use case is a CMake ExternalProject but those aren't supported on the website (not without a CPM_AddModuleExternal or some other modification to the CPM source).

I'll leave the issue open and post a maintenance warning on the github page.

iauns avatar Mar 12 '17 01:03 iauns