cmakelists例子
cmake例子
项目特定的逻辑。
cmake_minimum_required (VERSION 3.8)
project (“c_Plus_Plus”)
----------------------------------add opencv lib----------------------------------
find_package(OpenCV)
If the package has been found, several variables will
be set, you can find the full list with descriptions
in the OpenCVConfig.cmake file.
Print some message showing some of them
message(STATUS “OpenCV library status:”)
message(STATUS " version: ${OpenCV_VERSION}“)
message(STATUS " libraries: ${OpenCV_LIBS}”)
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
----------------------------------add opencv lib----------------------------------
set(BUILD_LIBS 0) # 是否编译出库文件
set(LINUX 1)
add_definitions(-DLINUX)
add_compile_options(-pg)
MESSAGE(STATUS “work in linux”)
include_directories(
“KaTeX parse error: Expected 'EOF', got '#' at position 38: …DIR}/include" #̲"{CMAKE_CURRENT_SOURCE_DIR}/bin/linux/include”
“${OpenCV_INCLUDE_DIRS}”
)
link_directories(
“KaTeX parse error: Expected 'EOF', got '#' at position 37: …_DIR}/libs/" ) #̲MESSAGE(STATUS …{CMAKE_CURRENT_SOURCE_DIR}”)
aux_source_directory(“${CMAKE_CURRENT_SOURCE_DIR}/src/” DIR_SRCS)
MESSAGE(STATUS “src:${DIR_SRCS}”)
将源代码添加到此项目的可执行文件。
add_executable (${PROJECT_NAME} ${DIR_SRCS})
target_link_libraries( P R O J E C T N A M E p t h r e a d ) t a r g e t l i n k l i b r a r i e s ( {PROJECT_NAME} pthread) target_link_libraries( PROJECTNAMEpthread)targetlinklibraries({PROJECT_NAME} ${OpenCV_LIBS} ${CMAKE_CURRENT_SOURCE_DIR}/bin/lib/*.a)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET fc_Plus_Plus PROPERTY CXX_STANDARD 20)
endif()
SET(CMAKE_INSTALL_PREFIX “${CMAKE_CURRENT_SOURCE_DIR}/bin/linux/”)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX})
#/bin/linux/${CMAKE_SYSTEM_PROCESSOR})