三次元日誌(hugo)

すぐ忘れるのでここをチートシート化しよう。

commandline

構成

solution

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(hello) # .sln

subdirectory

ADD_SUBDIRECTORY(src)

target

exe

ADD_EXECUTABLE(hello
    main.cpp
    renderer.cpp
    scene.cpp
    )

fileを集める例

FILE(GLOB SRC
    *.cpp
    *.h
    )
ADD_EXECUTABLE(hello
    ${SRC}
    )

static lib

ADD_LIBRARY(renderer STATIC
    renderer.cpp
    )

dll

ADD_LIBRARY(renderer SHARED
    renderer.cpp
    )

compile

source

FILE(GLOB SOURCES
*.cpp
*.h
)

compiler options

SET(CMAKE_CXX_FLAGS "-Wall")

include path

INCLUDE_DIRECTORIES(libpath/include)

define

ADD_DEFINITIONS(-DWITH_OPENCV2)

link

LINK_DIRECTORIES(libpath/lib)

x86とx64で違うパスにしたい時は?

example

CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(hello) # hello.sln
ADD_EXECUTABLE(hello main.cpp) # hello.vcxproj

set(CMAKE_CXX_FLAGS "/WD4096")
set(CMAKE_C_FLAGS "/WD4096")
include_directories(libpath/include)
add_definitions(
    -DUNICODE
    -D_UNICODE
    )