-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
90 lines (72 loc) · 2.49 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
cmake_minimum_required(VERSION 2.8.11)
project(lycon)
include(cmake/LyconUtils.cmake)
set(LYCON_SOURCES
src/lycon/io/base.cc
src/lycon/io/bitstream.cc
src/lycon/io/exif.cc
src/lycon/io/io.cc
src/lycon/io/jpeg.cc
src/lycon/io/png.cc
src/lycon/mat/allocator.cc
src/lycon/mat/convert.cc
src/lycon/mat/copy.cc
src/lycon/mat/io_array.cc
src/lycon/mat/iterator.cc
src/lycon/mat/mat.cc
src/lycon/mat/umat_data.cc
src/lycon/transform/resize.cc
src/lycon/transform/rotate.cc
src/lycon/util/alloc.cc
src/lycon/util/color.cc
src/lycon/util/file.cc
src/lycon/util/hardware.cc
src/lycon/util/parallel_pthreads.cc
src/lycon/util/parallel.cc
src/lycon/util/singleton.cc
src/lycon/util/string.cc
src/lycon/util/tls.cc
)
set(LYCON_PYTHON_SOURCES
src/lycon/python/interop.cc
src/lycon/python/module.cc
)
set(CMAKE_MACOSX_RPATH TRUE)
# Build options
lycon_option(LYCON_BUILD_STATIC "Build Lycon as a static library" ON)
lycon_option(LYCON_BUILD_PYTHON "Build the Python native extension" ON)
lycon_option(LYCON_NUMPY_ALLOCATOR_BY_DEFAULT "Use the NumPy allocator by default" ${LYCON_BUILD_PYTHON})
# Enabling this can avoid libstdc++ compatibility issues under environments like Conda
lycon_option(LYCON_STATIC_LIBSTDCPP "Statically link against libstdc++" ON IF NOT APPLE)
include_directories(src)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=native -O3 -fPIC -DNDEBUG -pthread")
if(LYCON_STATIC_LIBSTDCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
endif()
# If enabled, use the NumPy allocator as the default Mat allocator
if(LYCON_NUMPY_ALLOCATOR_BY_DEFAULT)
add_definitions(-DLYCON_USE_NUMPY_ALLOCATOR_BY_DEFAULT)
endif()
# The main library
if(LYCON_BUILD_STATIC)
add_library(lycon STATIC ${LYCON_SOURCES})
else()
add_library(lycon SHARED ${LYCON_SOURCES})
endif()
# LibPNG
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
target_link_libraries(lycon ${PNG_LIBRARY})
# LibJPEG
find_package(JPEG REQUIRED)
include_directories(${JPEG_INCLUDE_DIR})
target_link_libraries(lycon ${JPEG_LIBRARY})
# The Python extension
if (LYCON_BUILD_PYTHON)
include(cmake/LocatePythonLibs.cmake)
include_directories(${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_DIR})
add_library(pycon SHARED ${LYCON_PYTHON_SOURCES})
target_link_libraries(pycon lycon ${PYTHON_LIB_PATH})
# NOTE(saumitro): Even on macOS, Python expects the ".so" suffix rather than ".dylib"
set_target_properties(pycon PROPERTIES PREFIX "_" SUFFIX ".so" OUTPUT_NAME "lycon")
endif()