Commit d575323c authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Merge branch 'development/fix-conan-targets' into 'next'

New conan/cmake targets.

See merge request !117
parents a946bee1 66f99a7c
Pipeline #28783 passed with stages
in 25 minutes and 18 seconds
......@@ -68,7 +68,7 @@ windows-debug:
- mkdir build && cd build
- conan install .. --build missing -s compiler.cppstd=20 -e CXXFLAGS="" -e CCFLAGS="" -pr $CONAN_PROFILE -o pylene:fPIC=True
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DPYLENE_BUILD_PYTHON=ON
- cmake --build . --target Pylene
- cmake --build . --target Pylene-core
- cmake --build . --target pylena
- cmake --build . --target build-tests
- ctest -L UnitTests --schedule-random --output-on-failure
......
......@@ -95,6 +95,8 @@ endif ()
#### Configuration of the Compiler ###
# Subdirectories
add_library(Pylene INTERFACE)
add_library(Pylene::Pylene ALIAS Pylene)
add_subdirectory(pylene)
if (PYLENE_BUILD_PYTHON)
......@@ -122,6 +124,59 @@ if (NOT PYLENE_BUILD_LIBS_ONLY)
endif ()
####################################################
####### Installation & CMAKE module files ##########
####################################################
target_link_libraries(Pylene INTERFACE Pylene::Core)
include(GNUInstallDirs)
set(PyleneTargets Pylene Pylene-core Pylene-bp)
if (TARGET Pylene-numpy)
list(APPEND PyleneTargets Pylene-numpy)
endif()
install(TARGETS ${PyleneTargets}
EXPORT PyleneTargets)
write_basic_package_version_file(
pylene/PyleneConfigVersion.cmake
VERSION 0.1
COMPATIBILITY AnyNewerVersion
)
configure_file(
pylene/PyleneConfig.cmake.in
pylene/PyleneConfig.cmake
@ONLY
)
install(EXPORT PyleneTargets
FILE PyleneTargets.cmake
NAMESPACE Pylene::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pylene
)
install(DIRECTORY pylene-python/include/pln
TYPE INCLUDE)
install(DIRECTORY pylene/include/mln
TYPE INCLUDE)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pylene/PyleneConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/pylene/PyleneConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pylene)
####################################################
####### Packaging ##########
####################################################
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}/;/\\\\.git/;.*~;#.*#")
INCLUDE(CPack)
......
......@@ -9,7 +9,7 @@
# the list of executables to be run.
# A test is also added with the same name and belongs to the group "SpeedTests"
# They can be run with ctest -L SpeedTests.
#
#
add_custom_target(run-all-benchmarks)
......@@ -20,10 +20,10 @@ function(add_benchmark Executable)
# Create benchmark exe
add_executable(${Benchmark_NAME} ${Benchmark_SOURCES})
target_link_libraries(${Benchmark_NAME} PRIVATE Fixtures::ImagePath BenchImpl Pylene::Pylene benchmark::benchmark ${FreeImage_LIBRARIES})
target_link_libraries(${Benchmark_NAME} PRIVATE Fixtures::ImagePath BenchImpl Pylene::Core benchmark::benchmark ${FreeImage_LIBRARIES})
target_include_directories(${Benchmark_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(build-bench ${Benchmark_NAME})
# Retrieve reference
set(Benchmark_OUTPUT_FILE ${Benchmark_NAME}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}.json)
......
......@@ -66,19 +66,19 @@ class Pylene(ConanFile):
self.cpp_info.names["cmake_find_package"] = "Pylene"
self.cpp_info.names["cmake_find_package_multi"] = "Pylene"
self.cpp_info.components["Pylene"].system_libs.append("freeimage")
self.cpp_info.components["Pylene"].names["cmake_find_package"] = "Pylene"
self.cpp_info.components["Pylene"].names["cmake_find_package_multi"] = "Pylene"
self.cpp_info.components["Pylene"].libs = ["Pylene"]
self.cpp_info.components["Pylene"].includedirs = [os.path.join(self.package_folder, "include")]
self.cpp_info.components["Pylene"].requires = ["range-v3::range-v3", "fmt::fmt", "tbb::tbb", "xsimd::xsimd"]
self.cpp_info.components["Core"].system_libs.append("freeimage")
self.cpp_info.components["Core"].names["cmake_find_package"] = "Core"
self.cpp_info.components["Core"].names["cmake_find_package_multi"] = "Core"
self.cpp_info.components["Core"].libs = ["Pylene-core"]
self.cpp_info.components["Core"].includedirs = ["include"]
self.cpp_info.components["Core"].requires = ["range-v3::range-v3", "fmt::fmt", "tbb::tbb", "xsimd::xsimd"]
if self._build_python():
self.cpp_info.components["Pylene-numpy"].names["cmake_find_pakage_multi"] = "Pylene-numpy"
self.cpp_info.components["Pylene-numpy"].names["cmake_find_pakage"] = "Pylene-numpy"
self.cpp_info.components["Pylene-numpy"].libs = ["Pylene-numpy"]
self.cpp_info.components["Pylene-numpy"].requires = ["Pylene"]
self.cpp_info.components["Pylene-numpy"].includedirs = [os.path.join(self.package_folder, "include")]
self.cpp_info.components["Pylene-numpy"].requires = ["Core"]
self.cpp_info.components["Pylene-numpy"].includedirs = ["include"]
v = tools.Version(self.settings.compiler.version)
for comp in self.cpp_info.components:
......
......@@ -64,12 +64,12 @@ add_custom_target(build-images
DEPENDS "${DOCUMENTATION_IMAGES}")
add_library(doc-lib lut.cpp)
target_link_libraries(doc-lib Pylene::Pylene)
target_link_libraries(doc-lib Pylene::Core)
link_libraries(Pylene::Pylene)
link_libraries(Pylene::Core)
link_libraries(doc-lib)
add_executable(alphatree_example alphatree_example.cpp)
......@@ -90,4 +90,4 @@ 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
endif()
......@@ -96,10 +96,15 @@ Then, see conan's documentation for how to use the package with your favorite bu
The following targets are then available:
* ``Pylene::Pylene``: target to link with when using Pylene::
* ``Pylene::Pylene``: target to link with all Pylene components::
target_link_libraries(MyTarget PRIVATE Pylene::Pylene)
* ``Pylene::Core``: target to link with when using only the core component of Pylene::
target_link_libraries(MyTarget PRIVATE Pylene::Core)
Integration with CMake as a subdirectory
----------------------------------------
......@@ -113,12 +118,18 @@ or to exclude it from ``make``, ``make all``, or ``cmake --build ..``::
add_subdirectory(pylene EXCLUDE_FROM_ALL)
The following targets are then available:
* ``Pylene::Pylene``: target to link with when using Pylene::
* ``Pylene::Pylene``: target to link with all Pylene components::
target_link_libraries(MyTarget PRIVATE Pylene::Pylene)
* ``Pylene::Core``: target to link with when using only the core component of Pylene::
target_link_libraries(MyTarget PRIVATE Pylene::Core)
Integration with CMake from an existing installation
----------------------------------------------------
......@@ -128,12 +139,16 @@ Use ``find_package`` in your CMakeLists::
find_package(Pylene)
It makes the following targets available:
* ``Pylene::Pylene``: target to link with when using Pylene::
The following targets are then available:
* ``Pylene::Pylene``: target to link with all Pylene components::
target_link_libraries(MyTarget PRIVATE Pylene::Pylene)
* ``Pylene::Core``: target to link with when using only the core component of Pylene::
target_link_libraries(MyTarget PRIVATE Pylene::Core)
Installation (for developers)
......@@ -189,7 +204,7 @@ See `<https://gitlab.lrde.epita.fr/olena/pylene/-/blob/master/test_package/>`_.
find_package(Pylene REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Pylene::Pylene)
target_link_libraries(main Pylene::Core)
* Build intructions::
......
......@@ -19,13 +19,6 @@ target_link_libraries(Pylene-numpy PRIVATE fmt::fmt)
target_include_directories(Pylene-numpy PRIVATE ${pybind11_INCLUDE_DIRS})
pybind11_add_module(pylena)
target_link_libraries(pylena PRIVATE Pylene Pylene-numpy)
target_link_libraries(pylena PRIVATE Pylene::Core Pylene-numpy)
target_include_directories(pylena PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_sources(pylena PRIVATE src/module.cpp)
include(GNUInstallDirs)
install(TARGETS Pylene-numpy
EXPORT PyleneTargets)
install(DIRECTORY include/pln
TYPE INCLUDE)
\ No newline at end of file
......@@ -11,21 +11,21 @@ find_package(xsimd REQUIRED)
set(PYLENE_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")
add_library(Pylene)
add_library(Pylene-core)
if (TBB_FOUND AND PYLENE_USE_TBB)
target_link_libraries(Pylene PRIVATE TBB::TBB)
target_link_libraries(Pylene-core PRIVATE TBB::TBB)
else ()
set(PYLENE_USE_TBB OFF)
target_compile_definitions(Pylene PRIVATE MLN_NO_TBB)
target_compile_definitions(Pylene-core PRIVATE MLN_NO_TBB)
endif ()
# FIXME: still useful ?
if (UNIX AND NOT APPLE)
target_link_libraries(Pylene INTERFACE rt)
target_link_libraries(Pylene-core INTERFACE rt)
elseif (MSVC)
#
target_compile_options(Pylene PUBLIC
target_compile_options(Pylene-core 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
......@@ -35,14 +35,14 @@ endif ()
# Set dependancies
target_include_directories(Pylene PUBLIC
target_include_directories(Pylene-core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(Pylene SYSTEM PUBLIC $<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>)
target_link_libraries(Pylene PUBLIC range-v3::range-v3 xsimd::xsimd)
target_link_libraries(Pylene PUBLIC fmt::fmt)
target_link_libraries(Pylene PRIVATE FreeImage::FreeImage)
target_include_directories(Pylene-core SYSTEM PUBLIC $<BUILD_INTERFACE:${Boost_INCLUDE_DIRS}>)
target_link_libraries(Pylene-core PUBLIC range-v3::range-v3 xsimd::xsimd)
target_link_libraries(Pylene-core PUBLIC fmt::fmt)
target_link_libraries(Pylene-core PRIVATE FreeImage::FreeImage)
# Set sources
......@@ -61,10 +61,10 @@ target_include_directories(Pylene-bp PUBLIC
target_link_libraries(Pylene-bp PRIVATE xsimd::xsimd fmt::fmt)
target_compile_features(Pylene-bp PUBLIC cxx_std_20)
target_link_libraries(Pylene PRIVATE Pylene-bp)
target_link_libraries(Pylene-core PRIVATE Pylene-bp)
target_sources(Pylene PRIVATE
target_sources(Pylene-core PRIVATE
src/accu/cvxhull.cpp
src/core/image_format.cpp
src/core/init_list.cpp
......@@ -94,11 +94,11 @@ target_sources(Pylene PRIVATE
)
# Compiler configurations
target_compile_features(Pylene PUBLIC cxx_std_20)
target_compile_features(Pylene-core PUBLIC cxx_std_20)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
target_compile_options(Pylene-bp PUBLIC -fconcepts)
target_compile_options(Pylene PUBLIC -fconcepts)
target_compile_options(Pylene-core PUBLIC -fconcepts)
endif()
# IDE configuration
......@@ -106,39 +106,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/mln FILES ${sources})
add_library(Pylene::Pylene ALIAS Pylene)
add_library(Pylene::Core ALIAS Pylene-core)
include(GNUInstallDirs)
install(TARGETS Pylene Pylene-bp
EXPORT PyleneTargets)
write_basic_package_version_file(
PyleneConfigVersion.cmake
VERSION 0.1
COMPATIBILITY AnyNewerVersion
)
configure_file(
PyleneConfig.cmake.in
PyleneConfig.cmake
@ONLY
)
install(EXPORT PyleneTargets
FILE PyleneTargets.cmake
NAMESPACE Pylene::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pylene
)
install(DIRECTORY include/mln
TYPE INCLUDE)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/PyleneConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PyleneConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pylene)
# GCC8 has enoying random compilation failures
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_compile_definitions(Pylene PUBLIC PYLENE_GCC8_WORKAROUND)
target_compile_definitions(Pylene-core PUBLIC PYLENE_GCC8_WORKAROUND)
endif()
#pragma once
#include <mln/core/concepts/image.hpp>
#include <mln/core/image/image.hpp>
#include <mln/core/assert.hpp>
......
project(PyleneTest)
cmake_minimum_required(VERSION 3.11)
find_package(Pylene REQUIRED COMPONENTS Pylene)
find_package(Pylene REQUIRED COMPONENTS Core)
add_executable(main main.cpp)
target_link_libraries(main Pylene::Pylene)
target_link_libraries(main Pylene::Core)
if (WITH_PYLENE_NUMPY)
find_package(Pylene REQUIRED COMPONENTS Pylene-numpy)
find_package(pybind11 REQUIRED)
find_package(Pylene REQUIRED COMPONENTS Pylene-numpy)
pybind11_add_module(pylene_extension)
target_sources(pylene_extension PRIVATE pylene_extension.cpp)
target_link_libraries(pylene_extension PRIVATE Pylene::Pylene-numpy)
file(COPY ${CMAKE_SOURCE_DIR}/main.py DESTINATION ${CMAKE_BINARY_DIR})
endif(WITH_PYLENE_NUMPY)
\ No newline at end of file
endif(WITH_PYLENE_NUMPY)
Supports Markdown
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