Update build.info and support native system on win
This commit is contained in:
parent
ee6d9f5a3b
commit
ac88a68ebc
|
@ -57,8 +57,12 @@ if(Boost_FOUND)
|
||||||
set(WITH_BOOST_FILESYSTEM true)
|
set(WITH_BOOST_FILESYSTEM true)
|
||||||
add_definitions(-DWITH_FILESYSTEM)
|
add_definitions(-DWITH_FILESYSTEM)
|
||||||
add_definitions(-DWITH_BOOST_FILESYSTEM)
|
add_definitions(-DWITH_BOOST_FILESYSTEM)
|
||||||
message(STATUS "Found boost filesystem: ${Boost_VERSION}")
|
message(STATUS "With boost filesystem: ${Boost_VERSION}")
|
||||||
#message(STATUS " Boost_LIBRARIES: ${Boost_LIBRARIES}")
|
#message(STATUS " Boost_LIBRARIES: ${Boost_LIBRARIES}")
|
||||||
|
elseif(OS_WIN)
|
||||||
|
add_definitions(-DWITH_FILESYSTEM)
|
||||||
|
add_definitions(-DWITH_NATIVE_FILESYSTEM)
|
||||||
|
message(STATUS "With native filesystem")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
LIST(APPEND CMAKE_MODULE_PATH cmake)
|
LIST(APPEND CMAKE_MODULE_PATH cmake)
|
||||||
|
@ -72,8 +76,13 @@ set(MYNTEYE_NAME ${PROJECT_NAME})
|
||||||
set(MYNTEYE_NAMESPACE "mynteye")
|
set(MYNTEYE_NAMESPACE "mynteye")
|
||||||
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
|
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
|
||||||
|
|
||||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" MYNTEYE_SDK_ROOT_DIR)
|
if(MSVC)
|
||||||
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" MYNTEYE_SDK_INSTALL_DIR)
|
string(REPLACE "/" "\\\\" MYNTEYE_SDK_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
string(REPLACE "/" "\\\\" MYNTEYE_SDK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
else()
|
||||||
|
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" MYNTEYE_SDK_ROOT_DIR)
|
||||||
|
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" MYNTEYE_SDK_INSTALL_DIR)
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
include/mynteye/mynteye.h.in
|
include/mynteye/mynteye.h.in
|
||||||
|
@ -243,7 +252,7 @@ install(EXPORT ${MYNTEYE_NAME}-targets
|
||||||
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
|
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(CUDA QUIET)
|
## build.info
|
||||||
|
|
||||||
macro(set_default_value VARIABLE DEFAULT)
|
macro(set_default_value VARIABLE DEFAULT)
|
||||||
if(NOT ${VARIABLE})
|
if(NOT ${VARIABLE})
|
||||||
|
@ -251,8 +260,18 @@ macro(set_default_value VARIABLE DEFAULT)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
set_default_value(GCC_VERSION_MAJOR 0)
|
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
|
||||||
set_default_value(GCC_VERSION_MINOR 0)
|
list(GET VERSION_LIST 0 CXX_COMPILER_VERSION_MAJOR)
|
||||||
|
list(GET VERSION_LIST 1 CXX_COMPILER_VERSION_MINOR)
|
||||||
|
list(GET VERSION_LIST 2 CXX_COMPILER_VERSION_PATCH)
|
||||||
|
list(GET VERSION_LIST 3 CXX_COMPILER_VERSION_TWEAK)
|
||||||
|
|
||||||
|
find_package(CUDA QUIET)
|
||||||
|
|
||||||
|
set_default_value(CXX_COMPILER_VERSION_MAJOR 0)
|
||||||
|
set_default_value(CXX_COMPILER_VERSION_MINOR 0)
|
||||||
|
set_default_value(CXX_COMPILER_VERSION_PATCH 0)
|
||||||
|
set_default_value(CXX_COMPILER_VERSION_TWEAK 0)
|
||||||
set_default_value(CUDA_VERSION_MAJOR 0)
|
set_default_value(CUDA_VERSION_MAJOR 0)
|
||||||
set_default_value(CUDA_VERSION_MINOR 0)
|
set_default_value(CUDA_VERSION_MINOR 0)
|
||||||
set_default_value(OpenCV_VERSION_MAJOR 0)
|
set_default_value(OpenCV_VERSION_MAJOR 0)
|
||||||
|
|
|
@ -50,15 +50,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/TargetArch.cmake)
|
||||||
target_architecture(HOST_ARCH)
|
target_architecture(HOST_ARCH)
|
||||||
message(STATUS "HOST_ARCH: ${HOST_ARCH}")
|
message(STATUS "HOST_ARCH: ${HOST_ARCH}")
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
# CMAKE_CXX_COMPILER_ID
|
||||||
execute_process(COMMAND gcc -dumpversion COMMAND cut -c 1-3 COMMAND tr -d '\n' OUTPUT_VARIABLE GCC_VERSION)
|
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
|
||||||
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONMENTS ${GCC_VERSION})
|
# CMAKE_CXX_COMPILER_VERSION
|
||||||
list(GET GCC_VERSION_COMPONMENTS 0 GCC_VERSION_MAJOR)
|
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_VERSION.html
|
||||||
list(GET GCC_VERSION_COMPONMENTS 1 GCC_VERSION_MINOR)
|
|
||||||
message(STATUS "GCC_VERSION: ${GCC_VERSION}")
|
|
||||||
#message(STATUS "GCC_VERSION_MAJOR: ${GCC_VERSION_MAJOR}")
|
|
||||||
#message(STATUS "GCC_VERSION_MINOR: ${GCC_VERSION_MINOR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# set_outdir(ARCHIVE_OUTPUT_DIRECTORY
|
# set_outdir(ARCHIVE_OUTPUT_DIRECTORY
|
||||||
# LIBRARY_OUTPUT_DIRECTORY
|
# LIBRARY_OUTPUT_DIRECTORY
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
HOST_OS: "@HOST_OS@"
|
HOST_OS: "@HOST_OS@"
|
||||||
HOST_NAME: "@HOST_NAME@"
|
HOST_NAME: "@HOST_NAME@"
|
||||||
HOST_ARCH: "@HOST_ARCH@"
|
HOST_ARCH: "@HOST_ARCH@"
|
||||||
GCC_VERSION: "@GCC_VERSION@"
|
HOST_COMPILER: "@CMAKE_CXX_COMPILER_ID@"
|
||||||
GCC_VERSION_MAJOR: @GCC_VERSION_MAJOR@
|
COMPILER_VERSION: "@CMAKE_CXX_COMPILER_VERSION@"
|
||||||
GCC_VERSION_MINOR: @GCC_VERSION_MINOR@
|
COMPILER_VERSION_MAJOR: @CXX_COMPILER_VERSION_MAJOR@
|
||||||
|
COMPILER_VERSION_MINOR: @CXX_COMPILER_VERSION_MINOR@
|
||||||
|
COMPILER_VERSION_PATCH: @CXX_COMPILER_VERSION_PATCH@
|
||||||
|
COMPILER_VERSION_TWEAK: @CXX_COMPILER_VERSION_TWEAK@
|
||||||
CUDA_VERSION: "@CUDA_VERSION@"
|
CUDA_VERSION: "@CUDA_VERSION@"
|
||||||
CUDA_VERSION_MAJOR: @CUDA_VERSION_MAJOR@
|
CUDA_VERSION_MAJOR: @CUDA_VERSION_MAJOR@
|
||||||
CUDA_VERSION_MINOR: @CUDA_VERSION_MINOR@
|
CUDA_VERSION_MINOR: @CUDA_VERSION_MINOR@
|
||||||
|
|
|
@ -31,13 +31,19 @@
|
||||||
#include "device/device.h"
|
#include "device/device.h"
|
||||||
#include "internal/dl.h"
|
#include "internal/dl.h"
|
||||||
|
|
||||||
|
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
MYNTEYE_BEGIN_NAMESPACE
|
MYNTEYE_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef WITH_FILESYSTEM
|
#if defined(WITH_FILESYSTEM)
|
||||||
|
|
||||||
#ifdef WITH_BOOST_FILESYSTEM
|
#if defined(WITH_BOOST_FILESYSTEM)
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
|
@ -61,6 +67,24 @@ bool dir_exists(const fs::path &p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(WITH_NATIVE_FILESYSTEM)
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
|
||||||
|
bool file_exists(const std::string &p) {
|
||||||
|
DWORD attrs = GetFileAttributes(p.c_str());
|
||||||
|
return (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dir_exists(const std::string &p) {
|
||||||
|
DWORD attrs = GetFileAttributes(p.c_str());
|
||||||
|
return (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Unsupported native filesystem"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> get_plugin_paths() {
|
std::vector<std::string> get_plugin_paths() {
|
||||||
|
@ -69,7 +93,7 @@ std::vector<std::string> get_plugin_paths() {
|
||||||
|
|
||||||
cv::FileStorage fs(info_path, cv::FileStorage::READ);
|
cv::FileStorage fs(info_path, cv::FileStorage::READ);
|
||||||
if (!fs.isOpened()) {
|
if (!fs.isOpened()) {
|
||||||
// LOG(ERROR) << "build.info not found";
|
LOG(WARNING) << "build.info not found: " << info_path;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,19 +107,27 @@ std::vector<std::string> get_plugin_paths() {
|
||||||
to_lower(host_name);
|
to_lower(host_name);
|
||||||
std::string host_arch = fs["HOST_ARCH"];
|
std::string host_arch = fs["HOST_ARCH"];
|
||||||
to_lower(host_arch);
|
to_lower(host_arch);
|
||||||
// std::string gcc_version = fs["GCC_VERSION"];
|
std::string host_compiler = fs["HOST_COMPILER"];
|
||||||
int gcc_version_major = fs["GCC_VERSION_MAJOR"];
|
to_lower(host_compiler);
|
||||||
// int gcc_version_minor = fs["GCC_VERSION_MINOR"];
|
|
||||||
|
// std::string compiler_version = fs["COMPILER_VERSION"];
|
||||||
|
int compiler_version_major = fs["COMPILER_VERSION_MAJOR"];
|
||||||
|
// int compiler_version_minor = fs["COMPILER_VERSION_MINOR"];
|
||||||
|
// int compiler_version_patch = fs["COMPILER_VERSION_PATCH"];
|
||||||
|
// int compiler_version_tweak = fs["COMPILER_VERSION_TWEAK"];
|
||||||
|
|
||||||
std::string cuda_version = fs["CUDA_VERSION"];
|
std::string cuda_version = fs["CUDA_VERSION"];
|
||||||
// int cuda_version_major = fs["CUDA_VERSION_MAJOR"];
|
// int cuda_version_major = fs["CUDA_VERSION_MAJOR"];
|
||||||
// int cuda_version_minor = fs["CUDA_VERSION_MINOR"];
|
// int cuda_version_minor = fs["CUDA_VERSION_MINOR"];
|
||||||
// std::string cuda_version_string = fs["CUDA_VERSION_STRING"];
|
// std::string cuda_version_string = fs["CUDA_VERSION_STRING"];
|
||||||
|
|
||||||
std::string opencv_version = fs["OpenCV_VERSION"];
|
std::string opencv_version = fs["OpenCV_VERSION"];
|
||||||
// int opencv_version_major = fs["OpenCV_VERSION_MAJOR"];
|
// int opencv_version_major = fs["OpenCV_VERSION_MAJOR"];
|
||||||
// int opencv_version_minor = fs["OpenCV_VERSION_MINOR"];
|
// int opencv_version_minor = fs["OpenCV_VERSION_MINOR"];
|
||||||
// int opencv_version_patch = fs["OpenCV_VERSION_PATCH"];
|
// int opencv_version_patch = fs["OpenCV_VERSION_PATCH"];
|
||||||
// int opencv_version_tweak = fs["OpenCV_VERSION_TWEAK"];
|
// int opencv_version_tweak = fs["OpenCV_VERSION_TWEAK"];
|
||||||
// std::string opencv_version_status = fs["OpenCV_VERSION_STATUS"];
|
// std::string opencv_version_status = fs["OpenCV_VERSION_STATUS"];
|
||||||
|
|
||||||
std::string mynteye_version = fs["MYNTEYE_VERSION"];
|
std::string mynteye_version = fs["MYNTEYE_VERSION"];
|
||||||
// int mynteye_version_major = fs["MYNTEYE_VERSION_MAJOR"];
|
// int mynteye_version_major = fs["MYNTEYE_VERSION_MAJOR"];
|
||||||
// int mynteye_version_minor = fs["MYNTEYE_VERSION_MINOR"];
|
// int mynteye_version_minor = fs["MYNTEYE_VERSION_MINOR"];
|
||||||
|
@ -107,7 +139,7 @@ std::vector<std::string> get_plugin_paths() {
|
||||||
std::string lib_prefix;
|
std::string lib_prefix;
|
||||||
std::string lib_suffix;
|
std::string lib_suffix;
|
||||||
if (host_os == "linux") {
|
if (host_os == "linux") {
|
||||||
if (gcc_version_major < 5)
|
if (host_compiler != "gnu" || compiler_version_major < 5)
|
||||||
return {};
|
return {};
|
||||||
lib_prefix = "lib";
|
lib_prefix = "lib";
|
||||||
lib_suffix = ".so";
|
lib_suffix = ".so";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user