cmake - 샘플

C++ 2017. 5. 29. 19:29




cmake_minimum_required(VERSION 2.8)


project(ven)

include_directories(ven/include)


# verbose makefile

set(CMAKE_VERBOSE_MAKEFILE true)


# supress ZERO_CHECK

set(CMAKE_SUPPRESS_REGENERATION true)



# visual studio : 폴더 소스 별로 filter 생성

set(_SRC_DIR "${ven_SOURCE_DIR}/include")

file(GLOB_RECURSE _SRC_LIST

  LIST_DIRECTORIES false

  "${_SRC_DIR}/*.h"

  "${_SRC_DIR}/*.hpp"

  "${_SRC_DIR}/*.cpp"

)


foreach(SRC IN ITEMS ${_SRC_LIST})

  get_filename_component(_SRC_PATH "${SRC}" PATH)

  file(RELATIVE_PATH _SRC_REL_PATH "${_SRC_DIR}" "${_SRC_PATH}")

  string(REPLACE "/" "\\" _GROUP_PATH "${_SRC_REL_PATH}")

  source_group("${_GROUP_PATH}" FILES "${SRC}")

endforeach()


# avoid SourceFiles, HeaderFiles

source_group("" FILES main.cpp)


add_executable(ven main.cpp ${_SRC_LIST})