Skip to content

Commit

Permalink
Upgrade to Conan 2.0 (5)
Browse files Browse the repository at this point in the history
  • Loading branch information
arBmind committed Jun 2, 2024
1 parent d203f74 commit 00466f3
Show file tree
Hide file tree
Showing 37 changed files with 65 additions and 92 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ jobs:

- name: Create conan package
run: |
cd conan
conan create . --build=missing --profile profiles/msvc2022
conan create conan/ --build=missing --profile:all=./conan/profiles/msvc2022
- name: Test package components
shell: pwsh
run: |
foreach ($folder in (Get-ChildItem -Path ./conan/tests -Directory | Foreach-Object {$_.Name})) {
echo "Running ${folder}"
& script\test_conan.bat "${folder}" --profile "$pwd/conan/profiles/msvc2022"
& script\test_conan.bat "${folder}" --profile:all="$pwd/conan/profiles/msvc2022"
if ($LASTEXITCODE -ne 0) {
exit(1)
}
Expand Down
30 changes: 16 additions & 14 deletions conan/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from conans import ConanFile
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, replace_in_file, rm, rmdir
from conans import tools
from conan.tools.files import copy, rmdir
from conan.tools.build import check_min_cppstd

import os

Expand All @@ -24,27 +24,28 @@ class Cocpp19Conan(ConanFile):
"shared": False,
"fPIC": True
}
requires = [("gtest/1.11.0", "private")]
test_requires = "gtest/1.11.0"
generators = "CMakeDeps"

def layout(self):
self.folders.root = ".."
cmake_layout(self)

def export_sources(self):
self.copy("CMakeLists.txt", src="..")
self.copy("CoCpp19Config.cmake.in", src="..")
self.copy("LICENSE", src="..")
self.copy("src/*", src="..", excludes="*.qbs")
self.copy("third_party/CMakeLists.txt", src="..")
self.copy("third_party/googletest.cmake", src="..")
folder = os.path.join(self.recipe_folder, "..")
copy(self, "CMakeLists.txt", folder, self.export_sources_folder)
copy(self, "CoCpp19Config.cmake.in", folder, self.export_sources_folder)
copy(self, "LICENSE", folder, self.export_sources_folder)
copy(self, "src/*", folder, self.export_sources_folder, excludes="*.qbs")
copy(self, "third_party/CMakeLists.txt", folder, self.export_sources_folder)
copy(self, "third_party/googletest.cmake", folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def validate(self):
tools.check_min_cppstd(self, "20")
check_min_cppstd(self, "20")

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -56,7 +57,7 @@ def build(self):
cmake.build()

def package(self):
self.copy("LICENSE")
copy(self, "LICENSE", self.source_folder, self.package_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
Expand All @@ -65,6 +66,7 @@ def package(self):
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_file_name", "CoCpp19")
self.cpp_info.set_property("cmake_target_name", "CoCpp19")

components = [
{"name": "array19"},
Expand All @@ -90,8 +92,8 @@ def package_info(self):
if "libs" in comp:
self.cpp_info.components[name].libs = comp["libs"]

self.cpp_info.names["cmake_find_package"] = "CoCpp19"
self.cpp_info.names["cmake_find_package_multi"] = "CoCpp19"
# self.cpp_info.names["cmake_find_package"] = "CoCpp19"
# self.cpp_info.names["cmake_find_package_multi"] = "CoCpp19"

def test(self):
cmake = CMake(self)
Expand Down
2 changes: 0 additions & 2 deletions conan/profiles/clang15-libcxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.libcxx=libc++
compiler.version=15
Expand Down
2 changes: 0 additions & 2 deletions conan/profiles/clang15-libstdcpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=15
Expand Down
11 changes: 11 additions & 0 deletions conan/profiles/clang18-libstdcpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[settings]
os=Linux
arch=x86_64
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=18
compiler.cppstd=20
build_type=Release

[options]
*:shared=False
2 changes: 0 additions & 2 deletions conan/profiles/gcc12
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=12
Expand Down
11 changes: 6 additions & 5 deletions conan/profiles/msvc2022
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=17
compiler=msvc
compiler.version=194
compiler.cppstd=20
compiler.runtime=MD
compiler.runtime=dynamic
build_type=Release

[options]
*:shared=False

[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
3 changes: 0 additions & 3 deletions conan/tests/array19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(conan-array19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS array19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/array19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/coro19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(conan-coro19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS coro19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/coro19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/enum19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-enum19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS enum19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/enum19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/lookup19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-lookup19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS lookup19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/lookup19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/meta19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-meta19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS meta19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/meta19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/optional19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-optional19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS optional19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/optional19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/partial19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-partial19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS partial19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/partial19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/serialize19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-serialize19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS serialize19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/serialize19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/signal19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-signal19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS signal19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/signal19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/string19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-string19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS string19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/string19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/strong19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-strong19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS strong19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/strong19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/tuple19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-tuple19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS tuple19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/tuple19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
3 changes: 0 additions & 3 deletions conan/tests/variant19/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ cmake_minimum_required(VERSION 3.15)
project(cocpp19-variant19)
set(CMAKE_CXX_STANDARD 20)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
find_package(GTest REQUIRED)
find_package(CoCpp19 COMPONENTS variant19 REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion conan/tests/variant19/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ co-cpp19/1.0
gtest/1.11.0

[generators]
cmake
CMakeDeps
CMakeToolchain
2 changes: 1 addition & 1 deletion script/ci/conan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ script/create_conan.sh "${ConanProfile}"

for test in conan/tests/*/
do
script/test_conan.sh "$(basename "${test}")" --profile "${BASE_DIR}/conan/profiles/${ConanProfile}"
script/test_conan.sh "$(basename "${test}")" --profile:all="${BASE_DIR}/conan/profiles/${ConanProfile}"
done
3 changes: 1 addition & 2 deletions script/create_conan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ shift
cd "$(dirname "${BASH_SOURCE[0]}")/.."
BASE_DIR="$(pwd)"

cd conan
conan create . --build=missing --profile "conan/profiles/${ConanProfile}"
conan create conan --build=missing --profile:all="./conan/profiles/${ConanProfile}"
Loading

0 comments on commit 00466f3

Please sign in to comment.