CMake/Tutorials/C++Compilers
From KitwarePublic
Jump to navigationJump to search
<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 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()
</source>