Cmakelists一版教程

  • Post author:
  • Post category:其他


cmake_minimum_required(VERSION 3.00)
project(just_test)

set(CMAKE_CXX_STANDARD 11 )
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread" )


set(SOURCE_FILES main.cpp)

SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -g -Wall")

# OpenMP
FIND_PACKAGE(OpenMP REQUIRED)
if(OPENMP_FOUND)
    message("OPENMP FOUND")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
include_directories(${OpenMP_INCLUDE_DIRS})

# boost
find_package(Boost REQUIRED)
#find_package(Boost REQUIRED COMPONENTS system filesystem)
if(!Boost_FOUND)
    message("Boost NOT FOUND")
endif()
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

# opencv
find_package( OpenCV REQUIRED )
if(!Opencv_FOUND)
    message("OpenCV NOT FOUND")
endif()
include_directories(${Opencv_INCLUDE_DIRS})
link_directories(${Opencv_LIBRARY_DIRS})

include_directories (
        /usr/include
        /usr/local/include
#        ./include
#        ./include/rapidjson
#        ./include/mitab
)

add_executable(just_test ${SOURCE_FILES})


#target_link_libraries(just_test ${Boost_LIBRARIES})
#target_link_libraries(just_test ${OpenCV_LIBS})

target_link_libraries(just_test
        ${OpenCV_LIBS}
        libboost_regex.so
        libboost_filesystem.so
        libboost_system.so
        libglog.so
#        libsqlite3.so
#        libmitab.so
        )



版权声明:本文为djt4541原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。