cmake-conan icon indicating copy to clipboard operation
cmake-conan copied to clipboard

CMake re-build dependency every time

Open patrykgorniak opened this issue 4 years ago • 3 comments
trafficstars

Hi,

I had to put glib/2.67.0 (cairo dependency) to build from source as there is libc incompatibility (pre-built glib requires libc 2.28 while I have only 2.27 on the system)

My conan part:

macro(run_conan)
  if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake" {CMAKE_BINARY_DIR}/conan.cmake")
  endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_add_remote(
  NAME
  bincrafters
  URL
  https://api.bintray.com/conan/bincrafters/public-conan)

conan_cmake_run(
  REQUIRES
  cairo/1.17.2
  glib/2.67.0
  BASIC_SETUP
  CMAKE_TARGETS
  BUILD
  glib/2.67.0
  missing
  )
endmacro()

So the problem is that each time I type cmake this glib library is recompiled from the scratch even if it was recompiled few seconds before. Is there a way to stop this recompilation every time?

Thanks for help

patrykgorniak avatar Jan 19 '21 13:01 patrykgorniak

Hi @patrykgorniak, glib is building everytime because you are adding glib/2.67.0 to the BUILD argument in the conan_cmake_run call. If you just want to build what is missing do the call like this, removing the glib/2.67.0 after BUILD and leave just the missing parameter:

conan_cmake_run(
  REQUIRES
  cairo/1.17.2
  glib/2.67.0
  BASIC_SETUP
  CMAKE_TARGETS
  BUILD
  missing
  )

Hope this helps.

czoido avatar Jan 20 '21 05:01 czoido

Hi,

Unfortunately this did not help. After I used that cmd:

  conan_cmake_run(
    REQUIRES
    cairo/1.17.2
    BASIC_SETUP
    CMAKE_TARGETS
    BUILD
    missing
    ) 

All dependecies for Cairo were downloaded as pre-build, not build from the scratch. I attached conan.log produced by following cmd:

 /usr/local/bin/conan install . -s build_type=Release -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing

From my perspective I need to build only glib (cairo dependency) from sources. Any ideas? Thanks for help.

patrykgorniak avatar Jan 20 '21 09:01 patrykgorniak

Hi @patrykgorniak,

Are you running always from an empty cache? If that's the case you should create glib/2.67.0 for your configuration before the cmake call so that when you require cairo it builds against the local one and does not try to download from conan-center. Maybe doing something like:

conan install glib/2.67.0@ -r conan-center (add your settings and options or profile) --build

You could also add some logic to the CMakeLists to check if you have the package and adding it to the BUILD argument otherwise. Also, you could also upload to your own server (like Artifactory cpp) and taking the precompiled version from there. The problem is that conan checks the cache, does not find the binary and then tries to download it from conan-center.

Please tell me if this helps.

czoido avatar Jan 20 '21 10:01 czoido