-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
198 lines (160 loc) · 7.25 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
cmake_minimum_required(VERSION 2.8.7)
if(MSVC)
# CMake 3.4 introduced a WINDOWS_EXPORT_ALL_SYMBOLS target property that makes it possible to
# build shared libraries without using the usual declspec() decoration.
# See: https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
# and https://cmake.org/cmake/help/v3.5/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html
# for details.
cmake_minimum_required(VERSION 3.4)
endif()
if(POLICY CMP0046)
cmake_policy(SET CMP0046 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
project (RawScaler C CXX)
# The version number.
set (RawScaler_VERSION_MAJOR 1)
set (RawScaler_VERSION_MINOR 0)
option(OpenCV_Enable "for hardware design" ON)
option(openmp "for hardware design" ON)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
set(arch_hint "x64")
elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64")
set(arch_hint "ARM64")
elseif("${CMAKE_GENERATOR}" MATCHES "ARM")
set(arch_hint "ARM")
elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(arch_hint "x64")
elseif("$ENV{LIB}" MATCHES "(amd64|ia64)")
set(arch_hint "x64")
endif()
if(NOT arch_hint)
set(arch_hint "x86")
endif()
#
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
set(RawScaler_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(RawScaler_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(RawScaler_BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/RawScaler.config.h.in"
"${PROJECT_BINARY_DIR}/RawScaler.config.h"
)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories("${PROJECT_BINARY_DIR}")
# add the executable
file(GLOB RawScaler_TOOL
"tools/RawScaler/*.h"
"tools/RawScaler/*.cpp"
)
add_executable(RawScaler ${RawScaler_TOOL})
file(GLOB RawScaler_SRC
"include/*.h"
"include/*.hpp"
"src/*.cpp"
)
add_library(RawScalerLib ${RawScaler_SRC})
target_link_libraries (RawScaler RawScalerLib)
include_directories(RawScaler ${PROJECT_SOURCE_DIR}/include)
include_directories(RawScalerLib ${PROJECT_SOURCE_DIR}/include)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
IF(OpenCV_Enable MATCHES ON)
add_definitions(-DOpenCV)
add_definitions(-DImagePath="${PROJECT_SOURCE_DIR}/data/kodim19.png")
ELSE()
add_definitions(-DImagePath="${PROJECT_SOURCE_DIR}/data/kodim19.bmp")
ENDIF()
add_definitions(-DImagePath2="${PROJECT_SOURCE_DIR}/data/IMG_0040.bmp")
add_definitions(-DImagePath3="${PROJECT_SOURCE_DIR}/data/IMG_0086.bmp")
add_definitions(-DImagePath4="${PROJECT_SOURCE_DIR}/data/kodim01.bmp")
add_definitions(-DOutputDir="${PROJECT_SOURCE_DIR}/out/")
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 14 2015 Win64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
IF(openmp MATCHES ON)
add_definitions(-Dopenmp)
ENDIF(openmp MATCHES ON)
message("\n============== Windows " ${arch_hint} " build ===================\n")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "RawScaler" )
IF(CMAKE_BUILD_TYPE MATCHES Debug)
set(OpenCV_DIR OpenCV_DEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
IF(CMAKE_BUILD_TYPE MATCHES Release)
set(OpenCV_DIR OpenCV_RELEASE)
ENDIF(CMAKE_BUILD_TYPE MATCHES Release)
set(OpenCV_FOUND 1 )
find_package(OpenCV REQUIRED COMPONENTS core imgproc highgui)
# OPENCV config
set(OPENCV_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "")
set(opencv_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "")
set(OpenCV_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "")
set(OpenCV_STATIC OFF CACHE BOOL "")
# Add OpenCV to search directories
get_filename_component(_dir ${OpenCV_LIB_PATH} DIRECTORY)
list(APPEND _directories ${_dir}/bin)
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(RawScaler ${OpenCV_LIBS})
#include_directories(RawScaler "C:/Source Project 2017/RawScaler/OpenCV/x64/vc14/bin")
#file(GLOB OpenCV_DLLS
# "C:/Source Project 2017/RawScaler/OpenCV/x64/vc14/bin/*.dll"
#)
#file(COPY ${OpenCV_DLLS} DESTINATION ${RawScaler_BIN_DIR})
IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_highgui2413d.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
#target_link_libraries (RawScaler util)
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_imgproc2413d.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_core2413d.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
IF(CMAKE_BUILD_TYPE MATCHES Release)
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_highgui2413.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
#target_link_libraries (RawScaler util)
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_imgproc2413.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
add_custom_command(TARGET RawScaler PRE_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${_OpenCV_LIB_PATH}/opencv_core2413.dll" # <--this is in-file
$<TARGET_FILE_DIR:RawScaler>) # <--this is out-file path
ENDIF(CMAKE_BUILD_TYPE MATCHES Release)
else()
message("\n============== Linux " ${arch_hint} " build ===================\n")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
IF(OpenCV_Enable MATCHES ON)
find_package( OpenCV REQUIRED )
target_link_libraries( RawScaler ${OpenCV_LIBS} )
ENDIF()
#message(FATAL_ERROR "CMAKE_GENERATOR do net match Visual Studio 14 2015 Win64")
IF(openmp MATCHES ON)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
add_definitions(-Dopenmp)
endif()
ENDIF(openmp MATCHES ON)
endif()