Commit bf3c2ff1 authored by Edwin Carlinet's avatar Edwin Carlinet

Merge branch 'development/buidsystem' into 'master'

Improve conan buildsystem

See merge request !100
parents 03d2059f 826a1a7d
Pipeline #20281 passed with stages
in 23 minutes and 22 seconds
......@@ -20,11 +20,8 @@ if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake")
endif ()
find_package(Boost 1.58 COMPONENTS program_options REQUIRED)
find_package(FreeImage REQUIRED)
find_package(TBB)
find_package(Qt4)
find_package(FreeImage REQUIRED)
# CONFIGURE COMPILER LAUNCHERS
......@@ -81,7 +78,7 @@ if (MSVC)
"/wd4457" # la déclaration de '?' masque le paramètre de fonction
"/wd4996" # '...': was declared deprecated
)
add_compile_options("/WX" "/W3" "/wd4244" "/wd4127" "/permissive-")
add_compile_options("/WX" "/W3" "/wd4244" "/wd4127")
add_compile_definitions(_SCL_SECURE_NO_WARNINGS)
add_compile_definitions(_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
add_compile_definitions(_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
......
......@@ -48,14 +48,13 @@ conan remote add lrde-public https://artifactory.lrde.epita.fr/artifactory/api/c
1. Install the library with Conan:
```
conan install pylene/head@lrde/stable -g cmake_paths -g cmake_find_package
conan install pylene/head@lrde/stable -g cmake_find_package
```
2. Edit your ``CMakeLists.txt`` to include the paths to the library:
```
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
find_package(Pylene CONFIG)
find_package(Pylene)
```
3. Links with target ``Pylene::Pylene``:
......
......@@ -4,7 +4,9 @@
#include <mln/core/range/rows.hpp>
#include <mln/core/range/view/zip.hpp>
#ifdef _MSC_VER
# define __restrict__ __restrict
#endif
void Mult_Inplace_New_Values(mln::image2d<uint8_t>& img)
......
......@@ -4,9 +4,10 @@
#include <mln/core/range/view/reverse.hpp>
#include <mln/core/range/view/zip.hpp>
#include <vector>
#ifdef _MSC_VER
# define __restrict__ __restrict
#endif
void Mult_Inplace_New_Values_Reversed(mln::image2d<uint8_t>& img)
{
......
......@@ -7,14 +7,17 @@
#include <benchmark/benchmark.h>
#ifdef _MSC_VER
# define __restrict__ __restrict
#endif
void Mult_Inplace_C(uint8_t* buffer, int width, int height, std::ptrdiff_t stride);
void Threshold_Inplace_C(uint8_t* buffer, int width, int height, std::ptrdiff_t stride);
void LUT_Inplace_C(const uint8_t* LUT, uint8_t* buffer, int width, int height, std::ptrdiff_t stride);
void Mult_C(const uint8_t* ibuffer, uint8_t* obuffer, int width, int height, std::ptrdiff_t stride);
void Threshold_C(const uint8_t* ibuffer, uint8_t* obuffer, int width, int height, std::ptrdiff_t stride);
void LUT_C(const uint8_t* LUT, const uint8_t* ibuffer, uint8_t* obuffer, int width, int height,
void Mult_C(const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height, std::ptrdiff_t stride);
void Threshold_C(const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height, std::ptrdiff_t stride);
void LUT_C(const uint8_t* LUT, const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height,
std::ptrdiff_t stride);
void Mult_New_Values(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
......@@ -23,8 +26,8 @@ void Mult_New_Pixels(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>&
void Threshold_New_Values(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void Threshold_New_Pixels(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void LUT_New_Values(const uint8_t* LUT, const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void LUT_New_Pixels(const uint8_t* LUT, const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void LUT_New_Values(const uint8_t LUT[], const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void LUT_New_Pixels(const uint8_t LUT[], const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void Mult_Inplace_New_Values(mln::image2d<uint8_t>& img);
void Threshold_Inplace_New_Values(mln::image2d<uint8_t>& img);
......@@ -43,9 +46,9 @@ void Threshold_Inplace_C_Reversed(uint8_t* buffer, int width, int height, std::p
void LUT_Inplace_C_Reversed(const uint8_t* LUT, uint8_t* buffer, int width, int height, std::ptrdiff_t stride);
void Mult_C_Reversed(const uint8_t* ibuffer, uint8_t* obuffer, int width, int height, std::ptrdiff_t stride);
void Threshold_C_Reversed(const uint8_t* ibuffer, uint8_t* obuffer, int width, int height, std::ptrdiff_t stride);
void LUT_C_Reversed(const uint8_t* LUT, const uint8_t* ibuffer, uint8_t* obuffer, int width, int height,
void Mult_C_Reversed(const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height, std::ptrdiff_t stride);
void Threshold_C_Reversed(const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height, std::ptrdiff_t stride);
void LUT_C_Reversed(const uint8_t* LUT, const uint8_t* __restrict__ ibuffer, uint8_t* __restrict__ obuffer, int width, int height,
std::ptrdiff_t stride);
void Mult_New_Values_Reversed(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
......@@ -54,9 +57,9 @@ void Mult_New_Pixels_Reversed(const mln::image2d<uint8_t>& input, mln::image2d<u
void Threshold_New_Values_Reversed(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void Threshold_New_Pixels_Reversed(const mln::image2d<uint8_t>& input, mln::image2d<uint8_t>& output);
void LUT_New_Values_Reversed(const uint8_t* LUT, const mln::image2d<uint8_t>& input,
void LUT_New_Values_Reversed(const uint8_t LUT[], const mln::image2d<uint8_t>& input,
mln::image2d<uint8_t>& output);
void LUT_New_Pixels_Reversed(const uint8_t* LUT, const mln::image2d<uint8_t>& input,
void LUT_New_Pixels_Reversed(const uint8_t LUT[], const mln::image2d<uint8_t>& input,
mln::image2d<uint8_t>& output);
void Mult_Inplace_New_Values_Reversed(mln::image2d<uint8_t>& img);
......
from conans import CMake, ConanFile, tools
import os
class Pylene(ConanFile):
name = "pylene"
version = "head"
license = "https://gitlab.lrde.epita.fr/olena/pylene/blob/dev/LICENSE"
license = "MPL v2"
url = "https://gitlab.lrde.epita.fr/olena/pylene"
description = "C++ Generic Image Processing Library."
settings = "os", "compiler", "arch", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"freeimage": [True, False],
"boost": [True, False]}
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": False,
"freeimage": False,
"boost": False,
"gtest:shared": False
"shared": False,
"fPIC": False,
"gtest:shared": False,
"boost:shared": True
}
generators = [ "cmake", "cmake_paths", "cmake_find_package" ]
exports_sources = ["pylene/*", "cmake/*", "CMakeLists.txt", "LICENSE"]
build_requires = [
"gtest/[>=1.10]",
"benchmark/[>=1.5.0]",
]
requires = [
"range-v3/0.10.0",
"fmt/6.0.0",
"boost/1.73.0"
]
def configure(self):
self.settings.compiler.cppstd = "20"
tools.check_min_cppstd(self, "20")
def build(self):
cmake = CMake(self)
......@@ -33,26 +46,20 @@ class Pylene(ConanFile):
cmake.install()
def package(self):
self.copy("*", dst="", src="cmake")
self.copy("FindFreeImage.cmake", dst="", src="cmake")
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
def package_info(self):
if self.settings.compiler in ["gcc", "clang"]:
self.cpp_info.cppflags = ["-std=c++20"]
# developer dependancies (to be removed)
def build_requirements(self):
self.build_requires("gtest/[>=1.10]", force_host_context=True)
self.build_requires("benchmark/[>=1.5.0]", force_host_context=True)
# Requirements part of the INTERFACE
def requirements(self):
self.requires("range-v3/0.10.0@ericniebler/stable")
self.requires("fmt/6.0.0")
self.cpp_info.system_libs.append("freeimage")
self.cpp_info.names["cmake_find_package"] = "Pylene"
self.cpp_info.names["cmake_find_package_multi"] = "Pylene"
self.cpp_info.libs = [ "Pylene" ]
self.cpp_info.cxxflags.append(tools.cppstd_flag(self.settings))
if self.options.freeimage:
self.requires("freeimage/3.18.0@dutiona/stable")
v = tools.Version(self.settings.compiler.version)
if self.settings.compiler == "gcc" and v.major == "9":
self.cpp_info.cxxflags.append("-fconcepts")
if self.options.boost:
self.requires("boost/1.69.0@conan/stable")
def package_id(self):
del self.info.settings.compiler.cppstd
add_subdirectory(source/snippets)
find_package(Doxygen)
find_package(Sphinx)
find_package(Boost COMPONENTS program_options REQUIRED)
add_subdirectory(source/snippets)
if(DOXYGEN_FOUND)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/pylene/include)
......@@ -39,6 +39,5 @@ if(SPHINX_FOUND AND DOXYGEN_FOUND)
DEPENDS build-images build-doxygen ${SPHINX_SOURCES}
COMMENT "Generating Sphinx documentation")
add_dependencies(build-doc build-sphinx)
endif()
......@@ -64,7 +64,9 @@ add_custom_target(build-images
add_library(doc-lib lut.cpp)
target_link_libraries(doc-lib Pylene::Pylene)
link_libraries(${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} ${FreeImage_LIBRARY})
link_libraries(Pylene::Pylene)
link_libraries(doc-lib)
......@@ -77,3 +79,12 @@ add_executable(area_filter area_filter.cpp)
add_executable(cdt cdt.cpp)
add_executable(first_start_1 first_start_1.cpp)
add_executable(intro-1 intro-1.cpp)
target_compile_definitions(erosion-cli PRIVATE BOOST_ALL_NO_LIB)
# for program_options, need to separate CONAN and regular FindBoost
if (TARGET Boost::program_options)
target_link_libraries(erosion-cli PRIVATE Boost::program_options)
elseif (TARGET Boost::Boost)
target_link_libraries(erosion-cli PRIVATE Boost::Boost)
endif()
\ No newline at end of file
......@@ -68,13 +68,11 @@ The Pylene library is available on our repository https://artifactory.lrde.epita
Then, see conan's documentation for how to use the package with your favorite build system. The following steps apply to CMake.
3. Use conan with the **cmake_paths** generator to allows CMake to find the Config file provided by the library.
3. Use conan with the **cmake_find_package** generator.
4. In your :file:`CMakeLists.txt`, include the file ``conan_paths.cmake`` and
use **find_package** as usual::
4. In your :file:`CMakeLists.txt`, use **find_package** as usual::
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
find_package(Pylene CONFIG)
find_package(Pylene)
The following targets are then available:
......@@ -125,12 +123,13 @@ Install (for developers)
#. Clone the repository::
git clone git@gitlab.lrde.epita.fr:olena/pylene.git
#. Install developer dependencies
#. Install developer dependencies using conan.
* Google Test
* Google Benchmark (by Conan)
* range v3 (by Conan)
* FreeImage
* Google Benchmark
* range v3
* FreeImage (non-managed by conan)
* Boost
* Python with Sphinx, Matplotlib, Numpy (for the documentation)
* Conan
......@@ -138,10 +137,7 @@ Install (for developers)
#. Use *conan* to install the dependencies not provided by your system.
This is advised to use the followings options::
benchmark = True
freeimage = False
gtest = False
boost_program_options = False
benchmark:shared = True
gtest:shared = True
......
......@@ -4,7 +4,7 @@ find_package(Boost 1.58 REQUIRED)
find_package(FreeImage REQUIRED)
find_package(TBB)
find_package(range-v3 0.10.0 REQUIRED CONFIG)
find_package(range-v3 0.10.0 REQUIRED)
find_package(fmt 6.0 REQUIRED)
set(PYLENE_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")
......@@ -25,9 +25,12 @@ if (UNIX AND NOT APPLE)
target_link_libraries(Pylene INTERFACE rt)
elseif (MSVC)
#
target_compile_options(Pylene PUBLIC "/wd4275" # non dll-interface class '...' used as base for dll-interface (fmt lib)
"/wd5104" # found 'L#x' in macro replacement list, did you mean
)
target_compile_options(Pylene PUBLIC
"/wd4275" # non dll-interface class '...' used as base for dll-interface (fmt lib)
"/wd5104" # found 'L#x' in macro replacement list, did you mean
"/experimental:preprocessor" # required by range-v3
"/permissive-" # required by range-v3
)
endif ()
......@@ -36,8 +39,8 @@ target_include_directories(Pylene PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(Pylene SYSTEM PUBLIC ${Boost_INCLUDE_DIR})
target_link_libraries(Pylene PUBLIC range-v3)
target_include_directories(Pylene SYSTEM PUBLIC $<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>)
target_link_libraries(Pylene PUBLIC range-v3::range-v3)
target_link_libraries(Pylene PUBLIC fmt::fmt)
target_link_libraries(Pylene PRIVATE FreeImage::FreeImage)
......@@ -73,7 +76,7 @@ target_sources(Pylene PRIVATE
# Compiler configurations
target_compile_features(Pylene PUBLIC cxx_std_20)
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
target_compile_options(Pylene PUBLIC -fconcepts)
endif()
......
......@@ -17,7 +17,7 @@ namespace mln
{
int SR = 5; // Spatial window radius
int NITER = 30; // Maximal number of iteration
float eps = 0.1; //
float eps = 0.1f; //
double hs2 = hs * hs;
double hr2 = hr * hr;
double eps2 = eps * eps;
......
project(PyleneTest)
cmake_minimum_required(VERSION 3.8.2)
cmake_minimum_required(VERSION 3.11)
include("${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake")
if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake")
endif()
find_package(Pylene REQUIRED)
find_package(FreeImage REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Pylene::Pylene FreeImage::FreeImage)
target_link_libraries(main Pylene::Pylene)
......@@ -3,7 +3,7 @@ import os
class PyleneTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = [ "cmake_paths", "cmake_find_package" ]
generators = [ "cmake_find_package" ]
def build(self):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment