Small refactoring of OpenCV cmake options
This commit is contained in:
parent
8b7edda6ac
commit
4ac407e76a
@ -72,11 +72,6 @@ set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
|
|||||||
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
|
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE INTERNAL "" FORCE)
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
|
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
set(CMAKE_VERBOSE OFF CACHE BOOL "Verbose mode")
|
|
||||||
if(CMAKE_VERBOSE)
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(cmake/OpenCVUtils.cmake REQUIRED)
|
include(cmake/OpenCVUtils.cmake REQUIRED)
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
@ -121,11 +116,7 @@ OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF
|
|||||||
|
|
||||||
# OpenCV build components
|
# OpenCV build components
|
||||||
# ===================================================
|
# ===================================================
|
||||||
if(ANDROID OR IOS)
|
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
|
||||||
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead 6of static ones (.lib/.a)" OFF )
|
|
||||||
else()
|
|
||||||
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON )
|
|
||||||
endif()
|
|
||||||
OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
|
OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
|
||||||
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
|
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
|
||||||
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
|
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
|
||||||
@ -165,8 +156,15 @@ OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions"
|
|||||||
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||||
|
|
||||||
|
# uncategorized options
|
||||||
|
# ===================================================
|
||||||
|
OCV_OPTION(CMAKE_VERBOSE "Verbose mode" OFF )
|
||||||
|
|
||||||
|
# backward compatibility
|
||||||
|
# ===================================================
|
||||||
include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
|
include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Get actual OpenCV version number from sources
|
# Get actual OpenCV version number from sources
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
@ -217,6 +215,10 @@ if(DEFINED CMAKE_DEBUG_POSTFIX)
|
|||||||
set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
|
set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_VERBOSE)
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Path for build/platform -specific headers
|
# Path for build/platform -specific headers
|
||||||
|
@ -15,19 +15,44 @@ endif()
|
|||||||
# Provides an option that the user can optionally select.
|
# Provides an option that the user can optionally select.
|
||||||
# Can accept condition to control when option is available for user.
|
# Can accept condition to control when option is available for user.
|
||||||
# Usage:
|
# Usage:
|
||||||
# option(<option_variable> "help string describing option" <initial value> [IF <condition>])
|
# option(<option_variable> "help string describing the option" <initial value or boolean expression> [IF <condition>])
|
||||||
macro(OCV_OPTION variable description value)
|
macro(OCV_OPTION variable description value)
|
||||||
SET(__condition ${ARGN})
|
set(__value ${value})
|
||||||
|
set(__condition "")
|
||||||
|
set(__varname "__value")
|
||||||
|
foreach(arg ${ARGN})
|
||||||
|
if(arg STREQUAL "IF" OR arg STREQUAL "if")
|
||||||
|
set(__varname "__condition")
|
||||||
|
else()
|
||||||
|
list(APPEND ${__varname} ${arg})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(__varname)
|
||||||
if("${__condition}" STREQUAL "")
|
if("${__condition}" STREQUAL "")
|
||||||
SET(__condition 1)
|
set(__condition 2 GREATER 1)
|
||||||
endif()
|
endif()
|
||||||
list(REMOVE_ITEM __condition "IF" "if")
|
|
||||||
if(${__condition})
|
if(${__condition})
|
||||||
OPTION(${variable} "${description}" ${value})
|
if("${__value}" MATCHES ";")
|
||||||
|
if(${__value})
|
||||||
|
option(${variable} "${description}" ON)
|
||||||
|
else()
|
||||||
|
option(${variable} "${description}" OFF)
|
||||||
|
endif()
|
||||||
|
elseif(DEFINED ${__value})
|
||||||
|
if(${__value})
|
||||||
|
option(${variable} "${description}" ON)
|
||||||
|
else()
|
||||||
|
option(${variable} "${description}" OFF)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
option(${variable} "${description}" ${__value})
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
UNSET(${variable} CACHE)
|
unset(${variable} CACHE)
|
||||||
endif()
|
endif()
|
||||||
UNSET(__condition)
|
unset(__condition)
|
||||||
|
unset(__value)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
@ -35,35 +60,36 @@ endmacro()
|
|||||||
# After it adds module to build and define
|
# After it adds module to build and define
|
||||||
# constants passed as second arg
|
# constants passed as second arg
|
||||||
macro(CHECK_MODULE module_name define)
|
macro(CHECK_MODULE module_name define)
|
||||||
set(${define} 0)
|
set(${define} 0)
|
||||||
if(PKG_CONFIG_FOUND)
|
if(PKG_CONFIG_FOUND)
|
||||||
set(ALIAS ALIASOF_${module_name})
|
set(ALIAS ALIASOF_${module_name})
|
||||||
set(ALIAS_FOUND ${ALIAS}_FOUND)
|
set(ALIAS_FOUND ${ALIAS}_FOUND)
|
||||||
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
|
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
|
||||||
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
|
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
|
||||||
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
|
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
|
||||||
|
|
||||||
PKG_CHECK_MODULES(${ALIAS} ${module_name})
|
PKG_CHECK_MODULES(${ALIAS} ${module_name})
|
||||||
|
|
||||||
if (${ALIAS_FOUND})
|
if(${ALIAS_FOUND})
|
||||||
set(${define} 1)
|
set(${define} 1)
|
||||||
foreach(P "${ALIAS_INCLUDE_DIRS}")
|
foreach(P "${ALIAS_INCLUDE_DIRS}")
|
||||||
if (${P})
|
if(${P})
|
||||||
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
|
list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(P "${ALIAS_LIBRARY_DIRS}")
|
|
||||||
if (${P})
|
|
||||||
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
|
|
||||||
endif()
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(P "${ALIAS_LIBRARY_DIRS}")
|
||||||
|
if(${P})
|
||||||
|
list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# Status report macro.
|
# Status report macro.
|
||||||
# Automatically align right column and selects text based on condition.
|
# Automatically align right column and selects text based on condition.
|
||||||
# Usage:
|
# Usage:
|
||||||
@ -71,75 +97,77 @@ endmacro()
|
|||||||
# status(<heading> <value1> [<value2> ...])
|
# status(<heading> <value1> [<value2> ...])
|
||||||
# status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
|
# status(<heading> <condition> THEN <text for TRUE> ELSE <text for FALSE> )
|
||||||
macro(status text)
|
macro(status text)
|
||||||
SET(status_cond)
|
set(status_cond)
|
||||||
SET(status_then)
|
set(status_then)
|
||||||
SET(status_else)
|
set(status_else)
|
||||||
|
|
||||||
SET(status_current_name "cond")
|
set(status_current_name "cond")
|
||||||
foreach(arg ${ARGN})
|
foreach(arg ${ARGN})
|
||||||
if(arg STREQUAL "THEN")
|
if(arg STREQUAL "THEN")
|
||||||
SET(status_current_name "then")
|
set(status_current_name "then")
|
||||||
elseif(arg STREQUAL "ELSE")
|
elseif(arg STREQUAL "ELSE")
|
||||||
SET(status_current_name "else")
|
set(status_current_name "else")
|
||||||
else()
|
else()
|
||||||
LIST(APPEND status_${status_current_name} ${arg})
|
list(APPEND status_${status_current_name} ${arg})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(DEFINED status_cond)
|
if(DEFINED status_cond)
|
||||||
SET(status_placeholder_length 32)
|
set(status_placeholder_length 32)
|
||||||
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
|
string(RANDOM LENGTH ${status_placeholder_length} ALPHABET " " status_placeholder)
|
||||||
string(LENGTH "${text}" status_text_length)
|
string(LENGTH "${text}" status_text_length)
|
||||||
if (status_text_length LESS status_placeholder_length)
|
if(status_text_length LESS status_placeholder_length)
|
||||||
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
|
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
|
||||||
elseif (DEFINED status_then OR DEFINED status_else)
|
elseif(DEFINED status_then OR DEFINED status_else)
|
||||||
message(STATUS "${text}")
|
message(STATUS "${text}")
|
||||||
SET(status_text "${status_placeholder}")
|
set(status_text "${status_placeholder}")
|
||||||
else()
|
else()
|
||||||
SET(status_text "${text}")
|
set(status_text "${text}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DEFINED status_then OR DEFINED status_else)
|
if(DEFINED status_then OR DEFINED status_else)
|
||||||
if(${status_cond})
|
if(${status_cond})
|
||||||
string(REPLACE ";" " " status_then "${status_then}")
|
string(REPLACE ";" " " status_then "${status_then}")
|
||||||
message(STATUS "${status_text}" "${status_then}")
|
message(STATUS "${status_text}" "${status_then}")
|
||||||
else()
|
else()
|
||||||
string(REPLACE ";" " " status_else "${status_else}")
|
string(REPLACE ";" " " status_else "${status_else}")
|
||||||
message(STATUS "${status_text}" "${status_else}")
|
message(STATUS "${status_text}" "${status_else}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
string(REPLACE ";" " " status_cond "${status_cond}")
|
string(REPLACE ";" " " status_cond "${status_cond}")
|
||||||
message(STATUS "${status_text}" "${status_cond}")
|
message(STATUS "${status_text}" "${status_cond}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(STATUS "${text}")
|
message(STATUS "${text}")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# splits cmake libraries list of format "general;item1;debug;item2;release;item3" to two lists
|
# splits cmake libraries list of format "general;item1;debug;item2;release;item3" to two lists
|
||||||
macro(ocv_split_libs_list lst lstdbg lstopt)
|
macro(ocv_split_libs_list lst lstdbg lstopt)
|
||||||
set(${lstdbg} "")
|
set(${lstdbg} "")
|
||||||
set(${lstopt} "")
|
set(${lstopt} "")
|
||||||
set(perv_keyword "")
|
set(perv_keyword "")
|
||||||
foreach(word ${${lst}})
|
foreach(word ${${lst}})
|
||||||
if(word STREQUAL "debug" OR word STREQUAL "optimized")
|
if(word STREQUAL "debug" OR word STREQUAL "optimized")
|
||||||
set(perv_keyword ${word})
|
set(perv_keyword ${word})
|
||||||
elseif(word STREQUAL "general")
|
elseif(word STREQUAL "general")
|
||||||
set(perv_keyword "")
|
set(perv_keyword "")
|
||||||
elseif(perv_keyword STREQUAL "debug")
|
elseif(perv_keyword STREQUAL "debug")
|
||||||
list(APPEND ${lstdbg} "${word}")
|
list(APPEND ${lstdbg} "${word}")
|
||||||
set(perv_keyword "")
|
set(perv_keyword "")
|
||||||
elseif(perv_keyword STREQUAL "optimized")
|
elseif(perv_keyword STREQUAL "optimized")
|
||||||
list(APPEND ${lstopt} "${word}")
|
list(APPEND ${lstopt} "${word}")
|
||||||
set(perv_keyword "")
|
set(perv_keyword "")
|
||||||
else()
|
else()
|
||||||
list(APPEND ${lstdbg} "${word}")
|
list(APPEND ${lstdbg} "${word}")
|
||||||
list(APPEND ${lstopt} "${word}")
|
list(APPEND ${lstopt} "${word}")
|
||||||
set(perv_keyword "")
|
set(perv_keyword "")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# remove all matching elements from the list
|
# remove all matching elements from the list
|
||||||
macro(ocv_list_filterout lst regex)
|
macro(ocv_list_filterout lst regex)
|
||||||
foreach(item ${${lst}})
|
foreach(item ${${lst}})
|
||||||
@ -149,6 +177,7 @@ macro(ocv_list_filterout lst regex)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# stable & safe duplicates removal macro
|
# stable & safe duplicates removal macro
|
||||||
macro(ocv_list_unique __lst)
|
macro(ocv_list_unique __lst)
|
||||||
if(${__lst})
|
if(${__lst})
|
||||||
@ -156,6 +185,7 @@ macro(ocv_list_unique __lst)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# safe list reversal macro
|
# safe list reversal macro
|
||||||
macro(ocv_list_reverse __lst)
|
macro(ocv_list_reverse __lst)
|
||||||
if(${__lst})
|
if(${__lst})
|
||||||
@ -163,6 +193,7 @@ macro(ocv_list_reverse __lst)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# safe list sorting macro
|
# safe list sorting macro
|
||||||
macro(ocv_list_sort __lst)
|
macro(ocv_list_sort __lst)
|
||||||
if(${__lst})
|
if(${__lst})
|
||||||
@ -170,6 +201,7 @@ macro(ocv_list_sort __lst)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
# simple regex escaping routine (does not cover all cases!!!)
|
# simple regex escaping routine (does not cover all cases!!!)
|
||||||
macro(ocv_regex_escape var regex)
|
macro(ocv_regex_escape var regex)
|
||||||
string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}")
|
string(REGEX REPLACE "([+.*^$])" "\\\\1" ${var} "${regex}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user