conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
823 stars 250 forks source link

CMake re-build dependency every time #306

Open patrykgorniak opened 3 years ago

patrykgorniak commented 3 years ago

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

czoido commented 3 years ago

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.

patrykgorniak commented 3 years ago

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.

czoido commented 3 years ago

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.