cmake 문법 기초

5387 단어

cmake use

  • 홈 디렉토리에서 CMakeLists
  • cmake_minimum_required(VERSION 3.9.5)
    project(exchange)
    
    message(${PROJECT_SOURCE_DIR})
    
    set(CMAKE_C_COMPILER "gcc")
    set(CMAKE_CXX_COMPILER "g++")
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wno-deprecated -Wall")
    
    #  
    foreach(flag ${CMAKE_CXX_FLAGS})
        message(${flag})
    endforeach()
    
    # pkg-config
    find_package(PkgConfig)
    
    # generate lib
    #SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
    #aux_source_directory(. DIR_INC)
    #add_library(hellolib ${DIR_INC})
    
    pkg_search_module(OPENCV REQUIRED opencv)
    message(${OPENCV_LIBRARIES})
    message(${OPENCV_INCLUDE_DIRS})
    
    aux_source_directory(. DIR_MAIN)
    include_directories(${PROJECT_SOURCE_DIR}/inc)
    link_directories(${PROJECT_SOURCE_DIR}/lib)
    # add_subdirectory(inc) #  lib , lib 
    
    add_executable(exchange
            ${DIR_MAIN})
    
    target_link_libraries(
            exchange
            test
            thosttraderapi_se
    )
    
    
  • inc 디렉터리에서 lib 라이브러리를 생성하는 데 사용되는 CMakeLists
  • cmake_minimum_required(VERSION 3.9.5)
    
    # generate lib
    SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
    aux_source_directory(. DIR_INC)
    add_library(hellolib ${DIR_INC})
    

    좋은 웹페이지 즐겨찾기