Basic CLion Project


#1

I’m trying to build a basic project using CLion on OSX using the latest version of the master branch from github. I made some minor modifications to the example in the cinder cmake documentation:

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set( CMAKE_VERBOSE_MAKEFILE ON )

project(test)

set(CMAKE_CXX_STANDARD 11)

get_filename_component( CINDER_PATH "~/Repositories/Cinder" ABSOLUTE )
get_filename_component( APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE )

include( ${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake )

ci_make_app(
        CINDER_PATH ${CINDER_PATH}
        SOURCES     ${APP_PATH}/src/main.cpp
        INCLUDES    ${APP_PATH}/include
)

This setup however generates the following error:

CMake Error at /Users/ghirigoro/Repositories/Cinder/proj/cmake/modules/cinderMakeApp.cmake:65 (find_package):
  Could not find a package configuration file provided by "cinder" with any
  of the following names:

    cinderConfig.cmake
    cinder-config.cmake

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

It looks like it’s able to find the CINDER_PATH so I don’t think that’s the problem, but since that’s the main thing I changed (and CMake is still utterly opaque to me) I’m not sure where I went astray. If anyone has any suggestions they’d be much appreciated.


#2

I built cinder using CLion (previously I had built it with the xcode fullbuild.sh script) and it seems to work now. Just in case some other CLion user runs into this issue try that first.


#3

Does this mean that it’s not possible to use clion and xcode (or visual studio) on the same project if pointing at the same cinder build? I’m about to start a new project (today!) and am hoping to properly trial clion on it but don’t want to subject the rest of the team to it just yet!

Do you know if your cmake build will work with an xcode sample?


#4

Just a quick note that I pulled the latest master today and built with xcode. I then opened up the basic sample with clion and was able to compile the app without rebuilding cinder with cmake. Not sure if it’ll get trickier with a more involved project but so far so good.


#5

I don’t know enough about the differences between xcode and cmake builds of cinder (or if I’m even right about building with CMake) but I would guess it’s not an issue to have people working on a project with different IDEs. The source code and folder structure would be shared, but everything else (e.g. .xcproj and cmakelists.txt files) would be specific to a particular user’s tools. Basically, if I’m using Xcode I have no reason to interact with the CMake specific files, and vice versa.


#6

Hi Nay,

although personally I haven’t used CLion I know that it has been working nicely so far with our current CMake configuration for both building Cinder and applications that link with Cinder. @rich.e would definitely have more to say about this.

That said there were efforts put to be able to share build products from the different toolsets that Cinder supports but I think we mostly aimed and tested the cases where you build Cinder with CMake and then use Xcode or VS to build a sample for example.

The other way around ( i.e building Cinder with Xcode and trying to build then a sample with CMake ) like the case you tested, should not actually work if you haven’t build at least once Cinder with CMake. In that case you should get the error that @Ghirigoro got. This is because for linking an app with Cinder through CMake we rely on an exported configuration file that gets generated only when building Cinder through CMake currently. My guess is that this worked for you because you didn’t try it on a fresh clone of Cinder but rather on an existing clone that you had probably used CMake in the past to build Cinder with ???

I guess we could also try to figure out a way to support this use case by having a fallback CMake configuration file ( that is always present ) that checks if a build product exists already in the case that the above mentioned CMake exported configuration file is not present but this would need a bit more thinking.

Hope this clarifies things a bit…

Cheers,
Petros


#7

Thanks Petros,

That is strange! I guess there’s a chance I built cinder with the android_linux branch on OSX a while back but I don’t think I did this since it was merged into master as I only pulled those changes today.

I don’t mind building with CMake first, as long as I can then switch between different IDEs on the one machine without needing to rebuild.

I’m happy to finally be getting my head around how cinder deals with cmake and I like the strategy for dealing with blocks - super excited to finally have a cross platform build solution!

Cheers,
nay.


#8

I’m not aware of any issues when using both cmake / clion and xcode on Mac. There shouldn’t be, anyway, and if you find an issue hopefully we can find a fix for it. I think there was some work done a while ago to make the samples play nicely when built from Xcode, yet libcinder is build from cmake (or cmake-generated xcode), but I haven’t tested these paths myself.