feat:调整CMake

master
邱棚 2024-07-04 11:12:39 +08:00
parent 6c3b52564b
commit a9f462bcbd
3 changed files with 13 additions and 16 deletions

View File

@ -14,12 +14,12 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
# Check C++11 or C++0x support # Check C++11 or C++0x support
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
add_definitions(-DCOMPILEDWITHC11) add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.") message(STATUS "Using flag -std=c++14.")
elseif(COMPILER_SUPPORTS_CXX0X) elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X) add_definitions(-DCOMPILEDWITHC0X)
@ -32,9 +32,9 @@ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
# opencvdbowros # opencvdbowros
# 3 4 # 3 4
find_package(OpenCV 3.2) find_package(OpenCV 4.2)
if(NOT OpenCV_FOUND) if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 3.2 not found.") message(FATAL_ERROR "OpenCV > 4.2 not found.")
endif() endif()
MESSAGE("OPENCV VERSION:") MESSAGE("OPENCV VERSION:")

View File

@ -14,12 +14,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")
# Check C++11 or C++0x support # Check C++11 or C++0x support
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
add_definitions(-DCOMPILEDWITHC11) add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.") message(STATUS "Using flag -std=c++14.")
elseif(COMPILER_SUPPORTS_CXX0X) elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X) add_definitions(-DCOMPILEDWITHC0X)
@ -32,9 +32,9 @@ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../../cmake_modules)
# opencvdbowros # opencvdbowros
# 3 4 # 3 4
find_package(OpenCV 3.2) find_package(OpenCV 4.2)
if(NOT OpenCV_FOUND) if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 3.2 not found.") message(FATAL_ERROR "OpenCV > 4.2 not found.")
endif() endif()
find_package(Eigen3 3.1.0 REQUIRED) find_package(Eigen3 3.1.0 REQUIRED)

View File

@ -30,12 +30,9 @@ set(SRCS_DUTILS
# opencvdbowros # opencvdbowros
# 3 4 # 3 4
find_package(OpenCV 3.2 QUIET) find_package(OpenCV 4.2 QUIET)
if(NOT OpenCV_FOUND) if(NOT OpenCV_FOUND)
find_package(OpenCV 3.0 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 3.0 not found.") message(FATAL_ERROR "OpenCV > 3.0 not found.")
endif()
endif() endif()
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)