CMake/Tutorials/C++Compilers: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(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 ...")
 
No edit summary
Line 19: Line 19:


</source>
</source>
{{CMake/Template/Footer}}

Revision as of 12:33, 24 April 2018

<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>



CMake: [Welcome | Site Map]