1

So basically I have the following setup:

A small test library called mylib with an according CMake file. The CMake file creates all the necessary information so that another project (which is going to be my binary) can use find_package to add the library. The library also has a install target.

A small binary called mybin again wih according CMake file which is depended on the mylib project. Using find_package I can add mylib either by specifying the location of the according myLibConfig.cmake (and myLibTargets.cmake etc.) files or by executing the install target of mylib and then letting CMake find the library itself.

Using CMake and XCode everything works like a charm. First, I configure and build the library. Second, I configure my binary project, specify the location of the library and then build it without any problems.

Now I want to do the same using CLion. My problem now is that CLion puts all the generated CMake file (which usually are placed in the build folder) in some cryptic location which can't be changed in the IDE. Now, when I want to build the mybin project I have to specify this cryptic location which seems kinda odd to me (especially because you have to find out first where CLion actually places those files).

So my question is: Is there a more convenient way to handle the described configuration? I guess this is more or less the standard use case which makes me wonder if I'm missing out on something. Being able to specify where CLion should put the generated CMake files would solve my problem I guess.

I know that i can install the library (using the install target) and then let CMake find it. The problem here is that CLion (to my understanding) doesn't support install targets and therefore I have to use (in my case) XCode to build and install the library first.

  • Is "mylib" supposed to be used independently of "mybin", or should they always be paired? – Some programmer dude Feb 29 '16 at 07:33
  • Yes, it is supposed to be used independently. The real issue is the location where CLion places the files. I was thinking about setting the `CMAKE_CACHEFILE_DIR` from script but I'm not sure whether this is a good idea or not. At least it doesn't seem like the way to go. – Philipp Grasmug Feb 29 '16 at 08:03
  • 1
    `find_package` is intended to be used with **installed** libraries. `The problem here is that CLion (to my understanding) doesn't support install targets` - it can be easily overcomed, see e.g. [this question](http://stackoverflow.com/questions/33788729/how-do-i-get-clion-to-run-an-install-target). – Tsyvarev Feb 29 '16 at 08:23
  • Thanks for your reply. That's the solution I'm using right now. Seems like I misunderstood the intention of `find_package`. – Philipp Grasmug Feb 29 '16 at 08:36

1 Answers1

0

I was misunderstsanding the intention of find_package(as Tsyvarev pointed out). By using the solution proposed in this question I managed to add an install target to CLion which now allows me to conveniently build "mylib" and use it in the "mybin" project without having to configure anything manually.

Community
  • 1
  • 1