-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
416 changed files
with
34,250 additions
and
52,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
if (PREVIEW_USE_SYSTEM_BOOST) | ||
if ("${PREVIEW_BOOST_PATH}" STREQUAL "") | ||
find_package(Boost REQUIRED COMPONENTS atomic) | ||
else () | ||
find_package(Boost REQUIRED COMPONENTS atomic PATHS "${PREVIEW_BOOST_PATH}") | ||
endif () | ||
else() | ||
include(FetchContent) | ||
|
||
FetchContent_Declare(boost_config | ||
GIT_REPOSITORY https://github.com/boostorg/config | ||
GIT_TAG 5734e160e08b8df898c7f747000f27a3aafb7b2b | ||
) | ||
FetchContent_Declare(boost_predef | ||
GIT_REPOSITORY https://github.com/boostorg/predef | ||
GIT_TAG boost-1.86.0 | ||
) | ||
FetchContent_Declare(boost_preprocessor | ||
GIT_REPOSITORY https://github.com/boostorg/preprocessor | ||
GIT_TAG boost-1.86.0 | ||
) | ||
FetchContent_MakeAvailable(boost_config boost_predef boost_preprocessor) | ||
|
||
add_subdirectory("${PREVIEW_THIRD_PARTY_DIR}/boost_1_86_0/atomic" "${CMAKE_CURRENT_BINARY_DIR}/boost") | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Got from: https://github.com/opencv/opencv/blob/ff18c9cc7904e878b10273265196e0238490e692/cmake/OpenCVUtils.cmake#L723 | ||
|
||
# Provides an option that the user can optionally select. | ||
# Can accept condition to control when option is available for user. | ||
# Usage: | ||
# option(<option_variable> | ||
# "help string describing the option" | ||
# <initial value or boolean expression> | ||
# [VISIBLE_IF <condition>] | ||
# [VERIFY <condition>]) | ||
macro(PREVIEW_OPTION variable description value) | ||
set(__value ${value}) | ||
set(__condition "") | ||
set(__verification) | ||
set(__varname "__value") | ||
foreach(arg ${ARGN}) | ||
if(arg STREQUAL "IF" OR arg STREQUAL "if" OR arg STREQUAL "VISIBLE_IF") | ||
set(__varname "__condition") | ||
elseif(arg STREQUAL "VERIFY") | ||
set(__varname "__verification") | ||
else() | ||
list(APPEND ${__varname} ${arg}) | ||
endif() | ||
endforeach() | ||
unset(__varname) | ||
if(__condition STREQUAL "") | ||
set(__condition 2 GREATER 1) | ||
endif() | ||
|
||
if(${__condition}) | ||
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() | ||
if(DEFINED ${variable} AND "${${variable}}" # emit warnings about turned ON options only. | ||
AND NOT (PREVIEW_HIDE_WARNING_UNSUPPORTED_OPTION OR "$ENV{PREVIEW_HIDE_WARNING_UNSUPPORTED_OPTION}") | ||
) | ||
message(WARNING "Unexpected option: ${variable} (=${${variable}})\nCondition: IF (${__condition})") | ||
endif() | ||
if(PREVIEW_UNSET_UNSUPPORTED_OPTION) | ||
unset(${variable} CACHE) | ||
endif() | ||
endif() | ||
if(__verification) | ||
set(PREVIEW_VERIFY_${variable} "${__verification}") # variable containing condition to verify | ||
list(APPEND PREVIEW_VERIFICATIONS "${variable}") # list of variable names (WITH_XXX;WITH_YYY;...) | ||
endif() | ||
unset(__condition) | ||
unset(__value) | ||
endmacro() | ||
|
||
# Check that each variable stored in PREVIEW_VERIFICATIONS list | ||
# is consistent with actual detection result (stored as condition in PREVIEW_VERIFY_...) variables | ||
function(preview_verify_config) | ||
set(broken_options) | ||
foreach(var ${PREVIEW_VERIFICATIONS}) | ||
set(evaluated FALSE) | ||
if(${PREVIEW_VERIFY_${var}}) | ||
set(evaluated TRUE) | ||
endif() | ||
# status("Verifying ${var}=${${var}} => '${PREVIEW_VERIFY_${var}}'=${evaluated}") | ||
if (${var} AND NOT evaluated) | ||
list(APPEND broken_options ${var}) | ||
message(WARNING | ||
"Option ${var} is enabled but corresponding dependency " | ||
"have not been found: \"${PREVIEW_VERIFY_${var}}\" is FALSE") | ||
elseif(NOT ${var} AND evaluated) | ||
list(APPEND broken_options ${var}) | ||
message(WARNING | ||
"Option ${var} is disabled or unset but corresponding dependency " | ||
"have been explicitly turned on: \"${PREVIEW_VERIFY_${var}}\" is TRUE") | ||
endif() | ||
endforeach() | ||
if(broken_options) | ||
string(REPLACE ";" "\n" broken_options "${broken_options}") | ||
message(FATAL_ERROR | ||
"Some dependencies have not been found or have been forced, " | ||
"unset ENABLE_CONFIG_VERIFICATION option to ignore these failures " | ||
"or change following options:\n${broken_options}") | ||
endif() | ||
endfunction() | ||
|
||
macro(PREVIEW_CHECK_COMPILES code out) | ||
set(CMAKE_REQUIRED_FLAGS ${ARGN}) | ||
check_cxx_source_compiles("${code}" ${out}) | ||
if ("${${out}}" STREQUAL "") | ||
set(${out} 0) # Workaround: CMake sometimes sets empty string instead of FALSE | ||
endif () | ||
message("${out}=${${out}}") | ||
set(${out} ${${out}} PARENT_SCOPE) | ||
endmacro() | ||
|
||
function(preview_get_cmake_args out) | ||
get_cmake_property(vars CACHE_VARIABLES) | ||
set(args) | ||
foreach(var ${vars}) | ||
get_property(currentHelpString CACHE "${var}" PROPERTY HELPSTRING) | ||
if("${currentHelpString}" MATCHES "No help, variable specified on the command line." OR "${currentHelpString}" STREQUAL "") | ||
get_property(var_type CACHE ${var} PROPERTY TYPE) | ||
if(var_type STREQUAL "UNINITIALIZED") | ||
set(var_type) | ||
else() | ||
set(var_type :${var_type}) | ||
endif() | ||
list(APPEND args "-D${var}${var_type}=${${var}}") | ||
endif() | ||
endforeach() | ||
set(${out} "${args}" PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
include(CheckCXXSourceCompiles) | ||
include(CheckCXXCompilerFlag) | ||
include(CheckCXXSymbolExists) | ||
include(CheckCXXSourceRuns) | ||
|
||
include(config/HaveBuiltinBitCast) | ||
include(config/HaveBuiltinConstexprAddressof) | ||
include(config/HaveContiguousIteratorTag) | ||
include(config/HaveCXX20Atomic) | ||
include(config/HaveStringView) | ||
|
||
set(PREVIEW_CONFIG_INPUT_FILE "${PREVIEW_INCLUDE_DIR}/preview/cmake_config.h.in") | ||
|
||
function(RunConfiguration out_dir flags) | ||
macro(PREVIEW_RUN_CONFIGURATION_TEST flags) | ||
message("Test flags: ${flags}") | ||
|
||
HaveBuiltinBitCast(PREVIEW_HAVE_BUILTIN_BIT_CAST ${flags}) | ||
HaveBuiltinConstexprAddressof(PREVIEW_HAVE_BUILTIN_CONSTEXPR_ADDRESSOF ${flags}) | ||
|
||
HaveContiguousIteratorTag(PREVIEW_HAVE_CONTIGUOUS_ITERATOR_TAG ${flags}) | ||
HaveStringView(PREVIEW_HAVE_STRING_VIEW ${flags}) | ||
|
||
HaveCXX20Atomic(PREVIEW_HAVE_CXX20_ATOMIC ${flags}) | ||
endmacro() | ||
|
||
macro(PREVIEW_CONFIGURE_FILE out_dir) | ||
configure_file("${PREVIEW_CONFIG_INPUT_FILE}" "${out_dir}") | ||
endfunction() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
set(HaveCXX20Atomic_Source " | ||
#include <atomic> | ||
#include <chrono> | ||
#include <thread> | ||
int main() { | ||
std::atomic<int> a{1}; | ||
std::thread t1([&a] { | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
a.fetch_add(1); | ||
a.notify_one(); | ||
a.notify_all(); | ||
}); | ||
a.wait(1); | ||
return 0; | ||
}") | ||
|
||
function(HaveCXX20Atomic out) | ||
PREVIEW_CHECK_COMPILES("${HaveCXX20Atomic_Source}" ${out}) | ||
message("${out}: ${${out}}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.