CMake/Tutorials/C++Compilers

From KitwarePublic
< CMake‎ | Tutorials
Revision as of 10:24, 21 September 2012 by Daviddoria (talk | contribs) (Created page with "<source lang="cmake"> cmake_minimum_required(VERSION 2.6) PROJECT(C++) IF(WIN32) # Check if we are on Windows if(MSVC) # Check if we are using the Visual Studio compiler ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
cmake_minimum_required(VERSION 2.6)

PROJECT(C++)

IF(WIN32) # Check if we are on Windows
  if(MSVC) # Check if we are using the Visual Studio compiler
    SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} /SUBSYSTEM:WINDOWS") # Tell the project how to behave in this environment
  elseif(CMAKE_COMPILER_IS_GNUCXX)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Tell the project how to behave in this environment
  else()
    message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)")
  endif()
elseif(UNIX)
  add_executable(Test Test.cpp) # Tell the project how to behave in this environment
else()
  message(SEND_ERROR "You are on an unsupported platform! (Not Win32 or Unix)")
ENDIF()