Skip to content

Instantly share code, notes, and snippets.

@atinfinity
Last active January 8, 2024 06:20
Show Gist options
  • Save atinfinity/d84165bd3796bc73433a to your computer and use it in GitHub Desktop.
Save atinfinity/d84165bd3796bc73433a to your computer and use it in GitHub Desktop.
コンパイラ情報を取得するCMakeLists.txt
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}\n")
message(STATUS "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}\n")
message(STATUS "CMAKE_C_COMPILER_VERSION: ${CMAKE_C_COMPILER_VERSION}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}\n")
if(MSVC)
message(STATUS "MSVC_VERSION: ${MSVC_VERSION}")
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET: ${CMAKE_VS_PLATFORM_TOOLSET}")
string(SUBSTRING ${CMAKE_VS_PLATFORM_TOOLSET} 1 3 VS_PLATFORM_TOOLSET_VERSION_NUM)
message(STATUS "VS_PLATFORM_TOOLSET_VERSION_NUM: ${VS_PLATFORM_TOOLSET_VERSION_NUM}")
endif()
@atinfinity
Copy link
Author

コンパイラ情報を取得するCMakeLists.txt

CMakeのGeneratorをVisual Studio 12 2013 Win64と指定した場合の結果は以下の通り.

CMAKE_GENERATOR: Visual Studio 12 2013 Win64

CMAKE_C_COMPILER_ID: MSVC
CMAKE_CXX_COMPILER_ID: MSVC

CMAKE_C_COMPILER_VERSION: 18.0.40629.0
CMAKE_CXX_COMPILER_VERSION: 18.0.40629.0

MSVC_VERSION: 1800
CMAKE_VS_PLATFORM_TOOLSET: v120
VS_PLATFORM_TOOLSET_VERSION_NUM: 120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment