forked from rolinh/VQMT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (124 loc) · 4.52 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
cmake_minimum_required(VERSION 2.8.4)
# project information
project(vqmt CXX)
set(WEBSITE "http:/mmspg.epfl.ch/vqmt")
set(COPYRIGHT "(c) 2013 Philippe Hanhart")
set(DESCRIPTION "Compute PSNR, SSIM, MS-SSIM, VIFp, PSNR-HVS and PSNR-HVS-M metrics between raw YUV videos using OpenCV")
set(PACKAGE ${CMAKE_PROJECT_NAME})
set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
# useful defines
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/${CMAKE_BUILD_TYPE})
# defines for installation
# installation prefix
if(DEFINED PREFIX)
set(PREFIX ${PREFIX} CACHE PATH "install prefix")
set(CMAKE_INSTALL_PREFIX ${PREFIX})
else()
set(PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "install prefix")
endif()
mark_as_advanced(CMAKE_INSTALL_PREFIX)
# share directory
if(DEFINED SHAREDIR)
set(SHAREDIR ${SHAREDIR} CACHE PATH "share directory")
else()
set(SHAREDIR ${PREFIX}/share CACHE PATH "share directory")
endif()
# man path
# TODO uncomment the following once a manpage has been written
#if(DEFINED MAN_PATH)
# set(MAN_PATH ${MAN_PATH} CACHE PATH "manpage directory")
#else()
# set(MAN_PATH ${SHAREDIR}/man CACHE PATH "manpage directory")
#endif()
# documentation path
if(DEFINED DOC_PATH)
set(VQMT_DOC_PATH ${DFC_DOC_PATH} CACHE PATH "doc directory")
else()
set(VQMT_DOC_PATH ${SHAREDIR}/doc/${PACKAGE} CACHE PATH "doc directory")
endif()
# set compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wdouble-promotion HAS_DOUBLE_PROMOTION)
check_cxx_compiler_flag(-Wsuggest-attribute=const HAS_SUGGEST_ATTRIBUTE_CONST)
check_cxx_compiler_flag(-Wsuggest-attribute=noreturn HAS_SUGGEST_ATTRIBUTE_NORETURN)
check_cxx_compiler_flag(-Wuseless-cast HAS_USELESS_CAST)
check_cxx_compiler_flag(-Wlogical-op HAS_LOGICAL_OP)
check_cxx_compiler_flag(-Wstrict-null-sentinel HAS_STRICT_NULL_SENTINEL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wfloat-equal -Wundef -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wsign-conversion -Wmissing-declarations -Wredundant-decls -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -pipe")
if(HAS_DOUBLE_PROMOTION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion")
endif()
if(HAS_SUGGEST_ATTRIBUTE_CONST)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-attribute=const")
endif()
if(HAS_SUGGEST_ATTRIBUTE_NORETURN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-attribute=noreturn")
endif()
if(HAS_USELESS_CAST)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuseless-cast")
endif()
if(HAS_LOGICAL_OP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
endif()
if(HAS_STRICT_NULL_SENTINEL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-null-sentinel")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -flto -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g3 -ggdb3 -Wpadded -Wpacked")
find_package(OpenCV REQUIRED)
set(EXECUTABLE_NAME ${CMAKE_PROJECT_NAME})
set(SRCS
${SOURCE_DIR}/main.cpp
${SOURCE_DIR}/Metric.cpp
${SOURCE_DIR}/MSSSIM.cpp
${SOURCE_DIR}/PSNR.cpp
${SOURCE_DIR}/PSNRHVS.cpp
${SOURCE_DIR}/SSIM.cpp
${SOURCE_DIR}/VideoYUV.cpp
${SOURCE_DIR}/VIFP.cpp
)
add_executable(
${EXECUTABLE_NAME}
${SRCS}
)
target_link_libraries(${CMAKE_PROJECT_NAME} ${OpenCV_LIBS})
set(VQMT_DOC_FILES
AUTHORS.md
CHANGELOG.md
LICENSE
README.md
readme.txt
)
# rule to generate a source tarball
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
"~$"
".directory"
".swp$"
"^${PROJECT_SOURCE_DIR}/.git/"
"^${PROJECT_SOURCE_DIR}/build/"
"${PROJECT_SOURCE_DIR}/.gitignore$"
"${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)
add_custom_target(dist
COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# installation
install(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION bin)
# TODO uncomment the following once the manpage has been written
#install(FILES ${MAN_DIR}/vqmt.1 DESTINATION ${MAN_PATH}/man1)
install(FILES ${VQMT_DOC_FILES} DESTINATION ${VQMT_DOC_PATH})
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)