-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
74 lines (62 loc) · 2.37 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
cmake_minimum_required(VERSION 2.8)
project(libiio)
set(MAJOR_VERSION 0)
set(MINOR_VERSION 20220720)
set(IIO_VERSION ${MAJOR_VERSION}.${MINOR_VERSION})
set(prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
set(LIBS "-ljpeg -lpng -ltiff -lz")
# The build type "Release" adds some optimizations
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
# GCC on MacOs needs this option to use the clang assembler
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (APPLE))
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wa,-q")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-q")
set (CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem")
set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem")
endif ()
# Optimize to the current CPU and enable warnings
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -Wall -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra")
endif ()
# Enable C99
if (CMAKE_VERSION VERSION_LESS "3.1")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
else ()
set (CMAKE_C_STANDARD 99)
endif ()
# Enable C++11
if (CMAKE_VERSION VERSION_LESS "3.1")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else ()
set (CMAKE_CXX_STANDARD 11)
endif ()
# Enable OpenMP
find_package (OpenMP)
if(OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif()
# Link LibTIFF, LibJPEG, LibPNG, OpenMP
find_package (TIFF REQUIRED)
find_package (JPEG REQUIRED)
find_package (PNG REQUIRED)
include_directories (SYSTEM ${TIFF_INCLUDE_DIR} ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIRS})
link_libraries (${TIFF_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES})
set(SOURCE_FILES
src/iio.c
src/iio.h
)
set_property(SOURCE iio.c PROPERTY COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-parameter -Wno-pointer-sign -Wno-parentheses -Wno-deprecated-declarations -Wno-unused-function")
add_library(iio SHARED ${SOURCE_FILES})
set_target_properties(iio PROPERTIES VERSION ${IIO_VERSION} SOVERSION ${MAJOR_VERSION})
configure_file(libiio.pc.in libiio.pc @ONLY)
install(TARGETS iio LIBRARY DESTINATION lib)
install(FILES iio.h DESTINATION include)
install(FILES libiio.pc DESTINATION lib/pkgconfig)