CMakeLists.txt 3.54 KB
Newer Older
1
2
include(CMakePackageConfigHelpers)

3
find_package(Boost 1.58 REQUIRED)
4
find_package(range-v3 0.4.0 REQUIRED)
5
6
7
8
9
10
find_package(FreeImage REQUIRED)
find_package(TBB)

set(PYLENE_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")


Edwin Carlinet's avatar
Edwin Carlinet committed
11
12
add_library(Pylene)

13
14
if (TBB_FOUND AND PYLENE_USE_TBB)
  target_link_libraries(Pylene INTERFACE tbb)
15
else ()
16
17
18
  set(PYLENE_USE_TBB OFF)
  #FIXME use a config file
  target_compile_definitions(Pylene INTERFACE MLN_NO_TBB)
19
endif ()
20
21
22

# FIXME: still useful ?
if (UNIX AND NOT APPLE)
23
24
  target_link_libraries(Pylene INTERFACE rt)
endif ()
25
26
27


# Set dependancies
Edwin Carlinet's avatar
Edwin Carlinet committed
28
target_include_directories(Pylene PUBLIC
29
30
                           $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
                           $<INSTALL_INTERFACE:include>)
31

Edwin Carlinet's avatar
Edwin Carlinet committed
32
33
target_include_directories(Pylene SYSTEM PUBLIC ${Boost_INCLUDE_DIR})
target_include_directories(Pylene PUBLIC ${FreeImage_INCLUDE_DIRS})
34
set_property(TARGET Pylene APPEND
35
             PROPERTY INTERFACE_LINK_DIRECTORIES ${FreeImage_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
Edwin Carlinet's avatar
Edwin Carlinet committed
36
target_link_libraries(Pylene PUBLIC range-v3)
Michaël Roynard's avatar
Michaël Roynard committed
37
set_target_properties(Pylene PROPERTIES POSITION_INDEPENDENT_CODE ON)
38
39
40
41
42
43


# Set sources
file(GLOB_RECURSE sources "include/mln/*.hpp")
target_sources(Pylene INTERFACE $<BUILD_INTERFACE:${sources}>)

Edwin Carlinet's avatar
Edwin Carlinet committed
44
target_sources(Pylene PRIVATE
45
46
47
48
49
               src/core/se/disc.cpp
               src/core/se/periodic_line2d.cpp
               src/core/se/rect2d.cpp
               src/core/se/mask2d.cpp
               src/core/trace.cpp
Edwin Carlinet's avatar
Edwin Carlinet committed
50

51
52
               src/py/core/any_ref.cpp
               src/py/core/any_ref_placeholder.cpp
53
               src/py/core/any_span.cpp
54
               src/py/core/image2d_data.cpp
55
               )
Edwin Carlinet's avatar
Edwin Carlinet committed
56

57
# Compiler configurations
Edwin Carlinet's avatar
Edwin Carlinet committed
58
target_compile_features(Pylene PUBLIC cxx_std_17)
59

Michaël Roynard's avatar
Michaël Roynard committed
60
# Add concepts support for gcc > 7.2 with -fconcepts
61
62
63
64
65
66
# if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.2)
#   target_compile_options(Pylene PUBLIC -fconcepts)
#   find_package(cmcstl2 REQUIRED)
#   target_link_libraries(Pylene PUBLIC stl2)
#   target_compile_definitions(Pylene PUBLIC PYLENE_CONCEPT_TS_ENABLED)
# endif ()
Michaël Roynard's avatar
Michaël Roynard committed
67

68
69
70
71
72
73

# IDE configuration
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/mln FILES ${sources})


Edwin Carlinet's avatar
Edwin Carlinet committed
74
75
76
# Pylene-python lib
add_library(Pylene-python)
target_sources(Pylene-python PRIVATE
77
78
79
80
               #src/py/core/image_format.cpp
               #src/py/core/ndbuffer_image_data.cpp
               #src/py/core/ndbuffer_image.cpp
               )
Edwin Carlinet's avatar
Edwin Carlinet committed
81
82
83
84
85
86
target_include_directories(Pylene-python PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
   $<INSTALL_INTERFACE:include>)
target_compile_features(Pylene-python PUBLIC cxx_std_17)
target_link_libraries(Pylene-python PUBLIC Pylene)

87

Edwin Carlinet's avatar
Edwin Carlinet committed
88
# EXPORT and INSTALL
89
add_library(Pylene::Pylene ALIAS Pylene)
90
91
add_dependencies(build-pylene Pylene::Pylene)

92
install(TARGETS Pylene
93
94
95
96
        EXPORT PyleneTargets
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
        INCLUDES DESTINATION include)
97
98
99
100
101

write_basic_package_version_file(
    PyleneConfigVersion.cmake
    VERSION ${PACKAGE_VERSION}
    COMPATIBILITY AnyNewerVersion
102
)
103
104

configure_file(
105
106
107
108
    PyleneConfig.cmake.in
    PyleneConfig.cmake
    @ONLY
)
109
110

install(EXPORT PyleneTargets
111
112
113
114
        FILE PyleneTargets.cmake
        NAMESPACE Pylene::
        DESTINATION lib/cmake/pylene
        )
115
install(DIRECTORY include/mln
116
        DESTINATION include)
117

118
install(FILES
119
120
121
        ${CMAKE_CURRENT_BINARY_DIR}/PyleneConfig.cmake
        ${CMAKE_CURRENT_BINARY_DIR}/PyleneConfigVersion.cmake
        DESTINATION lib/cmake/pylene)