Skip to content

Instantly share code, notes, and snippets.

@ryutorion
Created July 6, 2020 16:50
Show Gist options
  • Save ryutorion/899bcd8d8d4546a03ce74eaa31951261 to your computer and use it in GitHub Desktop.
Save ryutorion/899bcd8d8d4546a03ce74eaa31951261 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 3.17.3)
# C++標準を指定
set(CMAKE_CXX_STANDARD 17)
# C++標準のサポート必須
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 拡張機能を無効化
set(CMAKE_CXX_EXTENSIONS OFF)
if(MSVC)
# 動的型情報の使用を禁止
string(REPLACE "/GR-" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# 例外を無しに
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(APPEND CMAKE_CXX_FLAGS " /D_HAS_EXCEPTIONS=0")
# 警告をエラーに
string(APPEND CMAKE_CXX_FLAGS " /WX")
# 警告レベルを設定
string(APPEND CMAKE_CXX_FLAGS " /W4")
# 標準準拠モードを有効に
target_compile_options(
${TARGET_NAME}
PRIVATE
"/permissive-"
)
# WIN32_LEAN_AND_MEAN : 無駄な宣言を省く
# NOMINMAX : min/maxマクロを使用しない
target_compile_definitions(
${TARGET_NAME}
PRIVATE
WIN32_LEAN_AND_MEAN
NOMINMAX
)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment