Skip to content

Commit

Permalink
Removed Conan1 build.py file using conan package tools that are no lo…
Browse files Browse the repository at this point in the history
…nger supported
  • Loading branch information
LinuxDevon committed Jan 31, 2024
1 parent 1078e7e commit a606d1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 108 deletions.
94 changes: 0 additions & 94 deletions .conan/build.py

This file was deleted.

46 changes: 32 additions & 14 deletions conanfile.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python
from conans import ConanFile, CMake, tools
from conan import ConanFile, tools
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout
from conan.tools import files


class CatchConan(ConanFile):
name = "catch2"
Expand All @@ -14,30 +17,45 @@ class CatchConan(ConanFile):

settings = "os", "compiler", "build_type", "arch"

generators = "cmake"
def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BUILD_TESTING"] = "OFF"
cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF"
cmake.definitions["CATCH_INSTALL_EXTRAS"] = "ON"
cmake.configure(build_folder="build")

# These are option variables. The toolchain in conan 2 doesn't appear to
# set these correctly so you have to do it in the configure variables.
cmake.configure(variables= {
"BUILD_TESTING": "OFF",
"CATCH_INSTALL_DOCS": "OFF",
"CATCH_INSTALL_EXTRAS": "ON",
}
)
return cmake


def build(self):
# We need this workaround until the toolchains feature
# to inject stuff like MD/MT
line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")'
tools.replace_in_file("CMakeLists.txt", line_to_replace,
'''{}
include("{}/conanbuildinfo.cmake")
conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/")))
# # We need this workaround until the toolchains feature
# # to inject stuff like MD/MT
# line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")'
# replacement_text = '''{}
# include("{}/conanbuildinfo.cmake")
# conan_basic_setup()'''.format(line_to_replace, self.package_folder.replace("\\", "/"))

# files.replace_in_file(self, f"{self.source_folder}/CMakeLists.txt", line_to_replace, replacement_text)

cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="LICENSE.txt", dst="licenses")
files.copy(self, pattern="LICENSE.txt", src='.', dst="licenses")
cmake = self._configure_cmake()
cmake.install()

Expand Down

0 comments on commit a606d1d

Please sign in to comment.