すぐ忘れるのでここをチートシート化しよう。
構成
solution
subdirectory
add_subdirectory — CMake 3.29.2 Documentation
https://cmake.org/cmake/help/latest/command/add_subdirectory.html
もしくは
target
exe
add_executable — CMake 3.29.2 Documentation
https://cmake.org/cmake/help/latest/command/add_executable.html
file を集める例
fo winmain
static lib
add_library — CMake 3.29.2 Documentation
https://cmake.org/cmake/help/latest/command/add_library.html
dll
compile
compiler options
全体
ターゲット指定
include path
全体
以降の ADD_XXX に対して有効になる
ターゲット指定
PUBLIC の部分はよくわからぬ。
define
全体
以降の ADD_XXX に対して有効になる
ターゲット指定
PUBLIC の部分はよくわからぬ。
-D なし
link
link path
x86 と x64 で違うパスにしたい時は?
Debug Release の切り分け
変数
ソース
ビルドディレクトリ
cmake -G CMAKE_SOURCE_DIR を実行したディレクトリ
The path to the top level of the build tree
出力ディレクトリ
exe と dll の出力先。
example
CMakeLists.txt