Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
(conan-io#18298) itk: migrate to Conan v2
Browse files Browse the repository at this point in the history
* itk: migrate to Conan v2

* Delete CMakeLists.txt

* Remove hdf5 from test

* bump libtiff to 4.5.1

* Add empty EOL to test_package.cpp

* Replace CRLF with LF in test_package.cpp

* itksys: link with dl
  • Loading branch information
Nekto89 authored and ericLemanissier committed Sep 15, 2023
1 parent 784432a commit 4a36b16
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 287 deletions.
22 changes: 0 additions & 22 deletions recipes/itk/all/CMakeLists.txt

This file was deleted.

8 changes: 8 additions & 0 deletions recipes/itk/all/conan_cmake_project_include.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_package(double-conversion REQUIRED CONFIG)
find_package(Eigen3 REQUIRED CONFIG)
find_package(EXPAT REQUIRED MODULE)
find_package(JPEG REQUIRED CONFIG)
find_package(OpenJPEG REQUIRED CONFIG)
find_package(PNG REQUIRED)
find_package(TIFF REQUIRED)
find_package(ZLIB REQUIRED)
6 changes: 4 additions & 2 deletions recipes/itk/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ sources:
patches:
"5.1.2":
- patch_file: "patches/0001-find-conan-packages.patch"
base_path: "source_subfolder"
patch_description: "inject thirdparties from conan"
patch_type: "conan"
"5.1.0":
- patch_file: "patches/0001-find-conan-packages.patch"
base_path: "source_subfolder"
patch_description: "inject thirdparties from conan"
patch_type: "conan"
483 changes: 242 additions & 241 deletions recipes/itk/all/conanfile.py

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions recipes/itk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.15)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
project(test_package CXX)

find_package(ITK REQUIRED CONFIG)
find_package(HDF5 COMPONENTS CXX)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ITKCommon hdf5::hdf5_cpp)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PRIVATE ITKCommon)
#itksys is already linked through dependencies of ITKCommon but we also want to check name alias
target_link_libraries(${PROJECT_NAME} PRIVATE ITK::itksys)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
19 changes: 14 additions & 5 deletions recipes/itk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
14 changes: 4 additions & 10 deletions recipes/itk/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "itkLightObject.h"

#include <hdf5/hdf5.h>
#include <hdf5/H5Exception.h>

#include <iostream>

class Test : public itk::LightObject {
Expand All @@ -12,12 +9,9 @@ class Test : public itk::LightObject {
const char *GetNameOfClass() { return "Test"; }
};

int main(int, char **) try {
//Test::Pointer test = Test::New();
//std::cout << test->GetNameOfClass() << std::endl;
return 0;
} catch(const H5::DataSpaceIException &e) {
std::cerr << "CAUGHT\n";
e.printErrorStack();
int main(int, char **)
{
Test::Pointer test = Test::New();
std::cout << test->GetNameOfClass() << std::endl;
return 0;
}
8 changes: 8 additions & 0 deletions recipes/itk/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

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

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
18 changes: 18 additions & 0 deletions recipes/itk/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os


class TestPackageV1Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

0 comments on commit 4a36b16

Please sign in to comment.