Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: add compiler + remove compiler.version to reduce number of builds #1783

Merged
merged 10 commits into from
Jul 2, 2020
6 changes: 1 addition & 5 deletions recipes/cmake/3.x.x/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
else()
include(conanbuildinfo.cmake)
endif()
include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
13 changes: 9 additions & 4 deletions recipes/cmake/3.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from conans import tools, ConanFile, CMake
from conans.tools import Version
from conans.errors import ConanInvalidConfiguration, ConanException


Expand All @@ -13,7 +12,9 @@ class CMakeConan(ConanFile):
license = "BSD-3-Clause"
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "arch", "build_type"
settings = "os", "arch", "compiler", "build_type"

requires = "openssl/1.1.1g"
Copy link
Contributor

@robert-shade robert-shade May 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openssl isn't enabled by default on Windows, I think this requires needs to be os specific

Copy link
Contributor Author

@madebr madebr May 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.
I'll have to add the CMAKE_USE_OPENSSL option.


_source_subfolder = "source_subfolder"
_cmake = None
Expand All @@ -35,9 +36,9 @@ def _configure_cmake(self):
self._cmake = CMake(self)
self._cmake.definitions["CMAKE_BOOTSTRAP"] = False
if self.settings.os == "Linux":
self._cmake.definitions["OPENSSL_USE_STATIC_LIBS"] = True
self._cmake.definitions["OPENSSL_USE_STATIC_LIBS"] = not self.options["openssl"].shared
self._cmake.definitions["CMAKE_EXE_LINKER_FLAGS"] = "-lz"
madebr marked this conversation as resolved.
Show resolved Hide resolved
self._cmake.configure(source_dir=self._source_subfolder)
self._cmake.configure()
return self._cmake

def build(self):
Expand All @@ -54,6 +55,10 @@ def package(self):
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "doc"))

def package_id(self):
# CMake is a executable-only package, so the compiler version does not matter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It matters since a system might be missing the runtimes. It won't fix the related issue. CCI will build one MSVC package using the 2015 runtimes, but the target system is a 2017 so it won't be able to execute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building with 2015 is fine, it’ll work with the 2015 - 2019 runtimes.

https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2015-2017?view=vs-2019

Removing the compiler ver may not be a best practice, because if CCI is upgraded to build with 2017+ and the system only had the 2015 runtime, that wouldn’t work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point, however these recipes can be used to generate a package for 2013 locally, and the same scenario would cause trouble.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To what runtime do the official cmake windows builds link?
The only problem I see with removing version in package_id, is the loss of reproduceability as the ci can build cmake using whatever version of msvc it pleases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to only allow static runtime? Or should we just build all variants of cmake and don't bother with limiting anything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the official build uses the static runtime. This is the latest release:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to build static runtime for CMake (and built tools in general), this will avoid a dependency on Visual Studio CRT redist, which is not necessarily available (especially, if I am using alternate compiler).

del self.info.settings.compiler.version

def package_info(self):
minor = self._minor_version()

Expand Down