Update CMakeLists.txt
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
|
||||
cmake_include_guard()
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
set(CUR_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
|
||||
cmake_include_guard()
|
||||
|
||||
if(MSVC)
|
||||
|
||||
# Support For C++11/14/17 Features (Modern C++)
|
||||
|
||||
30
cmake/DetectOpenCV.cmake
Normal file
30
cmake/DetectOpenCV.cmake
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
|
||||
cmake_include_guard()
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
|
||||
if(OpenCV_VERSION VERSION_LESS 3.0)
|
||||
add_definitions(-DUSE_OPENCV2)
|
||||
else()
|
||||
add_definitions(-DUSE_OPENCV3)
|
||||
endif()
|
||||
|
||||
if(MSVC OR MSYS OR MINGW)
|
||||
get_filename_component(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}/../bin" ABSOLUTE)
|
||||
else()
|
||||
set(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}")
|
||||
endif()
|
||||
23
cmake/IncludeGuard.cmake
Normal file
23
cmake/IncludeGuard.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# include_guard: https://cmake.org/cmake/help/latest/command/include_guard.html
|
||||
|
||||
macro(cmake_include_guard)
|
||||
get_property(INCLUDE_GUARD GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}")
|
||||
if(INCLUDE_GUARD)
|
||||
return()
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}" TRUE)
|
||||
endmacro()
|
||||
51
cmake/Utils.cmake
Normal file
51
cmake/Utils.cmake
Normal file
@@ -0,0 +1,51 @@
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
|
||||
cmake_include_guard()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
|
||||
|
||||
# make_executable(NAME
|
||||
# [SRCS src1 src2 ...]
|
||||
# [LINK_LIBS lib1 lib2 ...]
|
||||
# [DLL_SEARCH_PATHS path1 path2 ...]
|
||||
# [WITH_THREAD])
|
||||
macro(make_executable NAME)
|
||||
set(options WITH_THREAD)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs SRCS LINK_LIBS DLL_SEARCH_PATHS)
|
||||
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
|
||||
add_executable(${NAME} ${THIS_SRCS})
|
||||
target_link_libraries(${NAME} ${THIS_LINK_LIBS})
|
||||
target_create_scripts(${NAME} DLL_SEARCH_PATHS ${THIS_DLL_SEARCH_PATHS})
|
||||
|
||||
if(OS_WIN)
|
||||
target_compile_definitions(${NAME}
|
||||
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
)
|
||||
endif()
|
||||
|
||||
if(THIS_WITH_THREAD)
|
||||
#find_package(Threads REQUIRED)
|
||||
if(THREADS_HAVE_PTHREAD_ARG)
|
||||
target_compile_options(PUBLIC ${NAME} "-pthread")
|
||||
endif()
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
target_link_libraries(${NAME} "${CMAKE_THREAD_LIBS_INIT}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user